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

int main() {
	ios::sync_with_stdio(false);

	int n;
	string str;
	cin >> n >> str;

	int arr[n];
	fill(arr, arr+n, 0);


	int l = 0, r = n;
	while(l < r) {
		while(l < n && str[l] == 'L') ++l;
		while(--r >= 0 && str[r] == 'R') {;}
		for(int i = l+1; i <= r; ++i) {
			if(str[i-1] == 'P' && str[i] == 'L') {
				str[i-1] = 'L';
				str[i] = 'P';
				arr[i-1]++;
				arr[i++]++;
			}
		}
	}
	for(const int& i : arr)
		cout << i << ' ';
}