Classification: Graph Theory, Minimum Spanning Tree Author: acshiryu time: 2011729 original question: http://poj.org/problem? Id = 2485 highways
Time limit:1000 ms 

Memory limit:65536 K 
Total submissions:12754 

Accepted:5969 
Description
The island nation of flatopia is perfectly flat. unfortunately, flatopia has no public highways. so the traffic is difficult in flatopia. the flatopian Government is aware of this problem. they're planning to build some highways so that it will be possible to drive between any pair of towns without leaving the highway system.
Flatopian towns are numbered from 1 to n. each highway connects exactly two towns. all highways follow straight lines. all highways can be used in both directions ctions. highways can freely cross each other, but a driver can only switch between highways at a town that is located at the end of both highways.
The flatopian government wants to minimize the length of the longest highway to be built. However, they want to guarantee that every town is highwayreachable from every other town.
Input
The first line of input is an integer T, which tells how many test cases followed.
The first line of each case is an integer N (3 <= n <= 500), which is the number of ages. then come n lines, the Ith of which contains N integers, and the Jth of these N integers is the distance (the distance shocould be an integer within [1, 65536]) between village I and Village J. there is an empty line after each test case.
Output
For each test case, You shocould output a line contains an integer, which is the length of the longest road to be built such that all the ages are connected, and this value is minimum.
Sample Input
130 990 692990 0 179692 179 0
Sample output
692
The question is to find the maximum right edge of the minimal spanning tree. The method is no longer repeated. For details, see the solution report on today's and yesterday's questions. You can see a similar solution to this question, you can directly paste the code and change it to two lines.
1Y
Reference code:
1 # include <iostream>
2 # include <cstdlib>
3 # include <cstdio>
4 # include <cstring>
5 # include <algorithm>
6 # include <cmath>
7 using namespace STD;
8 int map [500] [500];
9 int lowcost [500];
10 const int INF = (1 <20 );
11 int main ()
12 {
13 int N;
14 int T;
15 CIN> T;
16 while (t )
17 {
18 CIN> N;
19 int I, J;
20 For (I = 0; I <n; I ++)
21 For (j = 0; j <n; j ++)
22 CIN> map [I] [J];
23 For (I = 0; I <n; I ++)
24 lowcost [I] = map [0] [I]; // initialize the distance from each point to the set
25 int ans = 0; // record the maximum weight of the Spanning Tree
26 For (I = 0; I <n1; I ++)
27 {
28 int mindis = inf;
29 int minone;
30 For (j = 0; j <n; j ++)
31 {// find the closest point of the Set
32 If (lowcost [J] & mindis> lowcost [J])
33 {
34 mindis = lowcost [J];
35 minone = J;
36}
37}
38 If (ANS <mindis)
39 ans = mindis;
40 lowcost [minone] = 0;
41 for (j = 0; j <n; j ++)
42 {// update the distance from each point to the set
43 If (lowcost [J]> map [minone] [J])
44 lowcost [J] = map [minone] [J];
45}
46}
47 cout <ans <Endl;
48}
49 return 0;
50}