题目链接:https://vjudge.net/contest/277768#problem
代码:
#include <iostream>
using namespace std;
int main()
{
int n, t;
cin >> n >> t;
if (n < 1 || n>50 || t < 1 || t>50)
return 0;
char *s = new char[n + 1];
cin >> s;
for(int j=0;j<t;j++)
for (int i = 0; i < n-1; i++)
{
if (s[i] == 'B'&&s[i + 1] == 'G')
{
s[i] = 'G';
s[i + 1] = 'B';
i++;
}
}
cout << s;
delete []s;
}