#P1339. [USACO09OCT] Heat Wave G

    ID: 336 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>图论2009USACO福建省历届夏令营最短路

[USACO09OCT] Heat Wave G

Description

Given an undirected graph with nn vertices and mm edges, find the length of the shortest path from ss to tt.

Input Format

The first line contains four positive integers n,m,s,tn, m, s, t.
The next mm lines each contain three positive integers u,v,wu, v, w, indicating an edge connecting uu and vv with length ww.

Output Format

Output one line containing a single integer, the answer.

7 11 5 4
2 4 2
1 4 3
7 2 2
3 4 3
5 7 5
7 3 3
6 1 1
6 3 4
2 4 3
5 6 3
7 2 1
7

Hint

Constraints
For 100%100\% of the testdata, 1n25001 \le n \le 2500, 1m62001 \le m \le 6200, 1w10001 \le w \le 1000.

Sample Explanation
56145 \to 6 \to 1 \to 4 is the shortest path, with length 3+1+3=73+1+3 = 7.

Translated by ChatGPT 5