#include <iostream>
#include <vector>
#include <list>
int main(const int argc, char const * const argv[]) {
    uint32_t antCount;
    std::cin>>antCount;
    std::vector<bool> goingLeft;
    std::vector<uint64_t> ans(antCount, 0);
    goingLeft.reserve(antCount);
    char direction;
    for(uint32_t i = 0; i < antCount; ++i) {
        std::cin>>direction;
        goingLeft.push_back(direction == 'L');
    }
    uint32_t begin = 0;
    std::list<uint32_t> list;
    for(uint32_t i = 0; i + 1 < goingLeft.size(); ++i) {
        if(goingLeft[i] || !goingLeft[i + 1]) {
            continue;
        }
        list.push_back(i);
    }
    while(list.size()) {
        const uint32_t current = list.front();
        list.pop_front();
        ++ans[current];
        ++ans[current + 1];
        goingLeft[current] = !goingLeft[current];
        goingLeft[current + 1] = !goingLeft[current + 1];
        if(goingLeft[current] && current != 0 && !goingLeft[current - 1]) {
            list.push_back(current - 1);
        }
        else if(!goingLeft[current] && current + 1 != goingLeft.size() && goingLeft[current + 1]) {
            list.push_back(current);
        }
    }
    for(size_t i = 0; i < ans.size(); ++i) {
        std::cout<<ans[i]<<' ';
    }
    return 0;
}
        1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42  | #include <iostream> #include <vector> #include <list> int main(const int argc, char const * const argv[]) { uint32_t antCount; std::cin>>antCount; std::vector<bool> goingLeft; std::vector<uint64_t> ans(antCount, 0); goingLeft.reserve(antCount); char direction; for(uint32_t i = 0; i < antCount; ++i) { std::cin>>direction; goingLeft.push_back(direction == 'L'); } uint32_t begin = 0; std::list<uint32_t> list; for(uint32_t i = 0; i + 1 < goingLeft.size(); ++i) { if(goingLeft[i] || !goingLeft[i + 1]) { continue; } list.push_back(i); } while(list.size()) { const uint32_t current = list.front(); list.pop_front(); ++ans[current]; ++ans[current + 1]; goingLeft[current] = !goingLeft[current]; goingLeft[current + 1] = !goingLeft[current + 1]; if(goingLeft[current] && current != 0 && !goingLeft[current - 1]) { list.push_back(current - 1); } else if(!goingLeft[current] && current + 1 != goingLeft.size() && goingLeft[current + 1]) { list.push_back(current); } } for(size_t i = 0; i < ans.size(); ++i) { std::cout<<ans[i]<<' '; } return 0; }  | 
            
        
                    English