HDU 4287 Intelligent IME(string,map,stl,make_pair)
//numx[i]=string(sx); //把char[]类型转换成string类型
// mat.insert(make_pair(numx[i],0)); //创造一个(string,int)整体——结构体,插入map
//sx[j]=ch[sx[j]-'a'];//把字母转换成相应的数字
//mat.find(numx[i])->second;//返回位置—— 取map当中num[i]对应的键值
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
using namespace std;
char ch[]={'','','','','','','','','','','','','','','','','','','','','','','','','',''};
string numx[];
map<string,int> mat; //int是用来记录要输出的答案——数量的
int main()
{
int cas,n,m;
char sx[];
scanf("%d",&cas);
for(;cas--;)
{
mat.clear();
scanf("%d%d",&n,&m);
for(int i=;i<n;++i)
{
scanf("%s",sx);
numx[i]=string(sx); //把char[]类型转换成string类型
mat.insert(make_pair(numx[i],)); //创造一个(string,int)整体——结构体,插入map
}
for(int i=;i<m;++i)
{
scanf("%s",sx);
for(int j=;j < strlen(sx);++j)
sx[j]=ch[sx[j]-'a'];//把字母转换成相应的数字
if(mat.count( string(sx) )!=)
(mat.find( string(sx) )->second)++;
}
for(int i=;i<n;++i)
printf("%d\n",mat.find(numx[i])->second);
}
return ;
}
//根据百度来的写的:
//string ch = "22233344455566677778889999";//string下标也从0开始
//mapp[ num[i] ] = 0; //保存这种按法相应的答案——种类数的,键值对应
// int len=sx.length(); //string的长度s.length()
//mapp.count(sx)//返回map当中sx的数目——查找mapp当中是否存在sx这个数字串(键),若sx的数目不等于0,说明存在
//mapp[sx]++;//键sx对应的值增加1
#include<stdio.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
map<string, int > mapp;
string ch = "";//string下标也从0开始
int main()
{
int n,m,t,i;
string num[];
string sx;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(i=;i<n;i++)
{
cin >> num[i];
mapp[ num[i] ] = ; //保存这种按法相应的答案——种类数的
}
for(i=;i<m;i++)
{
cin >> sx;
int len=sx.length(); //string的长度s.length()
for(int j=; j<len; j++)
{
sx[j]=ch[ sx[j]-'a' ];//把字母转换成数字(也是字符型的数字),模拟一下就理解了,string下标从0开始
}
if(mapp.count(sx))//查找mapp当中是否存在sx这个数字串(键),若sx的数目不等于0,说明存在
{
mapp[sx]++;//键sx对应的值数目增加1
}
}
//输出n个健相应的值
for(i=;i<n;i++)
{
printf("%d\n",mapp[num[i]]);
}
}
return ;
}
HDU 4287 Intelligent IME(string,map,stl,make_pair)的更多相关文章
- HDU 4287 Intelligent IME(map运用)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4287 Intellig ...
- HDU 4287 Intelligent IME(字典树数组版)
Intelligent IME Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 4287 Intelligent IME(字典树)
在我没用hash之前,一直TLE,字符串处理时间过长,用了hash之后一直CE,(请看下图)我自从经历我的字典树G++MLE,C++AC以后,一直天真的用C++,后来的CE就是因为这个,G++才支持这 ...
- ACM学习历程—HDU 4287 Intelligent IME(字典树 || map)
Description We all use cell phone today. And we must be familiar with the intelligent English input ...
- HDU 4287 Intelligent IME hash
Intelligent IME Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- HDU 4287 Intelligent IME
Intelligent IME Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- Es6(Symbol,set,map,filter)
首先再讲这几个新东西之前,先说一个Es6中新出的扩展运算符(...) 1.展开运算符,就是把东西展开,可以用在array和object上 比如: let a=[,] let b=[,...a,]//[ ...
- 【转】Java学习---Java核心数据结构(List,Map,Set)使用技巧与优化
[原文]https://www.toutiao.com/i6594587397101453827/ Java核心数据结构(List,Map,Set)使用技巧与优化 JDK提供了一组主要的数据结构实现, ...
- C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法
每次忘记都去查,真难啊 /* C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法 */ /* vector常用用法 */ //头文件 #i ...
随机推荐
- Python学习教程(learning Python)--3.2 if-else分支语句
if-else分支语句结构的特点是当conditon条件满足时,执行if下的语句块,当condition条件不满足时执行else下的语句块,也就是说根据条件来控制让某些语句执行,某些语句不被执行. i ...
- angularjs2 学习笔记(六) Form
Angular 2 Form表单 在angular2 form表单中我们需要了解表单数据绑定.数据验证.数据提交等内容,在下面的示例中并没有实际提交到后台,这部分内容在今后webapi中加以练习. 表 ...
- bhrs报表年结步骤
--前期准备数据三个表数据: s_subjtotal_year, subject_item, branch ,decrsubjtotal---informix 查看数据库剩余空间select d.na ...
- C# DateTime详解
//今天DateTime.Now.Date.ToShortDateString();//昨天,就是今天的日期减一DateTime.Now.AddDays(-1).ToShortDateString() ...
- MVC4.0 解决Controllers与Areas中控制器不能同名问题
在使用MVC4.0的时候,难免会遇到在根目录下的Controllers中添加的控制器名称可能会跟在Areas中的某个区域下的控制器名称一样.这个时候访问Areas下面的Controller/Actio ...
- [SSH服务]——一个SSH无密码登陆实验
实验拓扑图 实验描述 机房内有两台服务器: (1)B服务器10.0.10.158,充当Web服务器,有普通用户user_00 (2)C服务器10.0.10.191,充当Mysql服务器,有普通用户us ...
- SDOI2016 round1滚粗记
Day -1 刚刚从HN集训回来,感觉整个人萌萌哒.考前不断立flag——这次我一定会滚粗的,然后设想着滚粗之后文化课先补什么,浑浑噩噩的过了一天,晚上看到CA爷(娘)发了关于cena爆栈的问题,这时 ...
- IE点击tif,tiff文件,提示打开而不是查找
IE点击tif或者tiff后缀的文件,提示窗口没有显示打开,而是现实查找.而下载到本地后,又能用acdsee之类的软件双击打开.在tif文件右键-属性中选择了打开程序,在IE中还是依然. 搜索网络资料 ...
- BCP command usage in SQL Server
The bcp Command-Line Utility You use the bcp (bulk copy program) tool to address the bulk movement o ...
- Microsoft SQL Server 存储过程举例
-- if SP is existed, drop it. if (object_id('InvHoldToDPS', 'P') is not null) drop proc InvHoldToDPS ...