Problem F
Random Route
Where do you want to go today, and how do you want to get there? You decide to choose the answer to both questions at random.
You will be given a list of roads. Each road connects one city to another city (all roads are one-way), and each road takes a certain amount of time to drive. You will also be given a starting city. Consider all cities that you’re able to drive to, not including your starting city, and choose one of them at random with uniform probability to be your destination. Now consider every fastest route from your starting city to your destination city, and choose one of these routes at random with uniform probability. This will be the route on which you end up driving.
For each road in the input, your program must output the probability that you will end up driving on that road, given the behavior outlined above.
Input
The first line of input gives the number of cases,
Output
For each test case, output one line containing “Case #
Sample Input 1 | Sample Output 1 |
---|---|
1 5 san_francisco san_francisco los_angeles 6 los_angeles san_diego 2 san_francisco san_diego 8 los_angeles san_diego 2 san_francisco los_angeles 6 |
Case #1: 0.4500000 0.2000000 0.1000000 0.2000000 0.4500000 |