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

int INT() {
	int in; cin>>in;
	return in;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n=INT();
	string s; cin>>s;
	vector <int> rig_pref(n+2), lef_suff(n+2);
	rig_pref[0]=0, lef_suff[n+1]=0;
	for(int i=1; i<=n; ++i) rig_pref[i]=rig_pref[i-1]+int(s[i-1]=='P');
	for(int i=n; i; --i) lef_suff[i]=lef_suff[i+1]+int(s[i-1]=='L');
	for(int i=1; i<=n; ++i) {
		int l=rig_pref[i-1], r=lef_suff[i+1];
		if(s[i-1]=='L') swap(l, r);
		if(l<r) cout<<2*l+1<<" ";
		else cout<<2*r<<" ";
	}
	cout<<"\n";
	exit(0);
}