Intelligent IME

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=4287

Description

We all use cell phone today. And we must be familiar with the intelligent English input method on the cell phone. To be specific, the number buttons may correspond to some English letters respectively, as shown below:
  2 : a, b, c 3 : d, e, f 4 : g, h, i 5 : j, k, l 6 : m, n, o
  7 : p, q, r, s 8 : t, u, v 9 : w, x, y, z
  When we want to input the word “wing”, we press the button 9, 4, 6, 4, then the input method will choose from an embedded dictionary, all words matching the input number sequence, such as “wing”, “whoi”, “zhog”. Here comes our question, given a dictionary, how many words in it match some input number sequences?

Input

  First is an integer T, indicating the number of test cases. Then T block follows, each of which is formatted like this:
  Two integer N (1 <= N <= 5000), M (1 <= M <= 5000), indicating the number of input number sequences and the number of words in the dictionary, respectively. Then comes N lines, each line contains a number sequence, consisting of no more than 6 digits. Then comes M lines, each line contains a letter string, consisting of no more than 6 lower letters. It is guaranteed that there are neither duplicated number sequences nor duplicated words.

Output

For each input block, output N integers, indicating how many words in the dictionary match the corresponding number sequence, each integer per line.

Sample Input

1
3 5
46
64448
74
go
in
night
might
gn

Sample Output

3
2
0

HINT

题意

用9宫格敲了N次,给m个字符串,问你每次敲击,能够敲出多少个单词

题解:

hash或者map搞一搞

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=;
#define mod 1000000009
#define eps 1e-7
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** //2 : a, b, c 3 : d, e, f 4 : g, h, i 5 : j, k, l 6 : m, n, o
//7 : p, q, r, s 8 : t, u, v 9 : w, x, y, z
map<int,int> HH;
string s[];
map<string,int> H;
int ans[];
int main()
{
int k=;
for(int i=;i<=;i++)
{
if(i==||i==||i==||i==||i==||i==||i==)
k++;
HH[i]=k;
}
int t=read();
while(t--)
{
H.clear();
memset(ans,,sizeof(ans));
int n=read(),m=read();
for(int i=;i<n;i++)
cin>>s[i];
string s1;
for(int i=;i<m;i++)
{
cin>>s1;
for(int j=;j<s1.size();j++)
s1[j]=char(HH[(s1[j]-'a')]+'');
H[s1]++;
}
for(int i=;i<n;i++)
printf("%d\n",H[s[i]]);
}
}

最新文章

  1. 功能强大而又简单易学的编程语言Python
  2. Ubuntu FTP 配置
  3. Annotation注解(有源代码)
  4. 封印术:shadow dom
  5. 如何从Windows Phone 生成PDF文档
  6. 批处理,修改环境变量path的方法(加环境变量)
  7. chapter 14_1 环境
  8. 第3章 Java语言基础----成员变量与局部变量
  9. MySQL索引和查询优化
  10. JS日历插件 - My97 DatePicker用法详解
  11. JS(JavaScript)的进一步了解3(更新中&#183;&#183;&#183;)
  12. 如何卸载VMware虚拟机?
  13. Unity AssetBoundle 打包流程
  14. 详解Oracle数据字典
  15. 岭回归和Lasso回归以及norm1和norm2
  16. java命令行执行程序解决依赖外部jar包的问题
  17. Winfrom 实现转圈等待
  18. ZeroMQ API(二) 上下文
  19. CH5201 数组组合【01背包】
  20. iOS开发进阶 - 基于PhotoKit的图片选择器

热门文章

  1. python内建函数sorted方法概述
  2. 在mac上搭建python环境
  3. AS3垃圾回收整理
  4. deep learning 的java库
  5. nova service-list
  6. mysql基础知识(5)--视图
  7. JavaScript 继承方式详解
  8. 详解Android定位
  9. MFC消息响应机制 q
  10. 关于JPA封装数据库数据到实体不调用属性的get和set的方法解决办法