#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#define db(a) \
cout << #a << " = " << a << endl
#define db2(a, b) \
cout << #a << " = " << a << " " << #b << " = " << b << endl
#define inf (1<<30)
#define foreach(m, it) \
for (typeof(m.begin()) it = m.begin(); it != m.end(); it++)
using namespace std;
string limpiar(string s) {
int n = s.size();
for (int i = 0; i < n; i++) {
if (!isalpha(s[i])) s[i] = ' ';
else s[i] = tolower(s[i]);
}
return s;
}
bool contain(vector<string> & lista, string keyword) {
int n = lista.size();
for (int i = 0; i < n; i++) {
if (lista[i] == keyword)
return true;
}
return false;
}
int main() {
#ifdef dennisbot
freopen("in.in", "r", stdin);
freopen("ou.out", "w", stdout);
#endif
int k, x;
vector<string> keywords;
map<string, int> excuses;
char keyword[40], excuse[100];
int cont = 1;
while (scanf("%d %d\n", &k, &x) != EOF) {
keywords.clear();
excuses.clear();
for (int i = 0; i < k; i++) {
gets(keyword);
keywords.push_back(keyword);
}
for (int i = 0; i < x; i++) {
gets(excuse);
excuses[(string)excuse];
}
int best = 0;
foreach(excuses, it) {
string cad = limpiar(it->first);
char *st, *buf, sep[] = " ";
buf = strdup(cad.c_str());
st = strtok(buf, sep);
while (st) {
if (contain(keywords, st))
it->second++;
st = strtok(0, sep);
}
best = max(it->second, best);
}
printf("Excuse Set #%d\n", cont++);
foreach(excuses, it) {
if (it->second == best)
printf("%s\n", it->first.c_str());
}
puts("");
}
return 0;
}
Here is the Statementviernes, 13 de julio de 2012
409 - Excuses, Excuses, uva
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario