您的位置:首页 > 其它

Sicily 1194. Message Flood

2015-05-23 17:12 253 查看
注意: 不区分大小写, 所以需要转换成统一小写, 方便比较

另A为联系人集合, B为发送人集合

题意就是求: A - B

// Problem#: 1194
// Author#: Reid Chan

#include <iostream>
#include <cctype>
#include <set>

using namespace std;

void to_low(string &a, string b, int l) {
for (int i = 0; i < l; i++) {
a += tolower(b[i]);
}
}

int main() {
int n, m;
while (cin >> n >> m && n != 0) {
set<string> contacts, senders;
string name;
string ins;
int len;
for (int i = 0; i < n; ++i) {
cin >> name;
ins = "";
len = name.length();
to_low(ins, name, len);
contacts.insert(ins);
}
for (int i = 0; i < m; ++i) {
cin >> name;
ins = "";
len = name.length();
to_low(ins, name, len);
senders.insert(ins);
}
int num = contacts.size();
set<string>::iterator it;
for (it = senders.begin(); it != senders.end(); ++it) {
if (contacts.find(*it) != contacts.end()) {
contacts.erase((*it));
}
}
cout << contacts.size() << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: