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
#include <cstdio>

const int N = 300000 + 9;
char s[N];
int cnt[N];

int main() {
	int n;
	scanf("%d%s", &n, s);

	int mid = 0;
	for (int i = 0; i < n; ++i)
		if (s[i] == 'L')
			++mid;
	int pcnt = 0;
	for (int i = 0; i < mid; ++i) {
		cnt[i] += 2 * pcnt;
		if (s[i] == 'P') {
			++cnt[i];
			++pcnt;
		}
	}
	int lcnt = 0;
	for (int i = n - 1; i >= mid; --i) {
		cnt[i] += 2 * lcnt;
		if (s[i] == 'L') {
			++cnt[i];
			++lcnt;
		}
	}

	for (int i = 0; i < n; ++i)
		printf("%d%s", cnt[i], i + 1 < n ? " " : "\n");
	return 0;
}