All submissions for this problem are available.
It's the 1st of the month again, which means it's time for Dave to pay his bills.
Dave needs to go to the post office to mail his rent cheque, and wants to take the
shortest route possible. Dave wonders how many different shortest routes he can take.
Dave lives at the southwest corner of town (0,0) and the post office is at the northeast corner of town (W,H).
It takes Dave exactly one minute to move from (x, y) to (x, y+1), (x, y-1), (x+1, y) or (x-1, y).
Dave cannot move further south or west than his house, nor can he move further north or east than the post office
(that is, Dave's x coordinate must stay between 0 and W, and his y coordinate must stay between 0 and H at all times).
Additionally, there are N intersections that are being worked on by construction crews,
and Dave must avoid these intersections.
The number of shortest routes may be very large, so print the result modulo 1000000037.
If it is impossible for Dave to reach the post office, the answer is 0.
Input begins with an integer T, the number of test cases.
Each test case begins with 3 integers W, H, N.
N lines follow, each containing 2 integers (xi, yi), the coordinates of an intersection being worked on by a construction crew.
Intersections are guaranteed to be unique, and neither (0,0) nor (W,H) will be under construction.
A blank line separates each test case.
For each test case, output a line containing the number of shortest paths to the post office, modulo 1000000037.
3 2 2 1 1 1 1 1 2 0 1 1 0 7 1 2 1 0 4 1
2 0 6
|Tags||hard, oct10, pieguy|
|Time Limit:||0.88 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, CPP17, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.