Sicily 1194. Message Flood

来源:互联网 发布:linux怎么选中命令复制 编辑:程序博客网 时间:2024/05/22 15:09

注意: 不区分大小写, 所以需要转换成统一小写, 方便比较

另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;}                                 


0 0
原创粉丝点击