No.2524 Stripes
タグ : / 解いたユーザー数 44
作問者 :
MasKoaTS
fky_
Problem Statement
There are $N$ balls. The integer $i$ is written on the $i$-th ball.
Each ball is painted in exactly one of two colors, red or blue, and this information is represented by a string $S$. Specifically, if the $i$-th character of $S$ is R, the $i$-th ball is painted red, and if it is B, it is painted blue.
For $i = 1, \dots, N$ in this order, solve the following problem.
- Find the number, modulo $998244353$, of ways to choose $i$ balls from the $N$ balls such that, when the chosen balls are arranged in a row in ascending order of the integers written on them, the colors alternate, that is, no two adjacent balls have the same color.
Constraints
- $N$ is an integer
- $1 \leq N \leq 10^5$
- $S$ is a string of length $N$ consisting only of
RandB
Input
The input is given from standard input. Each test case is given in the following format.
$N$ $S$
Output
Output $N$ lines. On the $k$-th line, output the answer for $i = k$.
Sample
Sample 1
Input
4 RRBR
Output
4 3 2 0
$i = 1$ : There are $4$ ways to choose $1$ ball from the $4$ balls. All of them satisfy the condition in the problem statement.
$i = 2$ : There are $6$ ways to choose $2$ balls from the $4$ balls. Among them, the $3$ ways $(1,3),(2,3),(3,4)$ satisfy the condition.
Choosing $(1,2)$ does not satisfy the condition, because when the balls are arranged in ascending order of their numbers, the colors are RR, which do not alternate.
$i = 3$ : The $2$ ways $(1, 3, 4), (2, 3, 4)$ satisfy the condition.
$i = 4$ : No way satisfies the condition.
Sample 2
Input
2 BB
Output
2 0
Sample 3
Input
10 RBRRBBRBRR
Output
10 24 40 35 34 12 8 0 0 0
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。