当前位置:网站首页>L2-005 set similarity (set judgment)
L2-005 set similarity (set judgment)
2022-04-22 07:26:00 【S atur】


Ideas : A question of comparing water , However, if you want to pass all test points, you need to consider the maximum complexity .
Code implementation :
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 100;
int n, m, x, k;
set<int> s[N], tmp;
signed main()
{
cin >> n;
for(int i = 1; i <= n; i ++){
cin >> m;
for(int j = 0; j < m; j ++){
cin >> x;
s[i].insert(x);
}
}
cin >> k;
for(int i = 0; i < k; i ++){
int s1, s2;
cin >> s1 >> s2;
// The last test point will time out
// tmp.clear();
// for(auto x:s[s1]){
// tmp.insert(x);
// }
// for(auto x:s[s2]){
// tmp.insert(x);
// }
// int nt = tmp.size();
// int nc = s[s1].size()+s[s2].size()-nt;
int nc = 0, nt = s[s2].size();
for(auto x:s[s1]){
if(s[s2].find(x)!=s[s2].end()) nc ++;
else nt ++;
}
cout << fixed << setprecision(2) << nc*100.0/nt << "%\n";
}
return 0;
}
版权声明
本文为[S atur]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220616059381.html
边栏推荐
- 面试官常问的,对象分配的一般过程及特殊情况
- Error: (vlog-2892) Net type of 'i_ yc422' must be explicitly declared.
- If I make this silly mistake again/ (ㄒoㄒ)/~~
- LeetCode -3 - (字符串相加、最大连续1的个数<ⅠⅢ>、考试的最大困扰度、删除链表的倒数第N个结点)
- 要是我再犯这种憨憨错误就.../(ㄒoㄒ)/~~
- (4) Character set in SQL Server (collation)
- L2-001 紧急救援 (最短路Dijkstra的扩展 - 最短路径数&路径最大权值)
- Codeforces Round #634 (Div. 3)
- [number theory] congruence (III): univariate linear congruence equation
- Anaconda安装与使用
猜你喜欢

Vscode, this is enough

我们常说的栈帧的内部结构是什么样的呢?
![Error: [HSI 55-1545], unable to generate fsbl normally, unable to read in MSS file, failed to close system mss](/img/4e/34e2820ff8579007b20b33b27d8f1d.png)
Error: [HSI 55-1545], unable to generate fsbl normally, unable to read in MSS file, failed to close system mss

字节暑期实习一面——20220304

Vivado generates and invokes EDF netlist files

L2-005 集合相似度(set判重)

Complete a student information management system and systematically practice object-oriented, function, string and other knowledge. Realize the comprehensive application of knowledge. Use classes, fun

The only storage area in the JVM where GC and oom will not occur

LaTex中添加作者照片和作者简介

I.Jam-packed (均分/最大最小值) (2021年度训练联盟热身训练赛第五场)
随机推荐
1232 · 爆破气球的最小箭头数
【数论】欧拉函数(基本性质、递推法、公式法、线性筛法)
Unknown graphics extension:. 1 jpg. }
JVM中的逃逸分析,可以实现不在堆上分配内存
L2-004 这是二叉搜索树吗?(先序输入&判断搜索二叉树&后序输出)
Singleton pool, singleton bean, singleton mode
递归找序列集合
363 · 接雨水
浅谈时间复杂度与空间复杂度
[number theory] [indefinite equation] n-ary primary indefinite equation, Pell equation, Pythagoras theorem, Fermat theorem
美团春招暑期实习笔试——20220312
Codeforces Round #780 (Div. 3)
LeetCode -3 - (字符串相加、最大连续1的个数<ⅠⅢ>、考试的最大困扰度、删除链表的倒数第N个结点)
要是我再犯这种憨憨错误就.../(ㄒoㄒ)/~~
C language | array
Redis advanced
LaTex中插入图片报错Unknown graphics extension: .1.jpg. }
LeetCode - 4 - (接雨水、无重复字符的最长子串、分发糖果、二叉树的<前中后层>序遍历)
二叉树链式结构操作LeetCode+牛客(详解)
Precautions for using feign to make remote calls