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
//GRT_2018
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define all(x) x.begin(), x.end()
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

using namespace std;

using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;

const int nax = 300 * 1000 + 10;
int n;
int inv[nax];
string s;
int sum[nax];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    cin >> n >> s;
    
    int cntP = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'L') inv[i] = cntP;
        else cntP++;
    }
    
    int cntL = 0;
    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'P') inv[i] = cntL;
        else cntL++;
    }

    for (int i = 0; i < n; ++i) {
        if (s[i] == 'P') {
            // add [i + 1, i + inv[i]]
            sum[i + 1]++;
            sum[i + inv[i] + 1]--;
        } else {
            // add [i - inv[i], i - 1]
            sum[i - inv[i]]++;
            sum[i]--;
        }
    }
    for (int i = 1; i < n; ++i) sum[i] += sum[i - 1];
    for (int i = 0; i < n; ++i) {
        cout << sum[i] << " ";
    }
}