http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=203#problem/D

以前用字典树做过

#include <string.h>
#include <stdio.h>
#include <string>
#include <map>
using namespace std; int main()
{
char a[];
int n,m,sum,l;
while(scanf("%d",&n)!=EOF&&n!=)
{
sum=;
scanf("%d",&m);
map<string,int>q;
q.clear();
for(int i=; i<n; i++)
{
scanf("%s",a);
l=strlen(a);
for(int j=; j<l; j++)
a[j]=tolower(a[j]);//将字符转换成小写字符
q[a]++;
}
while(m--)
{
scanf("%s",a);
l=strlen(a);
for(int i=;i<l;i++)
a[i]=tolower(a[i]);
if(q.count(a)>)
{
sum++;
q.erase(q.find(a));
}
}
printf("%d\n",n-sum); }
return ;
}

第一次做的方法

#include<stdio.h>
#include<iostream>
#include<map>
#include<stdlib.h>
#include<string.h> using namespace std;
char a[][];
int main()
{
int n,m,l;
char b[];
map<string,int>q;
while(scanf("%d",&n)!=EOF&&n!=)
{
q.clear();
scanf("%d",&m);
getchar();
for(int i=;i<n;i++)
{
gets(a[i]);
l=strlen(a[i]);
for(int j=;j<l;j++)
{
if(a[i][j]>='A'&&a[i][j]<='Z')
a[i][j]=a[i][j]+;
}
q[a[i]]++;
}
for(int i=;i<=m;i++)
{
gets(b);
l=strlen(b);
for(int i=;i<l;i++)
{
if(b[i]>='A'&&b[i]<='Z')
b[i]=b[i]+;
}
q[b]--;
}
int sum=;
for(int i=;i<n;i++)
{
if(q[a[i]]>=)
sum++;
}
printf("%d\n",sum);
}
return ;
}

大神的代码

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio> #include <set> using namespace std; int main()
{
int n,m,i,j,len;
char s[];
while(scanf("%d",&n)!=EOF&&n)
{
set<string>mp;//声明set容器
set<string>::iterator it;//声明set迭代器
scanf("%d",&m);
getchar();
for(i=; i<n; i++)
{
gets(s);
len=strlen(s);
for(j=; j<len; j++)
{
s[j]=towlower(s[j]);
}
mp.insert(s);//向set里加入一个元素
}
for(i=; i<m; i++)
{
gets(s);
len=strlen(s);
for(j=; j<len; j++)
{
s[j]=towlower(s[j]);
}
if(mp.count(s))//判断容器里是否存在该元素
mp.erase(s);//如果容器里存在该元素,则删除
}
printf("%d\n",mp.size());//输出容器内剩余元素个数
}
return ;
}

Message Flood(map)的更多相关文章

  1. STL 之map解决 Message Flood(原字典树问题)

                                                                                      Message Flood Time ...

  2. Message Flood

    Message Flood Time Limit: 1500MS Memory limit: 65536K 题目描述 Well, how do you feel about mobile phone? ...

  3. Sicily 1194. Message Flood

    题目地址:1194. Message Flood 思路: 不区分大小写,先全部转化为小写,用stl提供的函数做会很方便. 具体代码如下: #include <iostream> #incl ...

  4. sdut Message Flood(c++ map)

    用字典树没过,学习了一下map; 参考博客:http://blog.csdn.net/zhengnanlee/article/details/8962432 AC代码 #include<iost ...

  5. SDUT1500 Message Flood

    以前做过的用的字典树,可是貌似现在再用超内存....求解释... 问了LYN用的map函数做的,又去小小的学了map函数.... http://wenku.baidu.com/view/0b08cec ...

  6. oj1500(Message Flood)字典树

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

  7. 图层损坏 E/ArcGIS﹕ The map or layer has been destroyed or recycled. 资源未释放

    看到论坛上有个网友和我一样的问题: The map or layer has been destroyed or recyled t Hello, I have a problem when the ...

  8. proto3 中的 map 类型

    .proto syntax = "proto3"; option optimize_for = SPEED; message TestStruct { map<int32,s ...

  9. SDUT 1500-Message Flood(set)

    Message Flood Time Limit: 1500ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述 Well, how do you feel abo ...

随机推荐

  1. Android Studio中R报错(cnanot resolve symbol R)

    我的解决办法: Tools -> Android -> Sync Project with Gradle Files Build -> Clean Project 然后就好了 PS: ...

  2. 【vue基础学习】vue.js开发环境搭建

    1.安装node.js(http://www.runoob.com/nodejs/nodejs-install-setup.html) 2.基于node.js,利用淘宝npm镜像安装相关依赖 在cmd ...

  3. java高级---->Thread之ExecutorService的使用

    今天我们通过实例来学习一下ExecutorService的用法.我徒然学会了抗拒热闹,却还来不及透悟真正的冷清. ExecutorService的简单实例 一.ExecutorService的简单使用 ...

  4. 一劳永逸的搞定 FLEX 布局(转)

    一劳永逸的搞定 flex 布局 寻根溯源话布局 一切都始于这样一个问题:怎样通过 CSS 简单而优雅的实现水平.垂直同时居中.记得刚开始学习 CSS 的时候,看到 float 属性不由得感觉眼前一亮, ...

  5. Kafka+Storm+HDFS 整合示例

    消息通过各种方式进入到Kafka消息中间件,比如可以通过使用Flume来收集日志数据,然后在Kafka中路由暂存,然后再由实时计算程序Storm做实时分析,最后将结果保存在HDFS中,这时我们就需要将 ...

  6. Atom使用插件精选

    小颖之前公司的大哥推荐小颖用的编辑器是atom,之前都是他给小颖了一个atom插件安装列表,小颖电脑出了点问题,所以后来小颖把那弄丢了,小颖重装atom后,就不知道要安装什么插件,所以也百度了很多,今 ...

  7. MFC学习单选框Radio使用

    创建单选框Radio ,ID号IDC_RADIO_NAME 1.获取单选框内容 int RadioState = ((CButton *)GetDlgItem(IDC_RADIO_NAME))-> ...

  8. Android Google Maps API 网络服务用于网络定位、计算路线、获取经纬度、获取详细地址等

    extends:http://blog.csdn.net/h7870181/article/details/12505883 Google Maps API 网络服务 官网地址 : https://d ...

  9. mysql如何使用索引index提升查询效率?

    https://dev.mysql.com/doc/refman/8.0/en/mysql-indexes.html Indexes are used to find rows with specif ...

  10. iOS - WKWebView那些坑

    WKWebView 是苹果在 WWDC 2014 上推出的新一代 webView 组件,用以替代 UIKit 中笨重难用.内存泄漏的 UIWebView.WKWebView 拥有60fps滚动刷新率. ...