1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
// 2024 HOPE IN VALUABLE
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int n,l[N],r[N]; string S;
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>S; S='#'+S;
	for(int i=1;i<=n;i++){
		l[i]=l[i-1]; r[i]=r[i-1];
		if(S[i]=='L') l[i]++; else r[i]++;
	}
	for(int i=1;i<=n;i++){
		int x=r[i-1],y=l[n]-l[i];
		cout<<min(2*x+(S[i]=='P'),2*y+(S[i]=='L'))<<(i==n?'\n':' ');
	}
	return 0;
}