您的位置:首页 > 其它

Sicily 1194 Message Flood

2014-03-05 16:45 274 查看
题目地址: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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: