HDU4287
Intelligent IME
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5319 Accepted Submission(s): 2498
Problem Description
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
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
Sample Input
3 5
46
64448
74
go
in
night
might
gn
Sample Output
2
0
Source
//2017-09-29
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; const int N = ; int arr[N];
int book[];
char str[]; int change(char ch){
if('a' <= ch && ch <= 'c')return ;
if('d' <= ch && ch <= 'f')return ;
if('g' <= ch && ch <= 'i')return ;
if('j' <= ch && ch <= 'l')return ;
if('m' <= ch && ch <= 'o')return ;
if('p' <= ch && ch <= 's')return ;
if('t' <= ch && ch <= 'v')return ;
if('w' <= ch && ch <= 'z')return ;
} int main()
{
int T, n, m;
scanf("%d", &T);
while(T--){
scanf("%d%d", &n, &m);
for(int i = ; i < n; i++){
scanf("%d", &arr[i]);
book[arr[i]] = ;
}
for(int i = ; i < m; i++){
scanf("%s", str);
int tmp = ;
for(int j = ; str[j] != '\0'; j++){
tmp *= ;
tmp += change(str[j]);
}
//printf("%s -> %d\n", str, tmp);
book[tmp]++;
}
for(int i = ; i < n; i++){
printf("%d\n", book[arr[i]]);
}
} return ;
}
HDU4287的更多相关文章
- hdu4287 字典树
#include<stdio.h> #include<string.h> #include<stdlib.h> #define maxn 10 struct tri ...
- hdu4287 水题
题意: 水题,就是给你一些单词,和一些按键记录,问打出下面的那些单词,每一个按键记录一共按了多少次. 思路: 直接把每个单词的每一位转换成数字,然后再把每个单词转换的数字 ...
随机推荐
- 初识Twisted(一)
pip install Twisted 安装Twisted库 from twisted.internet import reactor #开启事件循环 #不是简单的循环 #不会带来任何性能损失 rea ...
- Mac 下 Java 多版本切换
Step 1: 安装 jdk1.7 jdk1.8 路径如下: + /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk + /Library/Java/J ...
- 【论文学习】YOLO9000: Better,Faster,Stronger(YOLO9000:更好,更快,更强)
原文下载:https://arxiv.org/pdf/1612.08242v1.pdf 工程代码:http://pjreddie.com/darknet/yolo/ 目录 目录 摘要 简介 BETTE ...
- 二叉搜索树的平衡--AVL树和树的旋转
二叉搜索树只有保持平衡时其查找效率才会高. 要保持二叉搜索树的平衡不是一件易事.不过还是有一些非常经典的办法可以做到,其中最好的方法就是将二叉搜索树实现为AVL树. AVL树得名于它的发明者 G.M. ...
- 背水一战 Windows 10 (66) - 控件(WebView): 监听和处理 WebView 的事件
[源码下载] 背水一战 Windows 10 (66) - 控件(WebView): 监听和处理 WebView 的事件 作者:webabcd 介绍背水一战 Windows 10 之 控件(WebVi ...
- AJAX从入门到放弃(一)
AJAX可以用于创建快速动态的网页(无需重新加载整个网页的情况下,能够更新部分网页的技术) 即异步的Javascript和XML,通过后台与服务器进行少量数据交换,AJAX可以使网页实现异步更新. A ...
- SharkApktool 源码攻略
作者:HAI_ 原文来自:https://bbs.ichunqiu.com/thread-43219-1-1.html 0×00 前言 网上的资料对于apktool的源码分析,来来回回就那么几个,而且 ...
- Tomcat 部署 Web 项目的本质理解
手动创建Web项目 不借助集成开发工具IDE,直接手动创建一个Web项目,有助于理解Web项目的本质. 1.首先建立一个myweb文件夹(自己定义项目名). 2.然后可以建一个html文件(文件里面只 ...
- 和嗲妹妹面试python,是种什么体验?
这次给大家讲讲我2年前去爱奇艺面试高级运维开发岗位的经历,希望对大家带来一些帮助. 公众号「Python专栏」后台回复:自动化运维平台,获取整套自动化运维平台的源代码 聊骚阶段 嗲妹妹:你好,我是爱奇 ...
- python(leetcode)-136只出现一次的数字
给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次.找出那个只出现了一次的元素. 说明: 你的算法应该具有线性时间复杂度. 你可以不使用额外空间来实现吗? 示例 1: 输入: [ ...