#P16157. [ICPC 2016 NAIPC] K-Inversions

[ICPC 2016 NAIPC] K-Inversions

题目描述

You are given a string ss consisting only of upper case letters A and B. For an integer kk, a pair of indices ii and jj (1i<jn1 \leq i < j \leq n) is called a kk-inversion if and only if s[i]=Bs[i] = \text{B}, s[j]=As[j] = \text{A} and ji=kj - i = k.

Consider the string BABA. It has two 1-inversions and one 3-inversion. It has no 2-inversions.

:::align{center} :::

For each kk between 11 and n1n-1 (inclusive), print the number of kk-inversions in the string ss.

输入格式

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The input will consist of a single line with a string ss, which consists of only upper case As and Bs. The string ss will be between 11 and 1,000,0001,000,000 characters long. There will be no spaces.

输出格式

Output n1n-1 lines, each with a single integer. The first line’s integer should be the number of 1-inversions, the second should be the number of 2-inversions, and so on.

BABA
2
0
1
BBBBBAAAAA
1
2
3
4
5
4
3
2
1