1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  string s;
  cin >> n >> s;

  vector<ll> t(n+2);
  for (int i = 1, j = 1; j <= n; i++, j++) {
    while (j <= n && s[j-1] == 'P') j++;
    if (j > n) break;
    t[i] += 1, t[i+1] += 1;
    t[j] -= 1, t[j+1] -=1;
  }

  for (int i = 1; i <= n; i++) {
    cout << (t[i] += t[i-1]) << ' ';
  }
}