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

#define MAGICZNE_ZAKLECIE std::ios::sync_with_stdio(0);\
    cin.tie(0);\
    cout.tie(0)

#define repeat(times) for (int loop_count = 0; loop_count < times; loop_count++)

int main() {
    MAGICZNE_ZAKLECIE;
    int n;
    string s;
    cin >> n >> s;
    int vl[n], vr[n];

    vl[0] = (s[0] == 'L') ? 0 : 1;
    vr[n - 1] = (s[n - 1] == 'P') ? 0 : 1;
    
    for (int i = 1; i < n; i++) {
        vl[i] = (s[i] == s[i - 1]) ? ((s[i] == 'L') ? vl[i - 1] : (vl[i - 1] + 2)) : (vl[i - 1] + 1);
    }

    for (int i = n - 2; i >= 0; i--) {
        vr[i] = (s[i] == s[i + 1]) ? ((s[i] == 'P') ? vr[i + 1] : (vr[i + 1] + 2)) : (vr[i + 1] + 1);
    }
    
    for (int i = 0; i < n; i++) {
        cout << min(vl[i], vr[i]) << " ";
    }
}
;;