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
68
69
70
71
72
73
74
75
76
77
78
79
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <vector>
#include <functional>
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cctype>
#include <bitset>

using namespace std;

int lewo[300007];
int prawo[300007];

int main()
{

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

string uklad;
int mrowki, ileL, ileP;

cin >> mrowki;
cin >> uklad;

if (uklad.substr(0,1)=="L")
  ileP=0;
else
  ileP=1;
prawo[1]=ileP;
if (uklad.substr(mrowki-1,1)=="P")
  ileL=0;
else
  ileL=1;
lewo[mrowki]=ileL;

for (int n=1; n<mrowki; n++)
{

//cout << uklad.substr(n-1,2) << "-" << endl;

  if ((uklad.substr(n-1,2)=="PL") or (uklad.substr(n-1,2)=="LP"))
	ileP=ileP+1;
  else
	if (uklad.substr(n-1,2)=="PP")
	  ileP=ileP+2;
  prawo[n+1]=ileP;
  
//cout << uklad.substr(mrowki-n-1,2) << "+" << endl;  

  if ((uklad.substr(mrowki-n-1,2)=="PL") or (uklad.substr(mrowki-n-1,2)=="LP"))
	ileL=ileL+1;
  else
	if (uklad.substr(mrowki-n-1,2)=="LL")
	  ileL=ileL+2;
  lewo[mrowki-n]=ileL;  
}

//for (int n=1; n<=mrowki; n++)
//  cout << prawo[n] << " ";
//cout << endl;
//for (int n=1; n<=mrowki; n++)
//  cout << lewo[n] << " ";
//cout << endl;
	
for (int n=1; n<=mrowki; n++)
  cout << min(lewo[n],prawo[n]) << " ";

return 0;

}