Array Initialization
Time limit2sMemory limit512 MB
Count ordered sequences of M interval marks on an array of length N whose union covers every position, modulo 1e9+7.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Combinatorics, Intervals, Math
- Solved
- No attempts yet
Problem
Many programming languages have functions that fill an entire array, or part of it, with a given value. In Pascal this is fillchar(), in Java it is Arrays.fill(), and in C++ it is memset(). The new programming language J# has a function mark() that works only with boolean arrays.
Called with two parameters and , mark assigns true to every element of the array with index from to inclusive. For example, take an array of length 4 whose elements are numbered from one and whose values are all initially false. Running mark(1, 3) and then mark(2, 4) on it fills the whole array with true.
One of the first assignments for people starting to learn J# is to write a program that contains exactly mark operations and completely fills an array of length , initially filled with false, with true.
You solved this assignment quickly, and now you wonder: in how many different ways can this be done? Two programs are considered different if the -th mark operation is run with different parameters in them for at least one from 1 to . This number can be large, so you need to compute it modulo .
Input
The first line of the input file contains two positive integers and : the length of the array and the number of mark operations the program must contain. ()
Output
In a single line of the output file, print the remainder modulo of the number of ways to fill an array of elements with true using calls of the mark operation.
Hint
The required variants:
mark(1, 1); mark(1, 2)mark(1, 1); mark(2, 2)mark(1, 2); mark(1, 1)mark(1, 2); mark(1, 2)mark(1, 2); mark(2, 2)mark(2, 2); mark(1, 1)mark(2, 2); mark(1, 2)