Master of Shuangpin

在这里插入图片描述
题目传送门1
题目传送门2
这个题最开始是在codeforces上做了一遍的,后来在杭电oj上拿当初过了的代码提交了一遍结果报PE,然后又拿codeforces上AC的代码改了一下,末尾没有括号AC了。

#include<bits/stdc++.h>
using namespace std;
map<string,string>mp;
void init(){
	mp["q"] = mp["iu"] = "q";
	mp["w"] = mp["ei"] = "w";
	mp["e"] = "e";
	mp["r"] = mp["uan"] = "r";
	mp["t"] = mp["ue"] = "t";
	mp["y"] = mp["un"] = "y";
	mp["u"] = mp["sh"] = "u";
	mp["i"] = mp["ch"] = "i";
	mp["o"] = mp["uo"] = "o";
	mp["p"] = mp["ie"] = "p";
	mp["a"] = "a";
	mp["s"] = mp["ong"] = mp["iong"] = "s";
	mp["d"] = mp["ai"] = "d";
	mp["f"] = mp["en"] = "f";
	mp["g"] = mp["eng"] = "g";
	mp["h"] = mp["ang"] = "h";
	mp["j"] = mp["an"] = "j";
	mp["k"] = mp["uai"] = mp["ing"] = "k";
	mp["l"] = mp["uang"] = mp["iang"] = "l";
	mp["z"] = mp["ou"] = "z";
	mp["x"] = mp["ia"] = mp["ua"] = "x";
	mp["c"] = mp["ao"] = "c";
	mp["v"] = mp["zh"] = mp["ui"] = "v";
	mp["b"] = mp["in"] = "b";
	mp["n"] = mp["iao"] = "n";
	mp["m"] = mp["ian"] = "m";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	init();
	string s;
	while(getline(cin,s)){
		stringstream ss(s);
		string a;
		int k = 0,sum_space = 0;
		for(int i=0;i<s.length();i++)if(s[i] == ' ')sum_space++;
		//cout << sum_space << endl;
		while(ss >> a){
			if(a.length() == 1){
				cout << a << a;
				if(k < sum_space){
					cout << " ";
					k++;
				} else if(k == sum_space)cout << endl;
				continue;
			}
			if(a.length() == 2){
				cout << a;
				if(k < sum_space){
					cout << " ";
					k++;
				} else if(k == sum_space)cout << endl;
				continue;
			}
			if(mp[a] != ""){
				string s1 = a.substr(0,1);
				cout << mp[s1];
				cout << mp[a];
				if(k < sum_space){
					cout << " ";
					k++;
				} else if(k == sum_space)cout << endl;
				continue;
			}
			string s1 = "",s2 = "";
			s1 = s1 + a[0] + a[1];
			if(mp[s1] != ""){
				cout << mp[s1];
				for(int i=2;i<a.length();i++)s2 = s2 + a[i];
				cout << mp[s2];
			} else {
				s1 = "";
				s1 = s1 + a[0];
				cout << mp[s1];
				for(int i=1;i<a.length();i++)s2 = s2 + a[i];
				cout << mp[s2];
			}
			if(k < sum_space){
				cout << " ";
				k++;
			} else if(k == sum_space)cout << endl;
		}
	}
	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值