266B - Queue at the School Codeforces || Codeforces 266B - Queue at the School Solution

Problem Name: 266B Queue at the School
Judge: Codeforces
Problem link: 266B Queue at the School



Codeforces 266B - Queue at the School Solution in C++/Cpp

#include <iostream>
#include <string>

using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    string s;
    cin >> s;
    for (int j = 0; j < t; j++) {
        for (int i = 0; i < n; i++) {
            if (s[i] == 'B' && s[i + 1] == 'G') {
                swap(s[i], s[i + 1]);
                i++;
            }
        }
    }
    cout << s << "\n";

    return 0;
}








Tags: Codeforces 266B - Queue at the School solution in C C++, 266B codeforces solution in C C++, Codeforces 266B solution in C C++, Codeforces Queue at the School solution in C C++, 266B - Queue at the School Codeforces solution in C C++ Java Python, C#, Javascript, Codeforces 266B - Queue at the School solution in C C++ Java Python, C#, Javascript, 

Next Post Previous Post
No Comment
Add Comment
comment url