Treas .*)
Background
Czy climbed onto the black mangrove tree and reached a strange place ......
Description
Czy found a strange treasure map. There are n vertices on the graph, and m are undirected edges. The distance between two pairs in the graph is marked as Dist. However, czy knows that this treasure map is true only when the figure is just a tree. If the treasure map is true, X, which has the largest Edge Weight mean after vertices x, is the place where the treasure is hidden. Calculate whether this is a real treasure map.
Format
The number t in the first row of the input data indicates the T group of data.
For each group of data, the first line is N, indicating the number of points on the treasure map.
In the next n rows, N numbers in each row indicate the distance between two nodes.
Output one or two rows. The first line "yes" or "no" indicates whether this is a real treasure map.
If it is a real treasure map, output a number in the second line to indicate which point is a treasure map.
Sample Input
2
3
0 7 9
7 0 2
9 2 0
3
0 2 7
2 0 9
7 9 0
Sample output
Yes
1
Yes
3
Example: the shape of the first tree is 1--2--3. The edge weights between 1 and 2 are 7, 2, and 3 are 2.
The shape of the second tree is 2--1--3. The Edge Weight between 2 and 3 is 7.
Data range
For 30% data, n <= 50, 1 <= the length of the edge on the tree <= 10 ^ 9.
For 50% data, n <= 600.
For 100% data, 1 <= n <= 2500, any 0 except 30% small data <= DIST [I] [J] <= 10 ^ 9, T <= 5
Run the minimal spanning tree regardless of whether it is a tree or not to calculate the dist2 Array under the MST condition. If it is a tree, it is clear that dist and dist2 are exactly the same. If they are different, this graph must not be a tree. In addition, Kruskal will be stuck. The second question is: how can this problem be solved in the first question?
Http://www.cnblogs.com/zhber/p/4035894.html
Simulation competition [treasure map]