#include <stdio.h> #define MAXSIZE 1024 char que[MAXSIZE]; int main() { int n, t; scanf("%d %d", &n, &t); scanf("%s", que); int i, j; char temp; for(j=1; j<=t; ++j) { for(i=0; i<n-1; ++i) { if((que[i]=='B')&&(que[i+1]=='G')) { //printf("%dseconds:%d %d\n", j, i, i+1); temp=que[i]; que[i]=que[i+1]; que[i+1]=temp; i+=1; //printf("The i is equal to %d.\n", i); } } } for(i=0; i<n; ++i) printf("%c", que[i]); printf("\n"); return 0; }