#P2685. [TJOI2012] 桥

[TJOI2012] 桥

Description

There are nn islands and mm bridges. Each bridge connects two islands. There are some enemies on every bridge; the player can pass a bridge only after defeating the enemies on it, and doing so inflicts some damage to the player. There is also a big Boss guarding exactly one bridge, which is impassable for the player given their current ability. The Boss is evil and will choose a bridge to guard so that, after blocking that bridge, the minimum possible total damage the player must suffer to travel from island 11 to island nn (of course the player will choose the path with the least damage) is as large as possible. Determine which bridges the Boss might guard.

Note: multiple edges and self-loops are allowed.

Input Format

The first line contains two integers n,mn, m.

The next mm lines each contain three integers s,t,cs, t, c, indicating that the enemies on the bridge connecting islands ss and tt will inflict cc damage on the player.

Output Format

One line with two integers d,cntd, cnt, where dd is the minimum damage the player must suffer in the presence of the Boss, and cntcnt is the number of bridges that the Boss might guard.

3 4
1 2 1
1 2 2
2 3 1
2 3 2
3 2

Hint

  • For 30%30\% of the testdata, 1n10001 \le n \le 1000.
  • For 100%100\% of the testdata, 1n1000001 \le n \le 100000, 1m2000001 \le m \le 200000, 1c100001 \le c \le 10000.
  • It is guaranteed that the player can reach island nn from island 11.

Translated by ChatGPT 5