Codeforces Round 1025 (Div. 2)
E
Binary String Wowee
Codeforces
2400
原题
← DF →
翻译中…

Mouf is bored with themes, so he decided not to use any themes for this problem.

翻译中…

You are given a binary$^{\text{∗}}$ string $s$ of length $n$. You are to perform the following operation exactly $k$ times:

翻译中…
  • select an index $i$ ($1 \le i \le n$) such that $s_i = \mathtt{0}$;
  • then flip$^{\text{†}}$ each $s_j$ for all indices $j$ ($1 \le j \le i$).
翻译中…

You need to count the number of possible ways to perform all $k$ operations.

翻译中…

Since the answer could be ginormous, print it modulo $998\,244\,353$.

翻译中…

Two sequences of operations are considered different if they differ in the index selected at any step.

翻译中…

$^{\text{∗}}$A binary string is a string that consists only of the characters $\mathtt{0}$ and $\mathtt{1}$.$^{\text{†}}$Flipping a binary character is changing it from $\mathtt{0}$ to $\mathtt{1}$ or vice versa.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 100$). The description of the test cases follows.

翻译中…

The first line of each test case contains two integers $n$ and $k$ ($1 \le k \le n \le 500$) — the length of the binary string $s$ and the number of times the operation must be performed, respectively.

翻译中…

The second line of each test case contains a binary string $s$ of length $n$ consisting of only characters $\mathtt{0}$ and $\mathtt{1}$.

翻译中…

It is guaranteed that the sum of $n$ does not exceed $500$ over all test cases.

翻译中…

Output

翻译中…

For each test case, output a single integer — the number of ways you can perform exactly $k$ operations, modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first test case, here are all the possible sequences of operations:

翻译中…
  • $\mathtt{\color{red}{0}10} \xrightarrow{i = 1} \mathtt{110}$
  • $\mathtt{\color{red}{010}} \xrightarrow{i = 3} \mathtt{101}$
翻译中…

In the second test case, here are all the possible sequences of operations:

翻译中…
  • $\mathtt{\color{red}{0}00} \xrightarrow{i = 1} \mathtt{\color{red}{1}00} \xrightarrow{i = 2} \mathtt{010}$
  • $\mathtt{\color{red}{0}00} \xrightarrow{i = 1} \mathtt{\color{red}{1}00} \xrightarrow{i = 3} \mathtt{011}$
  • $\mathtt{\color{red}{00}0} \xrightarrow{i = 2} \mathtt{\color{red}{11}0} \xrightarrow{i = 3} \mathtt{001}$
翻译中…

样例

Input #1
5
3 1
010
3 2
000
5 4
01001
8 8
11001100
20 20
10010110101101010110
Output #1
2
3
10
27286
915530405
InputCopy OutputCopy
题目信息
题号
2109E
时间限制
2 s
内存限制
256 MB
标签
组合数学
动态规划
字符串

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