#P1547. [USACO05MAR] Out of Hay S

    ID: 535 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>图论贪心2005USACO并查集生成树连通块

[USACO05MAR] Out of Hay S

Description

Bessie plans to survey the hay situation of NN (2N20002 \leq N \leq 2\,000) farms, starting from farm 11. There are MM (1M1041 \leq M \leq 10^4) bidirectional roads in total, and the total length of all roads does not exceed 10910^9. There may be multiple roads between some pairs of farms, and all farms are connected.

Bessie wants to compute the length of the longest edge in a minimum spanning tree of this graph.

Input Format

The first line contains two integers N,MN, M.

Each of the next MM lines contains three space-separated integers Ai,Bi,LiA_i, B_i, L_i, indicating there is a road between AiA_i and BiB_i with length LiL_i.

Output Format

Output a single integer, the length of the longest edge in the minimum spanning tree.

3 3
1 2 23
2 3 1000
1 3 43
43

Hint

Translated by ChatGPT 5