题目:Intelligent IME

Problem 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

题解:按照手机九键拼音的方式分别输出数字组成的字符串分别有几个。

代码如下:

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<fstream>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<iomanip>
#include<vector>
using namespace std;
int num[5005];
char ss[5005][8];
int num1[5005];
int sum[5005]={0};
int main()
{int k;cin>>k;while(k--){int n,m;cin>>n>>m;for(int i=1;i<=n;i++){cin>>num[i];}for(int j=1;j<=m;j++){scanf("%s",ss[j]);}/*for(int i=1;i<=n;i++){cout<<num[i]<<"  ";}for(int j=1;j<=m;j++){cout<<ss[j]<<"  ";}*/int t=0;char ssi[8];for(int j=1;j<=m;j++){t=0;memset(ssi,'\0',sizeof(ssi));int lens=strlen(ss[j]);for(int k=0;k<lens;k++){switch(ss[j][k]){case 'a':case 'b':case 'c': ssi[t++]='2';break;case 'd':case 'e':case 'f':ssi[t++]='3';break;case 'g':case 'h':case 'i':ssi[t++]='4';break;case 'j':case 'k':case 'l':ssi[t++]='5';break;case 'm':case 'n':case 'o':ssi[t++]='6';break;case 'p':case 'q':case 'r':case 's':ssi[t++]='7';break;case 't':case 'u':case 'v':ssi[t++]='8';break;case 'w':case 'x':case 'y':case 'z':ssi[t++]='9';break;}}//cout<<ssi<<endl;num1[j]=atoi(ssi);//cout<<num1[j]<<endl;//cout<<endl<<endl;}for(int j=1;j<=m;j++){for(int i=1;i<=n;i++){if(num1[j]==num[i]){sum[i]++;break;} }}for(int i=1;i<=n;i++){cout<<sum[i]<<endl;}    }return 0;
}

HDU-4287 Intelligent IME相关推荐

  1. HDU -4287 Intelligent IME 字典树数组模拟

    We all use cell phone today. And we must be familiar with the intelligent English input method on th ...

  2. hdu 4287 sdnu 1119 Intelligent IME

    原题链接: hdu: http://acm.hdu.edu.cn/showproblem.php?pid=4287 sdnu: http://210.44.14.31/problem/show/111 ...

  3. HDU4287 Intelligent IME(Trie树,map)

    Problem Description We all use cell phone today. And we must be familiar with the intelligent Englis ...

  4. dd实现Linux转移,linux命令-dd {拷贝并替换}

    一 命令解释: dd:用指定大小的块拷贝一个文件,并在拷贝的同时进行指定的转换. 注意:指定数字的地方若以下列字符结尾,则乘以相应的数字:b=512:c=1:k=1024:w=2 参数注释: if=文 ...

  5. 字典树,01字典树,可持续化01字典树(总结+例题)

    目录 字典树 01字典树 字典树例题: power oj 2390: 查单词 HDU 1671 Phone List HDU 1004Let the Balloon Rise HDU 1075 Wha ...

  6. wince 6中硬键盘 输入法解决

    在一个项目中,我遇到了9宫格的键盘问题:wince下的keyboard的构架是native 方式,往 系统发送的是数字按键,要在wince上实现汉字或字母,就需要一个输入法来解析! 好在T9就是这样设 ...

  7. 输入法(IME)实现原理

    缘起 在windows下使用的sougou输入法,除了经常弹出广告,没有什么异常行为,Linux下的中文输入法似乎没那么强大好用了.起初用的是Ibus中的pinyin,后来因为机缘巧合装了yong输入 ...

  8. HDU 4775 Infinite Go 并查集

    题目链接:Infinite Go Infinite Go Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  9. HDU——1106排序(istringstream的使用、STLvector练习)

    排序 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submiss ...

最新文章

  1. python 中的下划线
  2. 十一、递归----迷宫问题
  3. Android开发学习笔记:数据存取之SQLite浅析
  4. 微信拦截URL,使用自己内置的web组件打开URL,为什么没人声讨?
  5. mfc连接ubuntu mysql数据库_Ubuntu 16.04 Linux系统下使用C++连接mysql数据库
  6. oracle+字段+virtual,Oracle 11g新特性之--虚拟列(Virtual Column)
  7. 驱动程序操作IO口API函数
  8. python自动化_python自动化测试-Behave框架的用法介绍 - python测试学习
  9. html css表格样式模板_HTML amp; CSS 基础入门【4】列表及其样式
  10. Unity3D 热更新方案(集合各位专家的汇总)
  11. 函数的参数,参数为数组
  12. 《计算机网络》-- 第一章 概述
  13. 浩瀚科技PDA移动开单|盘点机 数据采集器 条码扫描开单微POS软件 现场打印开单...
  14. 安卓原生系统开发与逆向工程
  15. 第九章 SQL Server的简单应用
  16. Xcode修改项目名称
  17. POJ 2752 既是前缀又是后缀
  18. html+css+js适合前端小白的实战全解(超详细)——2048小游戏(二)
  19. 使用 T-SQL 语句完成数据库的创建、编辑、修改及删除
  20. Android 解决 adapter.notifyDataSetChanged() 不起作用

热门文章

  1. 四 、Redis 集群的搭建
  2. vue-pdf 在线预览pdf(pdf地址或base64pdf)解决电子签章显示问题
  3. Arnold 渲染设置 - Main - Textures 纹理
  4. 抖音账号矩阵系统源码/技术开发搭建私有化部署开源
  5. 怒飞垂云视频教程 四、建立软件仿真环境
  6. 谈网络攻击:克里姆林宫暗讽美“泼脏水”
  7. 75万的青岛CMMI认证补贴政策介绍
  8. Linux查看CPU,硬盘型号和端口占用等常用命令
  9. 关于技术书籍,我是这么来选书和看书的
  10. QT时间相关的使用(日期相减问题)