提交时间:2022-04-10 11:35:39
运行 ID: 48164
#include<bits/stdc++.h> using namespace std; #define N 105 int n,T; int r[N],g[N]; int c1,c2,s[N]; #undef N int main(){ std::ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>n>>T; for(int i(1);i<=n;++i){ char c;cin>>c; if(c=='R'){r[++c1]=i;s[c1]=1;} else g[++c2]=i; } for(int i(1);i<=T;++i){ for(int j(1);j<=c1;++j) r[j]+=3; for(int j(1);j<=c2;++j) g[j]+=1; for(int j(1);j<=c1;++j) for(int k(c2);k>=1;--k) if(r[j]==g[k]) --r[j]; for(int j(c1);j>=2;--j) if(r[j]==r[j-1]){ s[j-1]+=s[j];--c1; for(int k(j);k<=c1;++k){ r[k]=r[k+1]; s[k]=s[k+1]; } } int p1(1),p2(1); while(p1<=c1&&p2<=c2){ if(r[p1]<g[p2]){ if(s[p1]==1) cout<<"R"; else cout<<"R("<<s[p1]<<")"; ++p1; } else{cout<<"G";++p2;} } while(p1<=c1){ if(s[p1]==1) cout<<"R"; else cout<<"R("<<s[p1]<<")"; ++p1; } while(p2<=c2){cout<<"G";++p2;} cout<<endl; } return 0; }