10304: CF EDU - DSU - Step 2 - F. Dense spanning tree
[Creator : ]
Description
You need to find a spanning tree in the graph so that the difference between the maximal and the minimal edges is minimal.
Input
The first line of the input contains two integers $n,m\ (2 ≤n≤ 1000,\ 0 ≤m≤ 10,000)$ — the number of vertices and the number of edges, respectively.
Next $m$ lines contain the desc
Output
If the spanning tree exists, then the first line of the output should contain "YES", and the second line should contain one integer — the minimal difference between the maximal and the minimal edges of the spanning tree.
Otherwise, the sole line of the output should contain "NO".
Sample 1 Input
4 5
1 2 1
1 3 2
1 4 1
3 2 2
3 4 2
Sample 1 Output
YES
0