This page is still under construction.

Parts of this page are still being built. What you see may change.

Independent Set

Time limit2sMemory limit512 MB

Summary
Count vectors of n nonnegative integers summing to m where positions flagged by a and parent-child pairs in the implicit binary heap cannot both be positive, modulo 1e9+7.
Level

Hard8 of 10

Topics
Dynamic programming, Tree, Combinatorics, Math
Solved
No attempts yet

Problem

Bobo has a binary sequence a1a2…ana_1 a_2 \dots a_n. He wants to count the number of sequences x1,x2,…,xnx_1, x_2, \dots, x_n satisfying the following conditions modulo (109+7)(10^9+7).

  1. x1,x2,…,xn∈N0x_1, x_2, \dots, x_n \in \mathbb{N}^0, x1+x2+⋯+xn=mx_1 + x_2 + \dots + x_n = m;
  2. For all 1≤i≤n1 \leq i \leq n, ai⋅xi=0a_i \cdot x_i = 0;
  3. For all 2≤i≤n2 \leq i \leq n, x⌊i/2⌋⋅xi=0x_{\lfloor i / 2 \rfloor} \cdot x_i = 0.

Input

The first line contains 22 integers n,mn, m (1≤n≤5000000,1≤m≤101 \leq n \leq 5000000, 1 \leq m \leq 10).

The second line contains nn integers a1a2…ana_1 a_2 \dots a_n (0≤ai≤10 \leq a_i \leq 1).

Output

A single number denotes the number of sequence.

Examples2

  1. Example 1

    Input
    2 2
    00
    
    Expected output
    2
    
  2. Example 2

    Input
    10 3
    0101010101
    
    Expected output
    26