-
Notifications
You must be signed in to change notification settings - Fork 0
/
1063.cpp
51 lines (50 loc) · 1.03 KB
/
1063.cpp
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
41
42
43
44
45
46
47
48
49
50
51
//
// main.cpp
// test
//
// Created by 李寻欢 on 2019/10/8.
// Copyright © 2019 李寻欢. All rights reserved.
//
#include <stdio.h>
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <set>
using namespace std;
set<int> s[51];
int main(){
int n;
scanf("%d",&n);
for (int i=1; i<=n; i++) {
int m;
scanf("%d",&m);
for (int j=0; j<m; j++) {
int val;
scanf("%d",&val);
s[i].insert(val);
}
}
int k;
scanf("%d",&k);
for (int i=0; i<k; i++) {
int a,b;
scanf("%d%d",&a,&b);
double common = 0;
int size = s[b].size();
for (auto it = s[a].begin(); it != s[a].end(); it++) {
if (s[b].find(*it) != s[b].end()) {
common++;
}else
size++;
}
printf("%.1lf%%\n",common/size*100);
}
return 0;
}