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

using namespace std;

typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define pb push_back
#define fi first
#define se second
#define rep(i,b,e) for(int i=(b); i<(e); i++)
#define each(a,x)  for(auto &a : (x))
#define all(x) (x).begin(), (x).end()
#define sz(x)  (int)(x).size()

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n;
    cin >> n >> s;
    vi cntL(n),cntP(n);
    rep(i,0,n){
        if(i) cntL[i]+=cntL[i-1];
        cntL[i] += s[i]=='L';
        if(i) cntP[i]+=cntP[i-1];
        cntP[i] += s[i]=='P';
    } 
    rep(i,0,n){
        int bouncesFront=0,bouncesBack=0;
        bouncesFront = i ? cntP[i-1] : 0;
        bouncesBack = cntL[n-1]-cntL[i];
        // L
        if(s[i]=='P')
            swap(bouncesFront,bouncesBack);
        cout << min(2*bouncesFront,2*bouncesBack+1) << " ";
    }
    return 0;
}