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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <bits/stdc++.h>
#define LLINF 100000000000000007

using namespace std;
typedef long long ll;
typedef string str;
template <typename T> using vec = vector<T>;

int n, N;
vec<ll> seg_tree;

void init();

void inc(int cur, int left, int right, int lOb, int rOb) {
	if(left == lOb && right == rOb) {
		seg_tree[cur]++;
		return;
	}

	int mid = (lOb + rOb) / 2;
	if(right <= mid) return inc(cur * 2, left, right, lOb, mid);
	if(left > mid) return inc(cur * 2 + 1, left, right, mid + 1, rOb);

	inc(cur * 2, left, mid, lOb, mid);
	inc(cur * 2 + 1, mid + 1, right, mid + 1, rOb);
}

ll get(int v) {
	v += N;
	ll sum = 0;
	while(v > 0) {
		sum += seg_tree[v];
		v /= 2;
	}
	return sum;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	cin>>n;
	str s;
	cin>>s;

	int rc = 0;
	init();
	for(int i = 0; i < n; i++) {
		if(s[i] == 'P') rc++;
		else {
			if(rc > 0) inc(1, i - rc + 1, i + 1, 1, N);
			if((i - rc + 2) <= i) inc(1, i - rc + 2, i, 1, N);
		}
	}

	for(int i = 0; i < n; i++) cout<<get(i)<<" ";
	
	cout.flush();
}


void init() {
	N = 1;
	while(N < n) N *= 2;
	seg_tree = vec<ll>(2 * N, 0);
}