## sicily 1090 Highways 原

Ciel

### 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. 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 highway-reachable from every other town.

### Input

The first line is an integer N (3 <= N <= 500), which is the number of villages. Then come N lines, the i-th of which contains N integers, and the j-th of these N integers is the distance (the distance should be an integer within [1, 65536]) between village i and village j.

### Output

You should output a line contains an integer, which is the length of the longest road to be built such that all the villages are connected, and this value is minimum.
This problem contains multiple test cases!
The first line of a multiple input is an integer T, then a blank line followed by T input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of T output blocks. There is a blank line between output blocks.

### Sample Input

``````1

3
0 990 692
990 0 179
692 179 0``````

### Sample Output

``692``

## 代码：

``````// Problem#: 1090
// Submission#: 1892154
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <iostream>
using namespace std;

#define MAX 500
#define INF 65536
unsigned int dist[MAX][MAX];
unsigned int tmp[MAX];

inline int min( int n ){
unsigned int min = INF;
int re;
for( int i=0 ; i<n ; i++ ){
if( tmp[i]>0  && tmp[i]<min ){
re = i;
min = tmp[i];
}
}
return re;
}

int mst_prim( int n ){
unsigned int re = 0;
int k;
for( int i=0 ; i<n ; i++ )
tmp[i] = dist[0][i];
for( int i=1 ; i<n ; i++ ){
k = min(n);
re = tmp[k]>re ? tmp[k] : re;
tmp[k] = 0;
for( int j=0 ; j<n ; j++ )
if( dist[k][j] < tmp[j] )
tmp[j] = dist[k][j];
}
return re;
}

int main(){
int t,n;
cin >> t;
while(t--){
cin >> n;
for( int i=0 ; i<n ; i++ )
for( int j=0 ; j<n ; j++ )
cin >> dist[i][j];

cout << mst_prim(n) << endl;
if( t ) cout << endl;
}
return 0;
}``````

### Ciel

--============Oracle ADG搭建============== --==========准备阶段========= 1.检查primary为archivelog模式。 select log_mode from v\$database; 如果为noarchivelog模式，切换到archivelo......

UltraSQL
2018/07/23
0
0
PAT 1013 Battle Over Cities（DFS统计连通图的个数）

2018/11/07
0
0
PTA (Advanced Level)1013 Battle Over Cities

Battle Over Cities 　　It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city......

suvvm
2018/12/16
0
0
PAT (Advanced Level) 1013. Battle Over Cities (25) DFS求连通分量

xp731574722
2018/04/25
0
0
oracle查询数据重复

2013/01/08
489
2

4
0
js中实现页面跳转（返回前一页、后一页）

3
0
JAVA 利用时间戳来判断TOKEN是否过期

import java.time.Instant;import java.time.LocalDateTime;import java.time.ZoneId;import java.time.ZoneOffset;import java.time.format.DateTimeFormatter;/** * @descri......

huangkejie

3
0

6
0