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
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
const int inf = 1e9+7;
const ll inf_ll = 1e18+7;

void boost ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int n, lewo1[300007], lewo2[300007], prawo1[300007], prawo2[300007];
string s;

int main ()
{
    boost();

    cin >> n >> s;
    for (int i = 1; i <= n; i++) {
        lewo1[i] = lewo1[i - 1];
        prawo1[i] = prawo1[i - 1];
        if (s[i - 1] == 'L')
            lewo1[i]++;
        else
            prawo1[i]++;
    }

    for (int i = n; i >= 1; i--) {
        lewo2[i] = lewo2[i + 1];
        prawo2[i] = prawo2[i + 1];
        if (s[i - 1] == 'L')
            lewo2[i]++;
        else
            prawo2[i]++;
    }

    for (int i = 1; i <= n; i++) {
        if (s[i - 1] == 'L') {
            cout << min(2 * prawo1[i - 1], 2 * lewo2[i + 1] + 1) << " ";
        }
        else {
            cout << min(2 * lewo2[i + 1], 2 * prawo1[i - 1] + 1) << " ";
        }
    }

    return 0;
}