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
#include <bits/stdc++.h>

using namespace std;

#define ll long long

int n;
string M;   


int main () {
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);

    cin >> n;
    cin >> M;

    vector<int> result(n, 0);
    vector<int> prefix(n + 1, 0);
    
    int i = 0, j = n - 1;

    while (i <= j) {
        while(M[i] == 'L' && i < n) i++;
        while(M[j] == 'P' && j >= 0) j--;
        if (i > j) break;
        if (i + 1 <= j - 1) {
            prefix[i + 1] += 2;
            prefix[j] -= 2;
        }
        result[i]++;
        if (i != j) {
            result[j]++;
        }
        i++;
        j--;
    }   

    int value = 0;
    for (int w = 0; w < n; w++) {
        value += prefix[w];
        cout << value + result[w] << " ";
    }


    return 0;
}