ACM: 图论题 poj2485 (crazy now~!…
来源:互联网 发布:淘宝网店加盟哪家好 编辑:程序博客网 时间:2024/05/18 23:25
Description
The island nation of Flatopia is perfectly flat. Unfortunately,Flatopia has no public highways. So the traffic is difficult inFlatopia. The Flatopian government is aware of this problem.They're planning to build some highways so that it will be possibleto drive between any pair of towns without leaving the highwaysystem.
Flatopian towns are numbered from 1 to N. Each highway connectsexactly two towns. All highways follow straight lines. All highwayscan be used in both directions. Highways can freely cross eachother, but a driver can only switch between highways at a town thatis located at the end of both highways.
The Flatopian government wants to minimize the length of thelongest highway to be built. However, they want to guarantee thatevery town is highway-reachable from every other town.
Input
The first line of input is an integer T, which tells how manytest cases followed.
The first line of each case is an integer N (3 <= N<= 500), which is the number of villages. Then comeN lines, the i-th of which contains N integers, and the j-th ofthese N integers is the distance (the distance should be an integerwithin [1, 65536]) between village i and village j. There is anempty line after each test case.
Output
For each test case, you should output a line contains aninteger, which is the length of the longest road to be built suchthat all the villages are connected, and this value is minimum.
Sample Input
3
0 990 692
990 0 179
692 179 0
Sample Output
692
题意:
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 250005
int n , m;
int u[MAX] , v[MAX] , w[MAX];
int p[MAX] , r[MAX];
int read_graph()
{
}
int cmp(const int i,const int j)
{
}
int find(int x)
{
}
int kruskal()
{