AtCoder Regular Contest 150
E
Weathercock
AtCoder
⌀ 3466
原题
← DF →
翻译中…

Problem Statement

翻译中…

$NK$ people are standing in a line from left to right. Let us denote them as person $i$ $(0\leq i \leq NK-1)$ from left to right.

翻译中…

Each person is always facing either left or right. The direction of each person at time $t=0$ is represented by a string of length $N$, $S=S_0 S_1 \dots S_{N-1}$, consisting of L and R. At time $t=0$, person $i$ is facing left if $S_{i \bmod N}$ is L, and right if it is R.

翻译中…

At time $t=0.5,\ 1.5,\ 2.5 ,\ \dots$, these people simultaneously change their directions according to the following rules.

翻译中…
  • When a person is facing left: If there are one or more people in the direction the person is facing, and more than half of those people are facing right, the person changes direction and faces right. Otherwise, the person does not change direction.
  • When a person is facing right: If there are one or more people in the direction the person is facing, and more than half of those people are facing left, the person changes direction and faces left. Otherwise, the person does not change direction.
翻译中…

Find the sum, modulo $998244353$, of the numbers of times the $NK$ people change direction from time $t=0$ to $t=10^{100}$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq K \leq 2 \times 10^5$
  • $S$ is a string of length $N$ consisting of L and R.
  • All numerical values in the input are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N K
S

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
7 1
RRLRLLL
Output #1
9
If we represent the directions of the seven people at each time, we have `LLRLRRL` at $t=1$, `LLRLRLL` at $t=2$, and `LLLLLLL` at $t=3$. After $t=3$, the directions of the seven people do not change. Therefore, the answer is $1+1+2+1+2+2+0=9$.
Input #2
4 10
LLRR
Output #2
0
Input #3
23 200
RLRRRLLLLLLLLRRRLLRLRRR
Output #3
2207
题目信息
题号
arc150_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。