#include <bits/stdc++.h>
using namespace std;
struct data{
string str_key;
}ar[100];
int main(){
int cnt, ans, k, l, cs = 0, bl = 0;
string keyword, sentence, temp, new_key;
vector <int> mx;
map <string, int> F, out;
while(cin >> l >> k){
F.clear(), cnt = 0, mx.clear(), out.clear(), temp.clear(), sentence.clear(), keyword.clear();
for(int i = 0; i < 100; i++)ar[i].str_key.clear();
int mxx = 0;
for(int i = 0; i < l; i++){
cin >> keyword;
for(int i = 0; i < keyword.size(); i++){
if(keyword[i] >= 'a' && keyword[i] <= 'z')new_key.push_back(keyword[i]-32);
if(keyword[i] >= 'A' && keyword[i] <= 'Z')new_key.push_back(keyword[i]);
}
F[new_key] = 1;
new_key.clear();
}
cin.ignore();
for(int i = 0; i < k; i++){
getline(cin, sentence);
ar[i].str_key = sentence;
int sz = sentence.size();
for(int i = 0; i < sz; i++){
if(i == sz-1 || (sentence[i] >= 32 && sentence[i] <= 64) || (sentence[i] >= '0' && sentence[i] <= '9')){
if(sentence[i] >= 'a' && sentence[i] <= 'z')temp.push_back(sentence[i]-32);
if(sentence[i] >= 'A' && sentence[i] <= 'Z')temp.push_back(sentence[i]);
if(F[temp])cnt++;
temp.clear();
}
else{
if(sentence[i] >= 'a' && sentence[i] <= 'z')temp.push_back(sentence[i]-32);
if(sentence[i] >= 'A' && sentence[i] <= 'Z')temp.push_back(sentence[i]);
}
}
out[sentence] = cnt;
mx.push_back(cnt);
cnt = 0;
}
int L = mx.size();
for(int i = 0; i < L; i++)mxx = max(mxx, mx[i]);
cout << "Excuse Set #" << ++cs << endl;
for(int i = 0; i < k; i++){
if(out[ar[i].str_key] == mxx)cout << ar[i].str_key << endl;
}
cout << endl;
}
return 0;
}
using namespace std;
struct data{
string str_key;
}ar[100];
int main(){
int cnt, ans, k, l, cs = 0, bl = 0;
string keyword, sentence, temp, new_key;
vector <int> mx;
map <string, int> F, out;
while(cin >> l >> k){
F.clear(), cnt = 0, mx.clear(), out.clear(), temp.clear(), sentence.clear(), keyword.clear();
for(int i = 0; i < 100; i++)ar[i].str_key.clear();
int mxx = 0;
for(int i = 0; i < l; i++){
cin >> keyword;
for(int i = 0; i < keyword.size(); i++){
if(keyword[i] >= 'a' && keyword[i] <= 'z')new_key.push_back(keyword[i]-32);
if(keyword[i] >= 'A' && keyword[i] <= 'Z')new_key.push_back(keyword[i]);
}
F[new_key] = 1;
new_key.clear();
}
cin.ignore();
for(int i = 0; i < k; i++){
getline(cin, sentence);
ar[i].str_key = sentence;
int sz = sentence.size();
for(int i = 0; i < sz; i++){
if(i == sz-1 || (sentence[i] >= 32 && sentence[i] <= 64) || (sentence[i] >= '0' && sentence[i] <= '9')){
if(sentence[i] >= 'a' && sentence[i] <= 'z')temp.push_back(sentence[i]-32);
if(sentence[i] >= 'A' && sentence[i] <= 'Z')temp.push_back(sentence[i]);
if(F[temp])cnt++;
temp.clear();
}
else{
if(sentence[i] >= 'a' && sentence[i] <= 'z')temp.push_back(sentence[i]-32);
if(sentence[i] >= 'A' && sentence[i] <= 'Z')temp.push_back(sentence[i]);
}
}
out[sentence] = cnt;
mx.push_back(cnt);
cnt = 0;
}
int L = mx.size();
for(int i = 0; i < L; i++)mxx = max(mxx, mx[i]);
cout << "Excuse Set #" << ++cs << endl;
for(int i = 0; i < k; i++){
if(out[ar[i].str_key] == mxx)cout << ar[i].str_key << endl;
}
cout << endl;
}
return 0;
}
No comments:
Post a Comment