题目链接:https://www.patest.cn/contests/pat-a-practise/1063
//freopen("C:\\Users\\yehao\\Desktop\\Test\\bin\\Release\\in1.txt", "r", stdin);
#include <cstdio>
#include <vector>
#include <string>
#include <string.h>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main(){
freopen("C:\\Users\\yehao\\Desktop\\Test\\bin\\Release\\in1.txt", "r", stdin);
int n=0;
cin>>n;
vector< map<int,int> > datas(n);
for(int i=0;i<n;i++){
int m=0;
cin>>m;
for(int j=0;j<m;j++){
int t=0;
cin>>t;
datas[i][t]=1;
}
}
int k=0;
cin>>k;
for(int i=0 ; i<k; i++){
int _id1 , _id2;
cin>>_id1>>_id2;
int id1=min(_id1 , _id2)-1;
int id2=max(_id1 , _id2)-1;
int nc=0 , nt=0;
for(map<int,int>::iterator it=datas[id1].begin() ; it!=datas[id1].end() ; ++it) if(datas[id2].find( it->first ) !=datas[id2].end())nc++;
nt=datas[id1].size() +datas[id2].size() - nc;
printf("%.1f%%\n",nc*100.0/nt);
}
return 0;
}