Canadian Computing Competition: 2012 Stage 2, Day 1, Problem 2
Welcome to the Hungary Games! The streets of Budapest form a twisted network of one-way streets. You have been forced to join a race as part of a "Reality TV" show where you race through these streets, starting at the Szechenyi thermal bath (
Naturally, you want to complete the race as quickly as possible, because you will get more promotional contracts the better you perform. However, there is a catch: any person who is smart enough to take a shortest
Sometimes the strictly second-shortest route visits some nodes more than once; see Sample Input 2 for an example.
Input Specification
The first line will have the format
Output Specification
Output the length of a strictly-second-shortest route from
Limits
Every length
Sample Input 1
4 6
1 2 5
1 3 5
2 3 1
2 4 5
3 4 5
1 4 13
Output for Sample Input 1
11
Explanation for Sample Output 1
There are two shortest routes of length 10 (
Sample Input 2
2 2
1 2 1
2 1 1
Output for Sample Input 2
3
Explanation for Sample Output 2
The shortest route is
Comments
Is it guaranteed that there exists an s-t path?
This comment is hidden due to too much negative feedback. Show it anyway.
That problem uses an undirected graph, and has a far more strict time limit.