提交时间:2022-10-04 11:30:38
运行 ID: 57500
#include<bits/stdc++.h> using namespace std; int main(){ int T,n,c,d,i; string t,s; cin>>T; while(T--){ cin>>n>>t; c=0; s=""; for(i=0;i<t.length();i++){ if(t[i]=='w')s=s+"uu"; else if(t[i]=='m')s=s+"nn"; else s=s+t[i]; } c=s.length(); d=c-n; for(i=0;i<c;i++){ if(i+1<c&&s[i]=='u'&&s[i+1]=='u'&&d>0){ putchar('w'); i++; d--; continue; } if(i+1<c&&s[i]=='n'&&s[i+1]=='n'&&d>0){ putchar('m'); i++; d--; continue; } putchar(s[i]); } putchar('\n'); } }