Codeforces Round 1053 (Div. 1)
G
Counting Is Fun: The Finale
Codeforces
3500
原题
← F→
翻译中…

You are given three positive integers $x$, $y$, and $k$.

翻译中…

You are also given a binary string$^{\text{∗}}$ $a$ ($|a| = x + y$).

翻译中…

Count the number of binary strings $b$, modulo $998\,244\,353$, such that:

翻译中…
  • there are exactly $x$ $\mathtt{0}$ in $b$.
  • there are exactly $y$ $\mathtt{1}$ in $b$.
  • there exists an integer $i$ ($1 \leq i \leq x + y - 1$) such that $\min \left( f(b_1 b_2 \ldots b_i), f(b_{i+1} b_{i+2} \ldots b_{x+y})\right) \geq k$, where $f(s)$ gives the length of the longest non-decreasing subsequence$^{\text{†}}$ in $s$.
  • $b$ is lexicographically larger$^{\text{‡}}$ than $a$.
翻译中…

$^{\text{∗}}$A binary string is a string that only consists of characters $\mathtt{0}$ and $\mathtt{1}$.$^{\text{†}}$A sequence $a$ is a subsequence of a sequence $b$ if $a$ can be obtained from $b$ by the deletion of several (possibly, zero or all) elements. For example, subsequences of $\mathtt{1011101}$ are $\mathtt{0}$, $\mathtt{1}$, $\mathtt{11111}$, $\mathtt{0111}$, but not $\mathtt{000}$ nor $\mathtt{11100}$.$^{\text{‡}}$A string $p$ is lexicographically larger than another string $q$ if and only if one of the following holds: $q$ is a prefix of $p$, but $p \ne q$; or in the first position where $p$ and $q$ differ, the string $p$ has a larger element than the corresponding element in $q$.

翻译中…

Input

翻译中…

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

翻译中…

The first line of each test case contains three integers $x$, $y$, and $k$ ($1 \le x, y \le 5000$, $1 \leq k \lt x + y$).

翻译中…

The second line of each test case contains a binary string $a$ ($|a| = x+y$) consisting of characters $\mathtt{0}$ and $\mathtt{1}$.

翻译中…

It is guaranteed that neither the sum of $x$ nor the sum of $y$ over all test cases exceeds $5000$.

翻译中…

Output

翻译中…

For each test case, output an integer on a new line, the number of binary strings that satisfy the conditions modulo $998\,244\,353$.

翻译中…

Note

翻译中…

For the first test case, there are two valid strings: $\mathtt{01}$ and $\mathtt{10}$.

翻译中…

For the third test case, there are four valid strings: $\mathtt{0110}$, $\mathtt{1001}$, $\mathtt{1010}$, and $\mathtt{1100}$.

翻译中…

样例

Input #1
6
1 1 1
00
2 2 2
1110
2 2 1
0101
1 6 3
0000000
4 6 4
0010110010
10 6 7
0010110000101100
Output #1
2
0
4
7
106
203
InputCopy OutputCopy
题目信息
题号
2150G
时间限制
5 s
内存限制
1024 MB
标签
组合数学
模拟

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