/*
大小写不区分,没看到,提交了好几次
我的map,感觉set应该更好
Constraints
Time Limit: 1 secs, Memory Limit: 32 MB
Description
Well, how do you feel about mobile phone? Your answer would probably be something like that “It’s so convenient and benefits people a lot”. However, if you ask Merlin this question on the New Year’s Eve, he will definitely answer “What a trouble! I have to keep my fingers moving on the phone the whole night, because I have so many greeting messages to send! ”. Yes, Merlin has such a long name list of his friends, and he would like to send a greeting message to each of them. What’s worse, Merlin has another long name list of senders that have sent message to him, and he doesn’t want to send another message to bother them (Merlin is so polite that he always replies each message he receives immediately). So, before he begins to send messages, he needs to figure to how many friends are left to be sent. Please write a program to help him.
Here is something that you should note. First, Merlin’s friend list is not ordered, and each name is alphabetic strings and case insensitive. These names are guaranteed to be not duplicated. Second, some senders may send more than one message to Merlin, therefore the sender list may be duplicated. Third, Merlin is known by so many people, that’s why some message senders are even not included in his friend list.
Input
There are multiple test cases. In each case, at the first line there are two numbers n and m (1<=n, m<=20000), which is the number of friends and the number of messages he has received. And then there are n lines of alphabetic strings (the length of each will be less than 10), indicating the names of Merlin’s friends, one per line. After that there are m lines of alphabetic strings, which are the names of message senders.
The input is terminated by n=0.
Output
For each case, print one integer in one line which indicates the number of left friends he must send.
Sample Input
5 3
Inkfish
Henry
Carp
Max
Jericho
Carp
Max
Carp
0
Sample Output
3
*/
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<cmath>
#include<iomanip>
#include<list>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <stack>
#include<queue>
#include<string.h>
#include<set>
using namespace std;
int main()
{
int n,m;
while(cin>>n&&n!=0)
{
cin>>m;
map<string,bool> data;
for(int i=0;i<n;i++)
{
string tmp;
cin>>tmp;
for(int j=0;j<tmp.length();j++)
tmp[j]=tolower(tmp[j]);
data[tmp]=false;
}
map<string,bool>::iterator ite;
for(int i=0;i<m;i++)
{
string tmp;
cin>>tmp;
for(int j=0;j<tmp.length();j++)
tmp[j]=tolower(tmp[j]);
ite=data.find(tmp);
if(ite!=data.end())
ite->second=true;
}
int num=0;
for(ite=data.begin();ite!=data.end();ite++)
{
if(ite->second==false)
num++;
}
cout<<num<<endl;
}
}
[sicily online]1194. Message Flood
最新推荐文章于 2017-05-24 11:20:43 发布
文章讲述了梅林在新年收到大量祝福信息后,需要发送给朋友的问题。梅林的朋友名单长且不按顺序排列,同时部分发信者可能不在朋友名单中。文章提供了一个解决方案来帮助梅林计算需要发送信息给多少未被发送过信息的朋友。
摘要由CSDN通过智能技术生成