SDUT-Message Flood
来源:互联网 发布:zphotoengine 源码 编辑:程序博客网 时间:2024/06/05 05:20
Message Flood
Time Limit: 1500MS Memory Limit: 65536KB
Submit Statistic Discuss
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 message 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 message, 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.
Example Input
5 3InkfishHenryCarpMaxJerichoCarpMaxCarp0
Example Output
3
Hint
应用map容器
Author
第9届中山大学程序设计竞赛预选赛
参考博客
注意:1.map的直接初始化或拷贝初始化 2.需要利用towlower将s中的字符转化为小写字母(因为朋友名单中的姓名不分大小写)
#include <bits/stdc++.h>using namespace std;int main(){ int n,m,i,j; while(cin>>n&&n) { map<string,int>my_map; string s; cin>>m; for(i=0;i<n;i++) { cin>>s; for(j=0;j<s.size();j++) { s[j]=towlower(s[j]); } my_map[s]++; } for(i=0;i<m;i++) { cin>>s; for(j=0;j<s.size();j++) { s[j]=towlower(s[j]); } my_map.erase(s); } cout<<my_map.size()<<endl; } return 0;}
阅读全文
0 0
- sdut 1500 Message Flood
- Message Flood SDUT 1500
- sdut 1500 Message Flood
- SDUT Message Flood
- Message Flood SDUT
- sdut Message Flood
- SDUT-Message Flood
- SDUT 1500-Message Flood(set)
- Message Flood SDUT OJ 1500
- SDUT 1500 Message Flood(字典树 && 模板)
- SDUT 1500 Message Flood (快排+二分查找)
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- OTT安卓电视盒系统发展的3种模式
- Android 组件化 构架
- Centos 6.X 安装php-redis扩展
- Java中ArrayList和LinkedList区别
- 例题1.5 蚂蚁 UVA
- SDUT-Message Flood
- Maven仓库介绍与本地仓库配置
- 腾讯Bugly的使用
- ubuntu16安装mysql图形界面
- LintCode 解题记录17.8.8 字符串处理4
- python 字符串str各种内置方法
- 搭建Cocos2d-JS开发环境
- 原生 JavaScript 和 jQuery 的优劣比较
- 引用类型的交换