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 水题
题意: 水题,就是给你一些单词,和一些按键记录,问打出下面的那些单词,每一个按键记录一共按了多少次. 思路: 直接把每个单词的每一位转换成数字,然后再把每个单词转换的数字 ...
随机推荐
- zabbix docker - 安装和初始化配置
zabbix docker - 安装和初始化配置 安装zabbix server docker-mysql版本 zabbix server支持不同的数据库(详见zabbix的docker hub),这 ...
- Hibernate入门1 - Hibernate概述及第一个小例子
一.什么是ORM? ORM,即Object Relational Mapping.我们知道,利用面向对象的思想编写的数据库应用程序最终都是把对象信息保存在关系型数据库中,于是需要编写与底层数据库相关的 ...
- Java学习笔记45(多线程二:安全问题以及解决原理)
线程安全问题以及解决原理: 多个线程用一个共享数据时候出现安全问题 一个经典案例: 电影院卖票,共有100座位,最多卖100张票,买票方式有多种,网上购买.自主售票机.排队购买 三种方式操作同一个共享 ...
- [CocoaPods]入门
什么是CocoaPods? CocoaPods管理Xcode项目的库依赖项. 项目的依赖项在名为Podfile的单个文本文件中指定.CocoaPods将解析库之间的依赖关系,获取生成的源代码,然后在X ...
- 关于文件命名,你必须要知道的(浏览器报错:net::ERR_BLOCKED_BY_CLIENT)
坑爹的,今天在写完页面,用各个浏览器测试的时候,火狐.谷歌都是正常的,QQ浏览器出幺蛾子了,在使用兼容模式的时候页面正常,使用急速模式的时候部分页面正常,点击跳转到其他页面的时候就出错了,打开控制台一 ...
- Django2.1发布,Django2.1新特性
Django 2.1 现已正式发布,官方表示随着 2.1 的发布,对 2.0 系列的主流支持服务将结束,进入安全修复服务周期,直至2019年4月. 2.1新特性:https://docs.django ...
- 如何用java POI将word中的内容导入到mysql数据库中
由于作业需要,要求我们将word文档中的数据直接导入到mysql中,在网上找了很常时间,终于将其解决. 由于比较初级,所以处理的word文档是那种比较规范的那种,条例比较清晰,设计的思路也比较简单,就 ...
- Git使用教程:最详细、最傻瓜、最浅显、真正手把手教!
Git使用教程:最详细.最傻瓜.最浅显.真正手把手教! 蘇小小 Web项目聚集地 9月16日 作者 | 蘇小小 编辑 | 王久一 来源 | 慕课网 导读:因为教程详细,所以行文有些长,新手边看边操作效 ...
- Linux编程 3 (初识bash shell与man查看手册)
一.初识bash shell 1.1 启动 shell GNU bash shell 能提供对Linux系统的交互式访问.通常是在用户登录终端时启动,登录时系统启动shell依赖于用户账户的配置. ...
- [java初探总结篇]__java初探总结
前言 终于,java初探系列的学习,要告一阶段了,java初探系列在我的计划中是从头学java中的第一个阶段,知识主要涉及java的基础知识,所以在笔记上实在花了不少的功夫.虽然是在第一阶段上面花费了 ...