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
80
81
82
83
84
85
86
87
88
89
90
91
92
/*#ifdef _MSC_VER
  #ifndef __GNUC__
    #pragma warning(disable: 4996)
  #endif
  #define main main0
#endif  //*/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long           ll;
typedef unsigned long long ull;
typedef unsigned int      uint;

/*const int LL = 'L' << 8 + 'L';
const int LP = 'L' << 8 + 'P';
const int PL = 'P' << 8 + 'L';
const int PP = 'P' << 8 + 'P';//*/

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

  int n/*, odbic = 0*/;
  uint n_1;
  string slowo;
  vector<int> odbicia;

  cin >> n >> slowo;
  n_1 = n - 1;
  odbicia.resize(n);
  odbicia[0] = slowo[0] == 'L'? 0 : 1;
  for(uint i = 0; i < n_1; ++i) {
    if(slowo[i] == 'L') {
      if(slowo[i+1] == 'L')
        odbicia[i+1] = odbicia[i];
      else                          // odbicia[i+1] == 'P'
        odbicia[i+1] = odbicia[i] + 1;
    } else {                        // odbicia[i] == 'P'
      if(slowo[i+1] == 'L')
        odbicia[i+1] = odbicia[i] + 1;
      else                          // odbicia[i+1] == 'P'
        odbicia[i+1] = odbicia[i] + 2;
    }
  }
  if(odbicia[n_1] > 0)
    odbicia[n_1] = slowo[n_1] == 'P'? 0 : 1;
  for(uint i = n_1; i > 0; --i) {
    int tmp;
    if(slowo[i] == 'P') {
      if(slowo[i-1] == 'P')
        tmp = odbicia[i];
      else                          // odbicia[i-1] == 'L'
        tmp = odbicia[i] + 1;
      } else {                        // odbicia[i] == 'L'
        if(slowo[i-1] == 'P')
          tmp = odbicia[i] + 1;
        else                          // odbicia[i-1] == 'L'
          tmp = odbicia[i] + 2;
      }
    if(tmp > odbicia[i-1])
      break;
    odbicia[i-1] = tmp;
  }
/*  for(; ; ) {
    int odbic1 = odbic;
    if(slowo[i] == 'L') {
      while(++i < j && slowo[i] == 'L')
        odbicia[i] = odbic1;
    }
    int zmiana = slowo[i] << 8 + slowo[i+1];
    switch(zmiana) {
    case LL:
      break;
    case LP:
      odbic1 += 2;
      break;
    case PL:
      break;
    case PP:
      break;
    default:
      ++odbic1;
    }
  }//*/

  for(uint i = 0; i < n_1; ++i)
    cout << odbicia[i] << ' ';
  cout << odbicia[n_1] << endl;

  return 0;
}