HDU - 7125 Master of Shuangpin
1 second
256 megabytes
standard input
standard output
As you know, there are three kinds of Chinese input methods commonly used: Wubi, Pinyin and Shuangpin. With Shuangpin, you can type any Chinese word by pressing keys only twice.
[h]
| Pinyin | Sequence | Pinyin | Sequence |
| q, iu | q | f, en | f |
| w, ei | w | g, eng | g |
| e | e | h, ang | h |
| r, uan | r | j, an | j |
| t, ue | t | k, uai, ing | k |
| y, un | y | l, uang, iang | l |
| u, sh | u | z, ou | z |
| i, ch | i | x, ia, ua | x |
| o, uo | o | c, ao | c |
| p, ie | p | v, zh, ui | v |
| a | a | b, in | b |
| s, ong, iong | s | n, iao | n |
| d, ai | d | m, ian | m |
Attention that:
- For pinyin of length 1, you should repeat it in order to meet the conditions.
- For those of length 2, just output the original pinyin.
- For pinyin such as ang, you should press the first character of it and then look up this whole pinyin in the table for the second key.
- For simplification, there is no character v in any input. We believe that you, a Pinyin master, can tell u and v in any situations such as lve and que, so we do not challenge you here.
OK, now you are already a MASTER of Shuangpin! Please output the keys sequence to type the given sentences. For example, "ni hao shi jie" will be "ni hc ui jp".
There are multiple test cases. Each line contains one.
Each line is a sequence of pinyin separated by spaces.
It is guaranteed that the number of test case is no more than 1000, the number of pinyin in one test case is no more than 500, and the number of pinyin in all the test cases is no more than 5000.
The keys sequence separated by spaces.
rua
ni xian qi po lan
rang wo men dang qi shuang jiang
cha na zhua zhu le wei lai
zhe ti mian shen me wan yi
rx
ni xm qi po lj
rh wo mf dh qi ul jl
ia na vx vu le ww ld
ve ti mm uf me wj yi
ni you ben shi na lai mai a
wo e le wo men chi shen me
ang yang de dou zhi
ni yz bf ui na ld md aa
wo ee le wo mf ii uf me
ah yh de dz vi
代码实现:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<unordered_map>
using namespace std;
#define int long long
unordered_map<string,char>mp;
void init(){
mp["iu"]='q',mp["ei"]='w',mp["uan"]='r',mp["ue"]='t',mp["un"]='y',mp["sh"]='u',mp["ch"]='i';
mp["uo"]='o',mp["ie"]='p',mp["ong"]='s',mp["iong"]='s',mp["ai"]='d',mp["en"]='f',mp["eng"]='g';
mp["ang"]='h',mp["an"]='j',mp["uai"]='k',mp["ing"]='k',mp["uang"]='l',mp["iang"]='l',mp["ou"]='z';
mp["ia"]='x',mp["ua"]='x',mp["ao"]='c',mp["zh"]='v',mp["ui"]='v',mp["in"]='b',mp["iao"]='n',mp["ian"]='m';
char c='a';
for(int i=0;i<26;i++){
string s="";
s+=c;
mp[s]=c;
c=c+1;
}
}
signed main(){
string s;
init();
while(cin>>s){
if(s.size()==1)cout<<s<<s;
else if(s.size()==2)cout<<s;
else{
if(mp.find(s)!=mp.end())cout<<s[0]<<mp[s];
else{
for(int i=1;i<s.size();i++){
string s1=s.substr(0,i);
string s2=s.substr(i);
if(mp.find(s1)!=mp.end()&&mp.find(s2)!=mp.end()){
cout<<mp[s1]<<mp[s2];
}
}
}
}
char c=getchar();
cout<<c;
}
return 0;
}
HDU - 7125 Master of Shuangpin的更多相关文章
- HDU 6273.Master of GCD-差分数组 (2017中国大学生程序设计竞赛-杭州站-重现赛(感谢浙江理工))
Super-palindrome 题面地址:http://acm.hdu.edu.cn/downloads/CCPC2018-Hangzhou-ProblemSet.pdf 这道题是差分数组的题目,线 ...
- 算法学习分析-点分治 HDU 6269 Master of Subgraph
首先给出定义 点分治是一种处理树上路径的工具 挂出一道题目来:Master of Subgraph 这道题目让你求所有联通子图加和所能产生数字,问你1到m之间,那些数字可以被产生 这道题目,假如我们利 ...
- HDU 6271 Master of Connected Component(2017 CCPC 杭州 H题,树分块 + 并查集的撤销)
题目链接 2017 CCPC Hangzhou Problem H 思路:对树进行分块.把第一棵树分成$\sqrt{n}$块,第二棵树也分成$\sqrt{n}$块. 分块的时候满足每个块是一个 ...
- HDU 6268 Master of Subgraph (2017 CCPC 杭州 E题,树分治 + 树上背包)
题目链接 2017 CCPC Hangzhou Problem E 题意 给定一棵树,每个点有一个权值,现在我们可以选一些连通的点,并且把这点选出来的点的权值相加,得到一个和. 求$[1, m] ...
- HDU 6274 Master of Sequence (暴力+下整除)
题意 两个1e5的数组a,b,定义\(S(t)=\left \lfloor \frac{t-b_i}{a_i} \right \rfloor\),有三个操作 1 x y:将\(a[x]\)变为\(y\ ...
- hdu 6268 Master of Subgraph(点分治+bitset)
You are given a tree with n nodes. The weight of the i-th node is wi. Given a positive integer m, no ...
- HDU 5016 Mart Master II
Mart Master II Time Limit: 6000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ...
- HDU 5308 I Wanna Become A 24-Point Master
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5308 题面: I Wanna Become A 24-Point Master Time Limit ...
- HDU 5900 QSC and Master 区间DP
QSC and Master Problem Description Every school has some legends, Northeastern University is the s ...
- hdu 5540 Secrete Master Plan(水)
Problem Description Master Mind KongMing gave Fei Zhang a secrete master plan stashed × matrix, but ...
随机推荐
- Android studio的基本使用--基础篇
一.新建项目 其实跟IDEA新建项目的流程基本一致,File->New->New project,这样就能够新建出来一个项目啦! 一般情况下,我们都会选择Empty Activity,之后 ...
- 第六章 C控制语句:分支和跳转
6.1if语句 程序 #define _CRT_SECURE_NO_WARNINGS 1 //coladays.c -- 求出温度低于零度的天数 #include<stdio.h> int ...
- Django笔记一之运行系统、创建视图并访问
从这一篇笔记开始将根据 Django 的官方文档,阅读整理之后,出一系列笔记教程,用作新手入门教程或者自己做查阅. 此次 Django 的版本为 3.2,且之后的一系列笔记都将以这个版本为基础,做功能 ...
- Hive 与 HBase 之间的区别和联系
首先要知道 Hive 和 HBase 两者的区别,我们必须要知道两者的作用和在大数据中扮演的角色 概念 Hive 1.Hive 是 hadoop 数据仓库管理工具,严格来说,不是数据库,本身是不存储数 ...
- uniapp踩坑必备笔记
1.[配置]应用版本号名称有一个规则的字符串:1.0.0,规则是:大版本号,中版本号,小版本号. 2.[配置]应用版本号中的小版本号不能超过9,超过9的需要向上一个版本号进一(逢十进一). 3.[配置 ...
- MyBatis 版本升级引发的线上问题
MyBatis上线前后的版本:上线前(3.2.3)上线后(3.4.6) 服务上线后,开始陆续出现了一些更新系统交互日志方面的报警,这属于系统的辅助流程,报警如下代码所示.我们发现都是跟 MyBatis ...
- 传输层和网络层的checksum区别,TCP cksum为何包含伪首部
一直搞不清传输层和网络层的校验和为什么校验内容不一样,最近问了一些前辈,找寻了一些答案,总结一下自己的思考. 先说一下传输层(TCP)和网络层(IP)的校验和: TCP校验和有伪首部.TCP herd ...
- CSS3新增选择器(属性选择器、结构伪类选择器、伪元素选择器)
本博文介绍CSS3中新增的选择器,包括属性选择器.结构伪类选择器和伪元素选择器. 1 属性选择器 属性选择器([属性])可以根据元素的属性和属性值来对符合要求的元素进行选择. 属性选择器的基础语法如 ...
- Flask框架使用蓝图划分目录、g对象、使用数据库连接池链接数据库
目录 一.使用蓝图划分项目目录 1.蓝图的介绍 2.蓝图的使用 二.介绍flask框架的g对象 1. g对象是什么? 2. 使用代码再次解释g对象 三.使用数据库连接池链接数据库 1. 引入数据库连接 ...
- PDD也可以通过ID获取商品详情?
先我们可以通过pinduoduo.item_get的接口传入商品的ID参数,这个接口可以获取到拼多多商品的详情数据,包括商品的标题.价格.原价.卖家的昵称.库存.销量.宝贝的链接.商品的备注.宝贝图片 ...