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 水题
题意: 水题,就是给你一些单词,和一些按键记录,问打出下面的那些单词,每一个按键记录一共按了多少次. 思路: 直接把每个单词的每一位转换成数字,然后再把每个单词转换的数字 ...
随机推荐
- Centos7中docker开启远程访问
在作为docker远程服务的centos7机器中配置: 1.在/usr/lib/systemd/system/docker.service,配置远程访问.主要是在[Service]这个部分,加上下面两 ...
- RunC容器逃逸漏洞席卷业界,网易云如何做到实力修复?
近日,业界爆出的runC容器越权逃逸漏洞CVE-2019-5736,席卷了整个基于runC的容器云领域,大量云计算厂商和采用容器云的企业受到影响.网易云方面透露,经过技术团队的紧急应对,网易云上的容器 ...
- SpringDataSolr 过滤(或者叫筛选)查询
// 被本类调用 private Map searchList(Map searchMap) { // 1.1关键字查询 SimpleHighlightQuery highlightQuery = n ...
- HTTP 总结
一.概念 特性 1. HTTP协议用于客户端和服务端之间的通信 2. 通过请求和响应的交互达成通信 : HTTP协议规定,请求从客户端发出,最后服务器端响应请求并返回,也就是说,肯定是从客户端开始建立 ...
- JavaScript实现页面显示倒计时功能
下面是用JS中的日期函数和定时器完成的一个倒计时的例子,效果如图: 代码如下: <!DOCTYPE html> <html> <head> <title> ...
- Android Fragment用法知识点的讲解
Android Fragment用法的讲解 碎片,它的出现是为了更好展示UI的设计,让程序更加得到充分的展示.Fragment的出现,如微信的额主界面包含多个Fragment,使得微信功能更加简洁明了 ...
- Swift5 语言指南(十一) 结构和类
结构和类是通用的,灵活的结构,它们成为程序代码的构建块.您可以使用与定义常量,变量和函数相同的语法来定义属性和方法,以便为结构和类添加功能. 与其他编程语言不同,Swift不要求您为自定义结构和类创建 ...
- 基数排序的理解和实现(Java)
基数排序是桶排序的扩展算法,其思想是:将整数按位数切割成不同的数字,然后按每个位数分别比较排序. 算法流程: 将所有待比较数值统一为同样的数位长度,数位较短的数前面补零. 从最低位开始,依次进行一次排 ...
- shell脚本中一些特殊变量
在shell脚本中,一些常见的特殊变量表示方式还是需要知道的 如下就是一些经常用到的特殊变量表示方法: $0 当前脚本名$1 $2... 传入脚本or函数的参数(大于10需大括号括起来)$ ...
- linux日常运维常用命令
---查看端口占用 netstat -ap | grep 8000 ---重启nginx sudo /usr/sbin/nginx -c /usr/local/nginx/conf/nginx.con ...