F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Harry Potter and the Present II

Time 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
2 2 1 2 0 1 1 0 1 1 2 2 1 2 0 1 2 0 1 1 2
 

Sample Output
Case 1: 0 Case 2: 1
 

Hint
If you can¡¯t figure out the sample, think twice whether you have forgotten someone named Harry Potter.
 

Author
iSea@WHU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-26 20:07:35, Gzip enabled