提交时间:2022-05-05 13:14:31
运行 ID: 49264
#include<bits/stdc++.h> using namespace std; const int MAXN=401; int n,T,numa[MAXN],numb[MAXN]; char a[MAXN],b[MAXN]; int main(){ cin>>n>>T; for(int i=1;i<=n;i++) a[i]=getchar(),numa[i]=(a[i]=='R'); while(T--){ for(int i=1;i<=400;i++) if(a[i]=='R')b[i+2]='R',numb[i+2]=numa[i],numa[i]=0; for(int i=1;i<=402;i++) if(b[i]=='R'){ int j=i; while(a[j]=='G')j--; numa[j]+=numb[i]; a[j]='R'; } for(int i=1;i<=400;i++) if(a[i]=='G'||(a[i]=='R'&&numa[i]==1)) putchar(a[i]); else if(a[i]=='R'&&numa[i]) printf("R(%d)",numa[i]); for(int i=0;i<=404;i++) b[i]=' '; puts(""); } return 0; }