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

const char L = 'L';
const char P = 'P';

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

	int n;
	cin >> n;
	string text;
	cin >> text;
	vector<int> counter(n, 0);
	vector<bool> begin(n, false);
	vector<bool> end(n, false);


	int firstP = n;
	for (int i = 0; i < n; i++) {
		if (text[i] == P) {
			firstP = i;
			break;
		}
	}
	for (int i = firstP + 1; i < n; i++) {
		if (text[i] == L) {
			begin[firstP] = true;
			end[i] = true;
			firstP++;
		}
	}
	int value = 0;
	for (int i = 0; i < n; i++) {
		if (begin[i]) {
			value += 2;
			counter[i]--;
		}
		counter[i] += value;
		if (end[i]) {
			value -= 2;
			counter[i]--;
		}
	}

	for (int i = 0; i < n; i++) {
		cout << counter[i] << " ";
	}
	cout << endl;

	return 0;
}