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

#define vec vector
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define repr(i,a,b) for(int i=(a); i>=(b); --i)
#define x first
#define y second

using namespace std;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vec<int> l(n+2), r(n+2);
	rep (i, 1, n+1) {
		r[i] = r[i-1] + (s[i-1] == 'P');
	}
	repr (i, n, 1) {
		l[i] = l[i+1] + (s[i-1] == 'L');
	}
	rep (i, 1, n+1) {
		int a = l[i+1], b = r[i-1];
		if (s[i-1] == 'L') {
			swap(a, b);
		}
		cout << min(a, b+1) + min(b, a) << " ";
	}
	cout << "\n";
	return 0;
}