|| ||Code Submission Evaluation System
CSES Problem Set
Task | Statistics
CSES - Grid PathsCSES - Grid Paths
|Time limit:||1.00 s
||Memory limit:||512 MB|
Consider an $n \times n$ grid whose top-left square is $(1,1)$ and bottom-right square is $(n,n)$.
Your task is to move from the top-left square to the bottom-right square. On each step you may move one square right or down. In addition, there are $m$ traps in the grid. You cannot move to a square which has a trap.
What is the total number of possible paths?
The first input line contains two integers $n$ and $m$: the size of the grid and the number of traps.
After this, there are $m$ lines that describe the traps. Each such line contains two integers $y$ and $x$: the location of a trap.
You can assume that there are no traps in the top-left and bottom-right square.
Print the number of paths modulo $10^9+7$.
- $1 \le n \le 10^6$
- $1 \le m \le 1000$
- $1 \le y,x \le n$