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
 Copy sample input to clipboard
5 3
Inkfish
Henry
Carp
Max
Jericho
Carp
Max
Carp
0
Sample Output
3

这道题有一个特点是,重复的名字也算同一个,所以用set再合适不过了。
第一次使用set库呢,有好多函数都要记得。
// Problem#: 1194
// Submission#: 4948878
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main()
{string str;int m,n;while(cin>>n&&n){set<string> myset;cin>>m;for(int i=0;i<n;i++){cin>>str;for(int j=0;j<str.length();j++)str[j]=tolower(str[j]);//将输入的字符大写转小写。使用的是函数tolower()。
            myset.insert(str);//插入转为小写的str}for(int i=0;i<m;i++){cin>>str;for(int j=0;j<str.length();j++)//注意这里字符串长度要使用str.length()而不是.size().str[j]=tolower(str[j]);set<string>::iterator itor=myset.find(str);//这里使用stl中的迭代器,大概就是指针find用来定位str在myset里的位置。if(itor!=myset.end())//如果myset里有这个str,就把该str删掉。myset.erase(str);}cout<<myset.size()<<endl;//最后输出myset的大小即可,(重复的都已被删掉)}return 0;
}

1194 . Message Flood相关推荐

  1. sdut 1500 Message Flood

    一道简单的Trie树,好长时间没写过了,手生了,wA了好几次... Message Flood Time Limit:1500MS  Memory Limit:65536K Total Submit: ...

  2. Message Flood

    题目描述 Well, how do you feel about mobile phone? Your answer would probably be something like that &qu ...

  3. oj1500(Message Flood)字典树

    大意:输入几个字符串,然后再输入几个字符串,看第一次输入的字符串有多少没有在后面的字符串中出现(后输入的字符串不一定出现在之前的字符串中) #include <stdio.h> #incl ...

  4. sdut 1500 Message Flood(Trie树)

    题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1500 View Code 1 #incl ...

  5. Soj题目分类 python代码)

    正值期末复习,刷点soj放松下 但想看看能不能在找点关于数据结构的题目来做一下. 在网上看到有不少人上传过那些关于部分SOJ题目的描述,但是说实话有些乱 不过我看到有个网页中包含的一个类似文档的东西, ...

  6. 初学者acm的练习题指南

    上机练习题参考题 忘了在哪找的啦~~希望对大家有帮助呦 <!--[if !supportLists]-->1.    <!--[endif]-->Programming Bas ...

  7. sicily题目分类

    sicily题目分类 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. ...

  8. [sicily]部分题目分类

    sicily题目分类 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 11. ...

  9. Sicily 题目分类

    依照自己水平挑着做→ →~~ 1. 编程入门 2. 数据结构 3. 字符串 4. 排序 5. 图遍历 6. 图算法 7. 搜索:剪枝,启发式搜索 8. 动态规划/递推 9. 分治/递归 10. 贪心 ...

最新文章

  1. 没有 5G 版 iPhone 的苹果秋季发布会,发布了些什么?
  2. 定制Eclipse IDE之插件篇(一)
  3. (转)flask的context机制
  4. 4. Nest :module (Model)
  5. js img图片加载失败,重新加载+断网检查
  6. asp.net core根据用户权限控制页面元素的显示
  7. Spring Boot 笔记汇总
  8. python中str如何使用_python中str函数的使用方法
  9. JSP技术-02-内置对象/作用域/EL表达式/JSTL标签库
  10. 【Java】转义字符
  11. 关于SIM900A模块的学习心得
  12. CSS多列等高如何实现?
  13. 廊坊金彩教育:如何提高店铺评分
  14. 浅谈对js闭包的理解
  15. 关于js中e = e || window.event
  16. ndnSIM学习(四)——examples之ndn-simple.cpp超详细剖析
  17. chrome运行 Android,告诉你如何在Chrome上运行Android应用!
  18. 孤立波matlab,色散方程的两个八点差分格式
  19. linux设置user1的密码为,linux下passwd用户设置与修改密码
  20. 率土之滨服务器进备战区维护多久,率土之滨备战区维护,备战区为什么不拆战法...

热门文章

  1. linux程序打印cr3寄存器,CR0,CR3寄存器
  2. Python_BeautifulSoup4爬虫应用案例
  3. c语言七巧板编程实验报告,智力七巧板社团活动记录表
  4. pgsql 设置用户权限
  5. Python—linux基础
  6. 基于微信小程序的电影院票务系统设计与实现-计算机毕业设计源码+LW文档
  7. 谈谈NITE 2的第一个程序HandViewer
  8. 【HDU】1283 最简单的计算机
  9. 小程序流量全面爆发,谁会湾道超车
  10. Maven上传jar包到本地仓库