[sicily online]1194. Message Flood

來源:互聯網
上載者:User
/*大小寫不區分,沒看到,提交了好幾次我的map,感覺set應該更好ConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionWell, 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.InputThere 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. OutputFor each case, print one integer in one line which indicates the number of left friends he must send. Sample Input5 3InkfishHenryCarpMaxJerichoCarpMaxCarp0Sample Output3*/#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;}}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.