CF187B AlgoRace
Description
PMP is getting a warrior. He is practicing a lot, but the results are not acceptable yet. This time instead of programming contests, he decided to compete in a car racing to increase the spirit of victory. He decides to choose a competition that also exhibits algorithmic features.
AlgoRace is a special league of car racing where different teams compete in a country of $ n $ cities. Cities are numbered $ 1 $ through $ n $ . Every two distinct cities in the country are connected with one bidirectional road. Each competing team should introduce one driver and a set of cars.
The competition is held in $ r $ rounds. In $ i $ -th round, drivers will start at city $ s_{i} $ and finish at city $ t_{i} $ . Drivers are allowed to change their cars at most $ k_{i} $ times. Changing cars can take place in any city in no time. One car can be used multiple times in one round, but total number of changes should not exceed $ k_{i} $ . Drivers can freely choose their path to destination.
PMP has prepared $ m $ type of purpose-built cars. Beside for PMP’s driving skills, depending on properties of the car and the road, a car traverses each road in each direction in different times.
PMP Warriors wants to devise best strategies of choosing car and roads in each round to maximize the chance of winning the cup. For each round they want to find the minimum time required to finish it.
Input Format
The first line contains three space-separated integers $ n,m,r $ ( $ 2
Output Format
For each round you should print the minimum required time to complete the round in a single line.
Explanation/Hint
In the first sample, in all rounds PMP goes from city #1 to city #2, then city #3 and finally city #4. But the sequences of types of the cars he uses are (1, 2, 1) in the first round and (1, 2, 2) in the second round. In the third round, although he can change his car three times, he uses the same strategy as the first round which only needs two car changes.