include iostream include vector include string using namespace std int

 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
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n,
k,
col;
string input;
cin >> n;
vector <vector <string>> DB(n);
for (int i = 0; i < n; ++i) {
cin >> col;
for (int j = 0; j < col; ++j) {
cin >> input;
DB[i].push_back(input);
}
}
cin >> k;
vector <vector <string>> query(k);
for (int i = 0; i < k; ++i) {
cin >> col;
for (int j = 0; j < col; ++j) {
cin >> input;
query[i].push_back(input);
}
}
for (int i = 0; i < query.size(); ++i){
int f_count = 0;
for (int p = 0; p < DB.size(); ++p) {
int count = 0;
for (int j = 0; j < query[i].size(); ++j) {
string curQ = query[i][j];
for (int u = 0; u < DB[p].size(); ++u) {
string curV = DB[p][u];
if (curQ == curV)
count++;
}
}
if (count == query[i].size())
f_count++;
}
cout << f_count << endl;
}
//system("pause");
return 0;
}