#P10066. [CCO 2023] Binaria

[CCO 2023] Binaria

Problem Description

You have been hired by the Cheap Communication Organization (CCO) to research a breakthrough communication technology: Submessage Sums (SMS). The revolutionary idea is as follows.

Given a binary string of length NN and a positive integer KK with KNK \leq N, the SMS of the string consists of NK+1N-K+1 integers. The first number in the sequence is the sum of the first KK bits, the second number is the sum of bits 22 through K+1K+1, and so on. The last number is the sum of bits NK+1N-K+1 through NN.

For example, if K=4K=4, then the SMS of the binary string 110010110010 is 2,2,12,2,1. This is because 1+1+0+0=21+1+0+0=2, 1+0+0+1=21+0+0+1=2, and 0+0+1+0=10+0+1+0=1.

Since you are a beginner, your job is not to find the original binary string from a given SMS, but to find the number of binary strings that could produce this SMS.

Input Format

The first line contains two integers NN and KK, separated by spaces.

The second line contains NK+1N-K+1 integers separated by spaces. It is guaranteed that this sequence is the SMS of at least one binary string.

Output Format

Output Tmod(106+3)T \bmod (10^{6}+3), where TT is the positive integer equal to the total number of binary strings that correspond to the given SMS.

7 4
3 2 2 2
3

Hint

Possible strings of length 77 are 10110011011001, 11010101101010, and 11100111110011.

For all testdata, 1N1061 \leq N \leq 10^6 and 1KN1 \leq K \leq N.

Subtask ID Score Range of NN Range of KK
1 12 1N101 \leq N \leq 10 K3K \leq 3
2 None
3 16 1N10001 \leq N \leq 1000 K10K \leq 10
4 1N1061 \leq N \leq 10^{6} K20K \leq 20
5 K3000K \leq 3000
6 28 None

Translated by ChatGPT 5