#P2299. Mzc和体委的争夺战

Mzc和体委的争夺战

Description

mzc is very rich (just kidding). He has nn male servants (those who did the first three installments know this). But such a large number of male servants attracted our PE monitor (a short, chubby fellow), who wants to compete with mzc for them.

mzc is very angry and decides to duel him, but cat's stamina is indeed somewhat unstable, so he needs you to help him calculate the minimum required time.

Input Format

The first line contains two numbers n,mn, m. nn means there are nn stops, and mm means there are mm roads.

Then follow mm lines, each with three numbers ai,bi,cia_i, b_i, c_i, meaning that it takes cic_i time to go from stop aia_i to stop bib_i. Note that the edges are bidirectional. That is, it also takes cic_i time to go from stop bib_i to stop aia_i.

Output Format

Output one line: the shortest time from 11 to nn.

5 8
1 2 3
2 3 4
3 4 5
4 5 6
1 3 4
2 4 7
2 5 8
1 5 100

11

Hint

Constraints: 1n25001 \le n \le 2500, 1m2×1051 \le m \le 2 \times 10^5, 1ci1061 \le c_i \le 10^6.

Time limit: 11 s.

Translated by ChatGPT 5