-
Notifications
You must be signed in to change notification settings - Fork 4
/
UVA00409.cpp
50 lines (47 loc) · 1.23 KB
/
UVA00409.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
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <unordered_set>
#include <sstream>
using namespace std;
bool match(char c) {
return !isalnum(c) && !isspace(c);
}
char func(char c) {
if (match(c)) return ' ';
return c;
}
int main() {
int K, E, set = 1;
string s;
unordered_set<string> l;
while (cin >> K >> E) {
l.clear();
for (int i = 0; i < K; i++) {
cin >> s;
l.insert(s);
}
int m = 0;
string output = "";
getline(cin, s);
for (int i = 0; i < E; i++) {
int cont = 0;
getline(cin, s);
string aux = s;
transform(aux.begin(), aux.end(), aux.begin(), ::tolower);
transform(aux.begin(), aux.end(), aux.begin(), &func);
//aux.erase(remove_if(aux.begin(), aux.end(), &match), s.end());
stringstream ss;
ss << aux;
while (ss >> aux) {
if (l.count(aux)) cont++;
}
if (cont == m) output += "\n" + s;
else if (cont > m) output = s, m = cont;
}
cout << "Excuse Set #" << set << "\n" << output << endl << endl;
set++;
}
return 0;
}