#P5480. [BJOI2015] 回家的路【征集spj】

    ID: 4434 远端评测题 2000ms 500MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2015各省省选北京Special JudgeO2优化

[BJOI2015] 回家的路【征集spj】

Description

Xiaoqiang and Amoeba are good friends. Connecting Beijing and Xiaoqiang's hometown is a complicated railway network. There are  N ~N~ stations in total, and between stations there are undirected railways of different lengths. Each time Xiaoqiang goes home, he randomly chooses one path among all shortest paths.

There is a railway in front of Amoeba's house. Without changing the shortest-path distance from Beijing to Xiaoqiang's hometown, Amoeba wants to add one directed railway of length  K ~K~ to the network, so that the probability that Xiaoqiang passes through the railway in front of Amoeba's house is as large as possible. Please output this maximum probability.

Constraints

 3N100000,M400000,1s,K10000 ~3\leq N\leq 100000,M\leq 400000,1\leq s,K≤10000~. It is guaranteed that no matter how you add the edge, the number of shortest paths between any two nodes in the graph will not exceed 216000 2^{16000}~.

Input Format

The first line contains three positive integers  N,M ~N,M~ and  K ~K~, representing the number of stations, the number of railways, and the length of the new railway. Stations are numbered from  1 ~1~ to  N ~N~. Beijing is node  1 ~1~, and Xiaoqiang's hometown is node  N ~N~.

The next  M ~M~ lines each contain three positive integers  u,v,s ~u,v,s~, indicating an undirected railway connecting stations  u ~u~ and  v ~v~ with length  s ~s~.

The first of these  M ~M~ lines describes the railway in front of Amoeba's house. There may be multiple railways between the same pair of nodes. It is also possible that  u=v ~u=v~, i.e., a self-loop. The new railway you build may overlap an existing railway, and it may also be a self-loop. Nodes  1 ~1~ and  N ~N~ are guaranteed to be connected.

Output Format

Output one line with two positive integers  A,B ~A,B~, meaning that you build a directed railway from  A ~A~ to  B ~B~. Your construction is accepted if the difference between the probability that Xiaoqiang passes through the target railway under your plan and the standard answer is at most 10610^{-6}.

// Note: This problem lacks an spjspj, so please submit with caution.

3 3 1
1 2 1
2 3 1
1 3 2
2 3

Hint

After adding an edge, there are  3 ~3~ shortest paths in total. The probability that Xiaoqiang passes in front of Amoeba's house changes from  1/2 ~1/2~ to  2/3 ~2/3~.

Translated by ChatGPT 5