HDU - 7125 Master of Shuangpin

D. Master of Shuangpin
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
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]
PinyinSequencePinyinSequence
q, iuqf, enf
w, eiwg, engg
eeh, angh
r, uanrj, anj
t, uetk, uai, ingk
y, unyl, uang, iangl
u, shuz, ouz
i, chix, ia, uax
o, uooc, aoc
p, iepv, zh, uiv
aab, inb
s, ong, iongsn, iaon
d, aidm, ianm

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".

Input

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.

Output

The keys sequence separated by spaces.

Examples
input
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
output
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
input
ni you ben shi na lai mai a
wo e le wo men chi shen me
ang yang de dou zhi
output
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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小小白?

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值