題目地址:http://soj.me/1194
題目說名字是不區分大小寫的,用map數據結構記錄那個人有沒有發短信給他,然後就可以很快搞定
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
int a, b;
while (cin >> a) {
if (!a)
break;
cin >> b;
string name[20001];
for (int i = 0; i < a; i++) {
string temp;
cin >> temp;
for (int j = 0; j < temp.length(); j++)
temp[j] = tolower(temp[j]);
name[i] = temp;
}
map<string, bool> nm;
for (int i = 0; i < b; i++) {
string temp;
cin >> temp;
for (int j = 0; j < temp.length(); j++)
temp[j] = tolower(temp[j]);
nm[temp] = true;
}
int count = 0;
for (int i = 0; i < a; i++)
if (!nm[name[i]])
count++;
cout << count << endl;
}
return 0;
}