-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path1975.cpp
48 lines (39 loc) · 976 Bytes
/
1975.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
/*
ad-hoc > implementation
difficulty: easy
date: 06/Apr/2020
by: @brpapa
*/
#include <bits/stdc++.h>
using namespace std;
int main() {
int P, A, R;
while (cin >> P >> A >> R >> ws && (P || A || R)) {
set<string> p;
while (P--) {
string s; getline(cin, s);
p.insert(s);
}
map<string, int> as;
int mx = -1;
while (A--) {
string sa; getline(cin, sa);
set<string> tmp;
for (int r = 0; r < R; r++) {
string pa; getline(cin, pa);
if (p.count(pa)) tmp.insert(pa);
}
as[sa] = as[sa] + tmp.size();
mx = max(mx, as[sa]);
}
vector<string> ans;
for (auto a : as) {
string sa = a.first;
int count = a.second;
if (count == mx) ans.push_back(sa);
}
for (int i = 0; i+1 < ans.size(); i++) cout << ans[i] << ", ";
cout << ans.back() << endl;
}
return 0;
}