-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1063.cpp
More file actions
41 lines (40 loc) · 739 Bytes
/
1063.cpp
File metadata and controls
41 lines (40 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int n, k;
cin>>n;
vector<set<int>> st(n+1);
for(int i=1; i<=n; i++){
int m;
cin>>m;
while(m--){
int x;
cin>>x;
st[i].insert(x);
}
}
cin>>k;
while(k--){
int a, b, nc = 0, nt;
cin>>a>>b;
if(st[a].size() > st[b].size()){
for(auto it=st[b].begin(); it!=st[b].end(); it++){
auto it2 = st[a].find(*it);
if(it2 != st[a].end()){
nc++;
}
}
}else{
for(auto it=st[a].begin(); it!=st[a].end(); it++){
auto it2 = st[b].find(*it);
if(it2 != st[b].end()){
nc++;
}
}
}
nt = st[a].size() + st[b].size() - nc;
cout<<fixed<<setprecision(1)<<(double)nc/nt*100.0<<"%\n";
}
return 0;
}