borsha06

268B_codeforces_updated

Dec 10th, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 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.                 std::swap(s[i],s[i+1]);
  17.             }
  18.         }
  19.         l--;
  20.     }
  21.  
  22.         cout<<s<<endl;
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment