|
||||||||||
Shortest pathTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1105 Accepted Submission(s): 243 Problem Description There are N cities (marked by 1, 2, ´, N) and M bidirectional roads in the kingdom. There may be several roads between any two cities, but there is not any road connects the same city. Your task is to find a shortest path from city 1 to city N, and the lengths of the edges you passed by must be strictly in increasing order. Input There is an integer T (1 <= T <= 500) in the first line, indicates that there are T test cases in total. For each test case, there are two integers N (2 <= N <= 10000) and M (1 <= M <= 50000), which have the same meaning as above. Then there are M lines, and there are three integers x (1 <= x <= N), y (1 <= y <= N), and z (1 <= z <= 10000000) in each line, indicate there is a bidirectional road between city x and city y. There are at most ten test cases that satisfy that N > 200 or M > 1000. Output For each test case, you should output the length of the shortest path you find in the above task. If such path does not exist, you should just output ^No answer ̄ (without quotation mark) instead. Sample Input
Sample Output
Source | ||||||||||
|