#P4234. 最小差值生成树
最小差值生成树
Description
Given an undirected graph with vertices labeled from to and edges, find a spanning tree that minimizes the difference between the maximum and minimum edge weights in the tree. The graph may contain self-loops.
Input Format
The first line contains two integers, the number of vertices and the number of edges .
Then follow lines. Each line contains three integers , indicating there is an edge between and with weight .
Output Format
Output a single integer on one line, which is the answer.
4 6
1 2 10
1 3 100
1 4 90
2 3 20
2 4 80
3 4 40
20
Hint
Constraints and Conventions
- For of the testdata, it is guaranteed that , .
- For of the testdata, it is guaranteed that , .
- For of the testdata, it is guaranteed that , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号