提交时间:2022-10-04 11:25:48
运行 ID: 57457
#include <bits/stdc++.h> using namespace std; bool flag[200003]; int n, t, cnt, tmp; char a[100003], b[200003]; int main() { // freopen("J2.in", "r", stdin); // freopen("J2.out", "w", stdout); scanf("%d", &t); while(t--) { cnt = 0; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); memset(flag, 0, sizeof(flag)); scanf("%d\n", &n); scanf("%s", a+1); tmp = strlen(a+1); for(int i=1; i<=tmp; i++) { if(a[i] == 'w') { b[++cnt] = 'u'; b[++cnt] = 'u'; } else if(a[i] == 'm') { b[++cnt] = 'n'; b[++cnt] = 'n'; } else b[++cnt] = a[i]; } tmp = cnt; for(int i=1; i<=cnt&&tmp>n; i++) { if(b[i]=='u' && b[i+1]=='u') { b[i] = 'w'; flag[++i] = true; tmp--; } else if(b[i]=='n' && b[i+1]=='n') { b[i] = 'm'; flag[++i] = true; tmp--; } } for(int i=1; i<=cnt; i++) { if(!flag[i]) putchar(b[i]); } puts(""); } return 0; }