Every spring, the trail-running guild of Fennwick charts the great relay between the clubhouse at station 1 and the summit lodge at station n. The n stations are joined by m two-way trails, trail i linking stations u_i and v_i with a running time of w_i seconds, and the trail map keeps every station reachable from every other.
A relay route starts at station 1, ends at station n, and may pass through any stations and trails along the way — runners are even allowed to double back and reuse a trail or revisit a station if they wish. The total time of a route is the sum of the running times of every trail crossing made, counted once per crossing.
The guild's champion already holds the record for the fastest possible total time. To keep the rivalry alive, the vice-champion wants to chase a different mark: the smallest total time that is strictly greater than the fastest possible time.
Given the trail map, find that runner-up time — the second-smallest distinct total time over all possible relay routes from station 1 to station n.
Function Description Implement the function 'findSecondShortestTime'.
Parameters
Returns the second-smallest distinct total time of a route from station 1 to station n.
Input Format
Output Format
Sample Case
Sample Input 1 4 4 1 2 3 2 4 4 1 3 2 3 4 6
Sample Output 1 8
Explanation Routes from station 1 to station 4 and their total times:
The fastest time is 7. Among all total times {7, 8, 13, ...}, the smallest value strictly greater than 7 is 8.
Note: Your code must be able to print the sample output from the provided sample input. However, your code is run against multiple hidden test cases. Therefore, your code must pass these hidden test cases to solve the problem statement.
Limits Time Limit: 5.0 sec(s) for each input file.