![]() |
||||||||||
|
||||||||||
Harry Potter and the Present IITime Limit: 5000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1954 Accepted Submission(s): 483 Problem Description Harry and his friends buy a lot of presents now, but they immediately find they had bought too many presents, so they decide to distribute them to the magicians who need them. To simplify the problem, here we assume the magic world has N cities and M roads, and there are Q requests, at time Ti, someone at city Pi need a present. After planning the route for a while, Harry realizes he can’t do it by himself, he need to find some friends to help him. But the new question is, how many friends Harry should ask at least? We can assume every magician can choose the original city and time to begin his/her journey, and all of them have the same speed, one unit distance per unit time. And if he/she is exactly in city Pi at time Ti, he/she will give the present in a wink, yes, as you see, they are magicians. ![]() Input The first line contains a single integer T, indicating the number of test cases. Each test case begins with three integers N, M, Q. Then M lines following, each line contains three integers Ai, Bi, Ci, describing an undirected road. Then Q lines following, each line contains two integers Pi, Ti, describing a request. Technical Specification 1. 1 <= T <= 50 2. 1 <= N <= 100 3. 1 <= M, Q <= 1 000 4. 0 <= Ai, Bi, Pi < N, Ai != Bi 5. 0 <= Ci, Ti <= 1 000 000 000 Output For each test case, output the case number first, then the least friend number. Sample Input
Sample Output
Hint If you can’t figure out the sample, think twice whether you have forgotten someone named Harry Potter. Author iSea@WHU Source | ||||||||||
|