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

int main() {
    cin.tie(0)->sync_with_stdio(false);
    int n;
    string m;
    cin >> n >> m;
    vector<long long> tt(n, 0);
    vector<long long> td(n+1, 0);
    int l=0,r=n-1;
    while (l<r) {
        while (m[l] == 'L') l++;
        while (m[r] == 'P') r--;
        if (l>r) break;
        td[l]+=1;
        td[l+1]+=1;
        td[r]-=1;
        td[r+1]-=1;
        m[l]='L';
        m[r]='P';
    }
    int tv = 0;
    for (int i=0;i<n;i++) {
        tv += td[i];
        tt[i] += tv;
    }
    for (const auto &v: tt) cout << v << ' ';
    cout << endl;
}