Message Flood

来源:互联网 发布:知乎 可怕的事 编辑:程序博客网 时间:2024/05/16 00:45

Message Flood

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 48   Accepted Submission(s) : 12

Font: Times New Roman | Verdana | Georgia

Font Size:  

Problem 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.cases end with 0 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 Carp0 0

Sample Output

3
#include<iostream>#include<stdio.h>#include<string.h>#include<string>#include<map>using namespace std;void f1(char *name){    int len ,i;    len=strlen(name);    for(i=0;i<len;i++)if(name[i]>='A'&&name[i]<='Z')     name[i]+=32;}int main(){    map<string,int>v;        map<string,int>::iterator it;    int num,n,m;    char name[20];    while(scanf("%d %d",&n,&m)!=EOF&&n+m)    {   v.clear();        num=0;        while(n--)        {            scanf("%s",name);            f1(name);            v[name]++;        }        while(m--)        {            scanf("%s",name);            f1(name);            v[name]+=2;        }        for(it=v.begin();it!=v.end();it++)           if(it->second==1)           num++;        printf("%d\n",num);    }    return 0;}