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

using namespace std;

int value [300010];

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


    int n;
    string ciag;
    cin >> n;
    cin >> ciag;
    int zderzenia = 0;
    for (int i = 0; i < ciag.size() - 1; i = i + 2)
    {
        if (ciag[i] == 'P' &&ciag[i + 1]== 'L') zderzenia++;
    }
    while (zderzenia > 0)
    {
        zderzenia = 0;
        for (int i = 0; i < ciag.size() - 1; i++)
        {
            if (ciag[i] == 'P' && ciag[i + 1]== 'L')
            {
                value[i]++;
                value[i + 1]++;
                ciag[i + 1] = 'P';
                ciag[i] = 'L';
                zderzenia++;
            }
        }
    }

    for (int i = 0; i < ciag.size(); i++)
    {
        cout << value[i] << " ";
    }
    return 0;
}