1790.
Two Paths
时间限制 2000 ms
内存限制 150 MB
You are given a undirected graph with n nodes (numbered from 1 to n) and m edges. Alice and Bob are now trying to play a game.
Both of them will take different route from 1 to n (not necessary simple).
Alice always moves first and she is so clever that take one of the shortest path from 1 to n.
Now is the Bob's turn. Help Bob to take possible shortest route from 1 to n.
There's neither multiple edges nor self-loops.
Two paths S and T are considered different if and only if there is an integer i, so that the i-th edge of S is not the same as the i-th edge of T or one of them doesn't exist.
输入数据
输出数据
For each test case print length of valid shortest path in one line.
样例输入
复制
2
3 3
1 2 1
2 3 4
1 3 3
2 1
1 2 1
\n
· \n
· · \n
· · \n
· · \n
· \n
· · \n
样例说明
For testcase 1, Alice take path 1 - 3 and its length is 3, and then Bob will take path 1 - 2 - 3 and its length is 5.
For testcase 2, Bob will take route 1 - 2 - 1 - 2 and its length is 3