Post OfficeProblem code: POST |
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:
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.
Output:
For each test case, output a line containing the number of shortest paths to the post office, modulo 1000000037.
Sample input:
3 2 2 1 1 1 1 1 2 0 1 1 0 7 1 2 1 0 4 1
Sample output:
2 0 6
Constraints
1<=T<=30
1<=W,H<=107
0<=xi<=W
0<=yi<=H
0<=N<=max(100,min(W,H,1000))
| Author: | pieguy |
| Date Added: | 7-07-2010 |
| Time Limit: | 10 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

What is the meaning of second