提交时间:2022-10-04 11:26:39

运行 ID: 57466

#include<bits/stdc++.h> using namespace std; inline int read(){ int X=0,w=0; char ch=0; while(!isdigit(ch)) {w|=ch=='-';ch=getchar();} while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar(); return w?-X:X; } inline void write(int x){ if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } char s[100001]; string t; int main(){ int T=read(); while(T--){ int n=read(); cin>>s+1; int len=strlen(s+1); t=""; for(int i=1;i<=len;i++){ if(s[i]=='w') t+="uu"; else if(s[i]=='m') t+="nn"; else t+=s[i]; } int l2=t.size(),tp=l2-n; for(int i=0;i<l2;i++){ if(i<l2-1&&(t[i]=='u'&&t[i+1]=='u')&&tp){ cout<<"w"; i++; tp--; }else if(i<l2-1&&(t[i]=='n'&&t[i+1]=='n')&&tp){ cout<<"m"; i++; tp--; }else cout<<t[i]; } puts(""); } return 0; }