提交时间:2022-04-12 13:34:01
运行 ID: 48380
#include <iostream> #include <cstring> #include <cstdio> using namespace std; bool g[310]; int a[310]; int r[110],rc = 0; int main() { //freopen("race.in","r",stdin); //freopen("race.out","w",stdout); int n,T,t,i; string st; cin>>n>>T; cin>>st; for(i = 0;i < st.size();i++) { if(st[i] == 'G') g[i + 1] = 1; else r[++rc] = i + 1; } for(t = 1;t <= T;t++) { memset(a,0,sizeof(a)); for(i = 1;i <= rc;i++) { r[i]+=3; while(g[r[i] - t]) r[i]--; a[r[i]]++; } for(i = 1;i <= 309;i++) { if(i - t >=0&&g[i - t]) cout<<'G'; if(a[i] > 0) { if(a[i] > 1) cout<<"R("<<a[i]<<')'; else cout<<'R'; } } cout<<endl; } return 0; }