提交时间:2022-10-04 11:26:08
运行 ID: 57461
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while(t--){ int n; string s; cin >> n >> s; if(s.size()==n)cout << s << endl; else if(s.size()<n){ int t; while(s.size()<n&&(t=s.find("w"))!=s.npos)s=s.replace(t,1,"uu"); while(s.size()<n&&(t=s.find("m"))!=s.npos)s=s.replace(t,1,"nn"); cout << s << endl; } else if(s.size()>n){ int t; while(s.size()>n&&(t=s.find("uu"))!=s.npos)s=s.replace(t,2,"w"); while(s.size()>n&&(t=s.find("nn"))!=s.npos)s=s.replace(t,2,"m"); if(s.size()==n)cout << s << endl; else{ while(s.size()>n&&(t=s.find("uwu"))!=s.npos)s=s.replace(t,3,"ww"); while(s.size()>n&&(t=s.find("nmn"))!=s.npos)s=s.replace(t,3,"mm"); if(s.size()==n)cout << s << endl; } } } return 0; }