Sicily 1194 Message Flood

来源:互联网 发布:d3.js拓扑图教程 编辑:程序博客网 时间:2024/05/22 16:45

题目地址: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;}


0 0
原创粉丝点击