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
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>

int main()
{
    std::ios_base::sync_with_stdio(false);
    int n;
    std::string s;
    std::cin>>n>>s;
    std::vector<int> moves(n,0);
    bool f = true;
    while(not std::is_sorted(s.begin(), s.end()))
    {
    for(int i =0;i<s.size()-1;++i)
    {
      if(s[i] == 'P' and s[i+1] == 'L')
      {
          ++moves[i];
          ++moves[i+1];
          s[i]='L';
          s[i+1]='P';
          ++i;
      }
    }
    }
    for(const auto& m:moves) std::cout<<m<<" ";
    return 0;
}