HDU - 7125

AYIT609第一周周赛(2021)

Problem Description

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.

Attention that:

1: For pinyin of length 1, you should repeat it in order to meet the conditions.
2: For those of length 2, just output the original pinyin.
3: 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.
4: 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.

Sample 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
ni you ben shi na lai mai a
wo e le wo men chi shen me
ang yang de dou zhi

Sample 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
ni yz bf ui na ld md aa
wo ee le wo mf ii uf me
ah yh de dz vi

题意:拼音转双拼
思路:用map<string,string>
失误点1:字符串数组a和字符串b没有按图里的一一对照好
失误点2:没把题中条件看全,单个字符输出两边,只有韵母的输出首字母和对应的字符
反思:好的精气神能事半功倍,反之事倍功半

#include<cstdio>
#include<map>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
char a[][5]={"iu","ei","uan","ue","un","uo","ie","ong","iong","ai","en","eng","ang","an","uai","ing","uang","iang","ou","ia","ua","ao","ui","in","iao","ian"};
//因为声母大多数是一位的,只有三个是两位的,所以在此只存除了声母和单韵母以外的部分
char b[]="qwrtyopssdfghjkkllzxxcvbnm";
char d[10];
map<string,string> m;
map<string,string>::iterator it;
int main()
{string str0,str1;char c,cc;int i,l,sss;for(i=0;i<26;i++){str0=a[i];str1=b[i];m[str0]=str1;}while(~scanf("%[a-z]%c",d,&c)){sss=l=strlen(d);if(l==1)//单字母情况printf("%s%s",d,d);else if(l==2)//双字母情况printf("%s",d);else{if(d[1]=='h')//声母是两位的时候分这三种情况{if(d[0]=='c')cc='i';else if(d[0]=='s')cc='u';else if(d[0]=='z')cc='v';sss-=2;str0.assign(d+2);}else{cc=d[0];str1=d;for(it=m.begin();it!=m.end();it++)if((*it).first==str1)//拼音只有韵母的情况 韵母str0 就是整个拼音{str0.assign(d);break;}if(it==m.end())//表里找不到和拼音一样的,说明有声母,因为上面已经处理过两位声母的情况,所以下面是一个声母的情况{sss-=1;str0.assign(d+1);//此时 韵母str0 就是除了第一个声母以外的部分}}printf("%c",cc);//声母部分翻译的字符if(sss==1)//韵母部分是一位的情况printf("%c",d[l-1]);elsecout<<m[str0];}printf("%c",c);}return 0;
}

HDU - 7125 Master of Shuangpin相关推荐

  1. HDU 6265 Master of Phi

    Master of Phi 推式子 ∑d∣nϕ(nd)d给出了n的唯一分解形式我们先对上面式子进行化简通过组合枚举d,d的取值分别可以通过∏i=1m∑j=0qipij,一个多项式组合得到那么上述的式子 ...

  2. 红黑树调整(漫画版)

    首页 首页 沸点 话题 小册 活动 写文章 登录注册 程序员小灰 2017年12月06日阅读 23937 关注 漫画:什么是红黑树? ​ ------------ ------------ 二叉查找树 ...

  3. Hdu 4916 Count on the path

    意甲冠军:鉴于一棵树的顶点标签为连续1~n,不是每个网上查询a-b最小的圆点标签路径 这题想了好久,如果1为根节点. 首先如果a-b只是根节点1.答案一定是1. 否则我们用fa[i]表示i节点的父亲, ...

  4. The 15th Chinese Northeast Collegiate Programming Contest部分题解

    The 15th Chinese Northeast Collegiate Programming Contest 目录 E. Easy Math Problem 题目思路 题目代码 I. Takea ...

  5. The 15th Chinese Northeast Collegiate Programming Contest

    linkkkkkk 1001 Matrix 题意: 用 [ 1 , n 2 ] [1,n^2] [1,n2]的数填 n ∗ n n*n n∗n的矩阵,每个数字只能用一次,记 a i a_i ai​表示 ...

  6. 【21.10.24】The 15th Chinese Northeast Collegiate Programming Contest题解

    A. Matrix(组合数+数学) #include <bits/stdc++.h> using namespace std; #define mod 998244353 ll fac[1 ...

  7. The 15th Chinese Northeast Collegiate Programming Contest 题解(CCPC压力测试?

    CCPC压力测试用了这套题,和一个队友一起搞了.初期签到还算比较顺利,还碰到了挺多有意思的题目,做的好爽,但还是犯了很多低级错误,对于杭电要时时刻刻关同步或者scanf,并且写代码还是要仔细些. A. ...

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

  9. HDU 6709“Fishing Master”(贪心+优先级队列)

    传送门 •参考资料 2019CCPC网络选拔赛 H.Fishing Master(思维+贪心) •题意 池塘里有 n 条鱼,捕捉一条鱼需要花费固定的 k 时间: 你有一个锅,每次只能煮一条鱼,其中煮熟 ...

最新文章

  1. php 返回字符串给aja,解决ajax异步请求返回的是字符串问题
  2. 美国在理论计算机科学的研究重视,留学热门专业计算机之研究方向篇
  3. 我的四年建站故事(X)
  4. 【图论】最短路上的统计(ssl 1500)
  5. C语言,谁都能看得懂的归并排序
  6. 不混淆so文件_NDK开发_编译的cpp引用到 其它so, Android.mk 的写法
  7. 4十4十4写成乘法算式_小学数学二年级下册数学1-4单元知识点复习提前准备才能考的更好...
  8. Mybatis案例升级版——小案例大道理
  9. oracle学习-数据迁移
  10. 极限编程(xp),iso国际标准化组织
  11. 数组中常见的问题,索引越界和空指针异常
  12. 跨平台数据库ODB实战1-ODB安装
  13. 【PhotoShop基础A篇】磨皮/图层/液化
  14. idea去掉拼写检查
  15. 正常人小气道上皮细胞 Small airway epithelial cells
  16. 多变量微积分笔记(1)——向量和矩阵
  17. 视频教程-Echarts+Asp.Net+Sql Server报表开发视频教程-.NET
  18. 推荐一个windows下使用的无广告解压缩软件
  19. 生信技能树课程记录笔记(三)20220526
  20. rv是什么电子元件 RV线的具体作用都有哪些

热门文章

  1. 中科院博士教你如何查找外文文献
  2. 请编写程序,读入CSV文件中数据,循环获得用户输入,直至用户直接输入“Q”退出。根据用户输入的星座名称,输出此星座的出生日期范围及对应字符形式。如果输入的名称有误,请输出“输入星座名称有误”
  3. 我糟糕的2019年:虽流年不利,但我心仍坚定
  4. 计算机我的生涯规划档案,我的生涯规划档案.doc
  5. FBI查封泄露数据售卖网站WeLeakInfo.com
  6. 久坐伤身,这个3D坐垫能让危害降到最低,办公自驾必备!
  7. 女朋友的情绪难以捉摸,作为程序员我应该?
  8. 双碳时代,数据中心供配电的“智”与“能”
  9. The 10 Most Important Linux Commands/10个最经常使用的命令行
  10. Looksery Cup 2015 F. Yura and Developers(单调栈+二分+分治)(难*)