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
#include <iostream>
#include <algorithm>
using namespace std;



int main()
{
    ios::sync_with_stdio(false);
    int n;
    std::cin >> n;
    string directions;
    std::cin >> directions;
    int leftCount = std::ranges::count(directions, 'L');
    int colisionWithLeft = 0;
    for (size_t i = 0; i < directions.size(); ++i)
    {
      bool initialLeft = (directions[i] == 'L');
      bool finalLeft = (i < leftCount);
      int collisionWithRight = colisionWithLeft;
      if (initialLeft && !finalLeft)
        collisionWithRight = colisionWithLeft - 1;
      if (!initialLeft && finalLeft)
        collisionWithRight = colisionWithLeft + 1;
      std::cout << (colisionWithLeft+ collisionWithRight) << " ";
      colisionWithLeft = collisionWithRight;
    }
    return 0;
}