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 ...
随机推荐
- 分享我常用的一些JS验证和函数
下面是我常用一些JS验证和函数,有一些验证我直接写到了对象的属性里面了,可以直接通过对象.方法来调用//浮点数除法运算 function fdiv(a, b, n) { if (n == undefi ...
- core java 5~6(OOP & 高级语言特征)
MODULE 5 OOP 面向对象程序设计--------------------------------------------------------Object Oriented Program ...
- windows phone版的一个儿教app
昨天下午看见一个园友写的一篇关于儿教的api,看了也就两三个接口,所以数据处理应该不会太复杂,主要是界面的效果,要求可能比较高.于是我就重新自己写了一个app,实现很简单,花的时间比较多的地方应该是在 ...
- JavaScript高级程序设计之数值数组排序
如果数组中全是Nunber类型,则可以按照数值大小排序 , , , , ]; // asc升序函数 function compareAsc(value1, value2) { if (value1 & ...
- IOS内存管理「1」- 引用计数
- Android编程: 调试方法
学习知识:Android的调试方法 ====调试方法==== 前提: IDE环境为Android Studio,熟悉LogCat,知道如何查看日志信息 工具: Android DDMS调试工具,一般点 ...
- iOS UIView的简单渐变效果
这里主要用到了ios4.0以后 UIView的类方法 animateWithDuration: 函数原型包括以下类方法 + (void)animateWithDuration:(NSTimeInter ...
- Cocos2dx中利用双向链表实现无限循环滚动层
[Qboy原创] 在Cocos2dX 3.0 中已经实现一些牛逼的滚动层,但是对于有一些需要实现循环滚动的要求确没有实现,笔者在前段时间的一个做了一个游戏,需求是实现在少有的(13个)英雄中进行循环滚 ...
- ios-UIWebView中js和oc代码的互调
webview是ios中显示远程数据的网页控件,webview能显示的内容很多,MP4.文本.pdf等等: 关于js和oc代码的互相调用 1:oc中调用js代码; >>oc中调用js代码很 ...
- 一些常用到的Centos命令
CentOS常用命令在我们的使用中,经常被使用.所以,我们对一些经常使用又很重要的CentOS常用命令进行了全面的整理.下面,就来介绍这些CentOS常用命令. 一:使用CentOS常用命令查看cpu ...