[Sicily online] 1194. Message flood

Source: Internet
Author: User
/* Case insensitive. I didn't see it. I submitted my map several times and felt that set should be better. constraintstime limit: 1 secs, memory limit: 32 mbdescriptionwell, how do you feel about mobile phone? Your answer wowould 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 far too greeting messages to send! ". Yes, Merlin has such a long name list of his friends, and he wowould 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 has es immediately ). so, before he begins to send messages, he needs t O figure to how many friends are left to be sent. please write a program to help him. here is something that you shoshould 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 I S known by so many people, that's why some message senders are even not supported ded 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 encoded ed. and then there are n lines of alphabetic strings (the length of each will be less than 10), indicating the Na MES 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 ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.