题目传送门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;
}