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 水题
题意: 水题,就是给你一些单词,和一些按键记录,问打出下面的那些单词,每一个按键记录一共按了多少次. 思路: 直接把每个单词的每一位转换成数字,然后再把每个单词转换的数字 ...
随机推荐
- Vuejs——(8)Vuejs组件的定义
版权声明:出处http://blog.csdn.net/qq20004604 目录(?)[+] 本篇资料来于官方文档: http://cn.vuejs.org/guide/components ...
- nginx并发模型与traffic_server并发模型简单比较
ginx并发模型: nginx 的进程模型采用的是prefork方式,预先分配的worker子进程数量由配置文件指定,默认为1,不超过1024.master主进程创建监听套接口,fork子进程以后,由 ...
- Thinking in Java from Chapter 21
From Thinking in Java 4th Edition 并发 线程可以驱动任务,因此你需要一种描述任务的方式,这可由Runnable接口来提供. 要想定义任务,只需要实现Runnable接 ...
- SharkApktool 源码攻略
作者:HAI_ 原文来自:https://bbs.ichunqiu.com/thread-43219-1-1.html 0×00 前言 网上的资料对于apktool的源码分析,来来回回就那么几个,而且 ...
- JavaScript实现页面显示倒计时功能
下面是用JS中的日期函数和定时器完成的一个倒计时的例子,效果如图: 代码如下: <!DOCTYPE html> <html> <head> <title> ...
- Python+Excel+Unittest+HTMLTestRunner实现数据驱动接口自动化测试(二)
因为小白,这2天研究了好久才算是搞好.先附上一个测试完成后邮件的截图: 上一篇有提到: unittest中实际运行了一个接口的很多条用例,而报告中只会有一条记录.这是因为unittest test c ...
- Spring Boot 1.5.10 发布:修复重要安全漏洞!!!
2018/01/31,Spring Boot团队发布了Spring Boot 1.5.10. Maven: <parent> <groupId>org.springframew ...
- Spring Caching集成Ehcache
Ehcache可以对页面.对象.数据进行缓存,同时支持集群/分布式缓存.在应用中用于常常需要读取的数据交换,而不是通过DB DAO数据交换(cache不占用DB宝贵的NIO,直接交换堆内存). 整合S ...
- Python九九乘法表三种方案
方法一: row = 1 # 定义起始行 while row <= 9: # 最大打印 9 行 col = 1 # 定义起始列 while col <= row: # 最大打印 row 列 ...
- springboot创建统一异常拦截器全局处理 异常
1.创建Exception类 public class MyException extends RuntimeException { private ErrorCodeEnum errorCode; ...