Note
Code:
#include<bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
freopen("data.txt","r",stdin);
#endif
int n,count,num,k;
scanf("%d",&n);
unordered_set<int> v[n+1];
for(int i=1;i<=n;i++){
scanf("%d",&count);
for(int j=0;j<count;j++){
scanf("%d",&num);
v[i].insert(num);
}
}
scanf("%d",&k);
unordered_set<int> vc;
int len1,len2,t,s;
for(int i=1;i<=k;i++){
scanf("%d %d",&t,&s);
count=0;
vc.clear();
if(v[t].size()<v[s].size()) swap(t,s);
for(unordered_set<int>::iterator it=v[t].begin();it!=v[t].end();it++){
vc.insert(*it);
}
for(unordered_set<int>::iterator it=v[s].begin();it!=v[s].end();it++){
len1=vc.size();
vc.insert(*it);
len2=vc.size();
if(len1==len2) count++;
}
printf("%.1lf%\n",100.0*count/vc.size());
}
return 0;
}