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
#include<bits/stdc++.h>
using namespace std;
string s;
int wynik[300005],mod[300005];
int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    int ogon=0,modyfikator=0;
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(i==0)
        {
            while(i<n and s[i]=='L') i++;
            ogon=i;
            //i--;
        }
        if(s[i]=='L')
        {
            wynik[i]++;
            wynik[ogon]++;
            ogon++;
            mod[ogon]+=2;
            mod[i]-=2;
        }
    }
    for(int i=0;i<n;i++)
    {
        modyfikator+=mod[i];
        cout<<wynik[i]+modyfikator<<' ';
    }
}