提交时间:2022-04-11 19:51:14
运行 ID: 48306
#include<bits/stdc++.h> using namespace std; #define Max 500 int a[Max],b[Max],n,T; int main() { scanf("%d%d",&n,&T); char x; for(int i=1; i<=n; i++) { scanf("%c",&x); if(x=='R')a[i]++; else b[i]++; } while(T--) { for(int i=Max; i>=0; i--) if(a[i]) a[i+3]+=a[i],a[i]=0; else if(b[i]) b[i+1]+=b[i],b[i]=0; for(int i=Max; i>=1; i--) if(a[i]&&b[i]) a[i-1]+=a[i],a[i]=0; for(int i=0; i<=Max; i++) { if(a[i])(a[i]>1?printf("R(%d)",a[i]):printf("R")); if(b[i]) putchar('G'); } puts(""); } return 0; }