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
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, lower, upper) for(int (i) = (lower); i <= (int)(upper); (i)++)
#define FORD(i, upper, lower) for(int (i) = (upper); i >= (int)(lower); (i)--)
#define PB push_back
using ll = long long;

const int N = 3e5;

char a[N + 1];
int ans[N + 1];
int n, L, R;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    FOR(i, 1, n) {
        cin >> a[i];
    }
    FOR(i, 1, n) {
        if(a[i] == 'L') {
            L++;
        }
        else {
            R++;
        }
    }
    (a[1] == 'L' || L == 0) ? ans[1] = 0 : ans[1] = 1; 
    FOR(i, 1, L - 1) {
        if(a[i] == 'L' && a[i + 1] == 'L') {
            ans[i + 1] = ans[i];
        }
        else if(a[i] != a[i + 1]) {
            ans[i + 1] = ans[i] + 1;
        }
        else if(a[i] == 'P' && a[i + 1] == 'P') {
            ans[i + 1] = ans[i] + 2;
        }
    }
    (a[n] == 'P' || L == n) ? ans[n] = 0 : ans[n] = 1;
    FORD(i, n, L + 2) {
        if(a[i] == 'P' && a[i - 1] == 'P') {
            ans[i - 1] = ans[i];
        }
        else if(a[i] != a[i - 1]) {
            ans[i - 1] = ans[i] + 1;
        }
        else if(a[i] == 'L' && a[i - 1] == 'L') {
            ans[i - 1] = ans[i] + 2;
        }
    }
    FOR(i, 1, n) {
        cout << ans[i] << ' ';
    }
    
    return 0;
}