//cf #163 div 2 A // http://codeforces.com/contest/266/problem/A #include<stdio.h> #include<iostream> using namespace std; char a[55]; int main(){ int n,i; //freopen("input.txt","r",stdin); while(scanf("%d%*c",&n)!=EOF){ int sum=0; for(i=0;i<n;i++) scanf("%c",a+i); for(i=0;i<n-1;i++) if(a[i]==a[i+1]) sum++; printf("%d\n",sum); } return 0; } //cf #163 div 2 B // http://codeforces.com/contest/266/problem/B #include<stdio.h> char a[100]; int main(){ // freopen("input.txt","r",stdin); int n,t,i; while(scanf("%d%d",&n,&t)!=EOF){ scanf("%s",a); while(t--){ for(i=0;i<n;) if(a[i]=='B'&&a[i+1]=='G'){ a[i]='G'; a[i+1]='B'; i+=2; } else i++; } printf("%s\n",a); } return 0; }
时间: 2024-10-30 19:59:02