Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
48142 lzqy_ 【AB-1】比赛 C++ 通过 100 0 MS 252 KB 961 2022-04-09 14:23:54

Tests(10/10):


#include<bits/stdc++.h> using namespace std; int n,T; int tong[1010]; int Red[110],Green[110]; void walk(int n,int m){ for(int i=1;i<=n;i++) Red[i]+=3; for(int i=1;i<=m;i++) Green[i]++; } void init(int m){ memset(tong,0,sizeof(tong)); for(int i=1;i<=m;i++) tong[Green[i]]++; } void chuai(int n){ for(int i=1;i<=n;i++) while(tong[Red[i]]) Red[i]--; } int main(){ register char c; int N1=0,N2=0,l1,l2,sum; scanf("%d%d",&n,&T); for(int i=1;i<=n;i++){ cin>>c; if(c=='R') Red[++N1]=i; else Green[++N2]=i; } for(int t=1;t<=T;t++){ walk(N1,N2); init(N2); chuai(N1); sort(Red+1,Red+N1+1); sort(Green+1,Green+N2+1); l1=l2=1; for(int i=1;i<=n;i++){ if((l1<=N1&&Red[l1]<Green[l2])||l2>N2){ printf("R"),sum=1; while(l1<=N1&&Red[l1]==Red[l1+1]) i++,l1++,sum++; l1++; if(sum>1) printf("(%d)",sum); } else printf("G"),l2++; } printf("\n"); } return 0; }


测评信息: