#P11487. Subsequence Prefix Sum

    ID: 13571 Type: Default 1000ms 256MiB

Subsequence Prefix Sum

Subsequence Prefix Sum

We are given two integers (n) and (m) and a binary string (S) of length (n+m). For any binary string (T) consisting exactly of (n) ones and (m) zeros, define (f(T)) as the length of the longest prefix of (S) that is a subsequence of (T). (Recall that a sequence (X) is a subsequence of (Y) if by deleting zero or more characters from (Y) one can obtain (X); note that the empty string is a subsequence of every string.)

For example, if (S = 10) and (T = 01) then by the greedy matching algorithm we can match only the first character of (S) (after skipping the initial mismatch), so (f(T)=1).

Your task is to compute the sum (\sum_T f(T)) over all binary strings (T) that have exactly (n) ones and (m) zeros. Since the answer can be very large, output it modulo (2933256077) (a prime number).

A few remarks:

(\dagger) A subsequence is not necessarily contiguous.

(\ddagger) The modulus is a prime number.

inputFormat

The input consists of two lines. The first line contains two integers (n) and (m). The second line contains the binary string (S) of length (n+m).

outputFormat

Output a single integer, the sum of (f(T)) over all binary strings (T) with exactly (n) ones and (m) zeros, taken modulo (2933256077).

sample

1 1
10
3

</p>