#P16506. [GKS 2015 #B] Travel
[GKS 2015 #B] Travel
题目描述
There are cities in Chelsea's state (numbered starting from 1, which is Chelsea's city), and bidirectional roads directly connect them. (A pair of cities may even be directly connected by more than one road.) Because of changes in traffic patterns, it may take different amounts of time to use a road at different times of day, depending on when the journey starts. (However, the direction traveled on the road does not matter -- traffic is always equally bad in both directions!) All trips on a road start (and end) exactly on the hour, and a trip on one road can be started instantaneously after finishing a trip on another road.
Chelsea loves to travel and is deciding where to go for her winter holiday trip. She wonders how quickly she can get from her city to various other destination cities, depending on what time she leaves her city. (Her route to her destination may include other intermediate cities on the way.) Can you answer all of her questions?
输入格式
The first line of the input gives the number of test cases, . test cases follow.
The first line of each test case contains three integers: the number of cities, the number of roads, and the number of Chelsea's questions.
lines -- pairs of two lines -- follow. In each pair, the first line contains two different integers x and y that describe one bidirectional road between the x-th city and the y-th city. The second line contains 24 integers () that indicate the time cost, in hours, to use the road when departing at t o'clock on that road. It is guaranteed that () and .
Then, an additional lines follow. Each contains two integers and that comprise a question: what is the fewest number of hours it will take to get from city 1 to city , if Chelsea departs city 1 at o'clock?
输出格式
For each test case, output one line containing "Case #x: ", where x is the case number (starting from 1), followed by distinct space-separated integers that are the answers to the questions, in order. If Chelsea cannot reach the destination city for a question, no matter which roads she takes, then output for that question.
3
3 3 2
1 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
2 3
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 1
3 3
3 1 2
1 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2 2
3 4
3 3 3
1 2
7 23 23 25 26 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8
1 3
10 11 15 26 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11
2 3
7 29 28 27 26 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8
2 14
3 3
3 21
Case #1: 1 2
Case #2: 1 -1
Case #3: 17 26 13
提示
Limits
.
all Cost values .
.
.
Small dataset (Test Set 1 - Visible)
.
.
.
.
Large dataset (Test Set 2 - Hidden)
.
.
.
.