#P11487. 「Cfz Round 5」Gnirts 10

    ID: 10213 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>洛谷原创O2优化组合数学洛谷月赛

「Cfz Round 5」Gnirts 10

Description

Let's keep the problem statement simple.

  • Given n,mn, m, and a binary string SS of length n+mn + m.
  • For a binary string TT, define f(T)f(T) as the length of the longest prefix of SS that is a subsequence ^\dagger of TT.
  • For every binary string TT that contains exactly n\bm n 1\tt 1s and m\bm m 0\tt 0s, compute the sum of f(T)f(T). The answer should be modulo 29332560772933256077^\ddagger.

\dagger: Note that a subsequence does not need to be contiguous. In other words, aa is a subsequence of bb if and only if aa can be obtained by deleting 0\geq 0 characters from bb. Note that the empty string is always a subsequence of any string.

\ddagger: The modulus is a prime number.

Input Format

The first line contains two integers n,mn, m.

The second line contains a binary string SS of length n+mn + m.

Output Format

Output a single integer, representing the result modulo 29332560772933256077.

2 1
000
3
5 5
0010111011
1391

Hint

Sample Explanation #1

The only possible sequence is the common sequence 0\texttt{0}. Since there are exactly 3 different TTs (110,101,011\tt 110, 101, 011), the answer is 1×3=31 \times 3 = 3.

Constraints

For all test cases, it is guaranteed that 1n,m3×1061 \leq n, m \leq 3\times 10^6.

Subtasks are used in this task.

  • Subtask 0 (13 points): max(n,m)5\max(n, m) \leq 5.
  • Subtask 1 (13 points): max(n,m)100\max(n, m) \leq 100.
  • Subtask 2 (34 points): max(n,m)3×103\max(n, m) \leq 3\times 10^3.
  • Subtask 3 (40 points): No further restrictions.