Daegu Ilgwa Science High School
Time limit1sMemory limit1024 MB
Count monotone lattice paths in d dimensions from (1,...,1) to (N,...,N) that visit P given points in order, modulo 1e9+7.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
Daegu Ilgwa Science High School is a high school in Daegu Metropolitan City, located in -dimensional space. Graduating seniors must move out of their dormitories after the college entrance exam and commute to school. Seojin is a third-year student, so Seojin is worried about the commute and decided to look for a route. The walk from Seojin's home to the school must follow a special rule.
If Seojin is at , Seojin can move to one of these positions: , , , , . On the way from home to school, Seojin found points that must be passed. These points must be passed in the given order. No point is repeated, and no point is at the same position as Seojin's home or the school.
Seojin's home is at , and the school is at . Here, and for every . Find the number of ways to move from home to the school, modulo .
Input
The first line contains , , and , separated by spaces. From the second line on, the lines each contain the coordinates of a point, , separated by spaces.
Output
Print the answer on the first line.
Constraints
- (, )
- (, )
- All numbers in the input are integers.