Advertisement
borsha06

268B_

Dec 10th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,i,j,l;
  6.     string s;
  7.     cin>>n>>l;
  8.     cin>>s;
  9.  
  10.     while(l)
  11.     {
  12.         for(i=0; i<n; i++)
  13.         {
  14.             if(s[i]=='B' && s[i+1]=='G')
  15.             {
  16.                 swap(s[i],s[i+1]);
  17.                 i++;
  18.             }
  19.         }
  20.         l--;
  21.     }
  22.  
  23.         cout<<s<<endl;
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement