博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2485 Highways
阅读量:6953 次
发布时间:2019-06-27

本文共 2065 字,大约阅读时间需要 6 分钟。

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 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 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. There is an empty line after each test case.

Output

For each test case, 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.

Sample Input

130 990 692990 0 179692 179 0

Sample Output

692求最小生成树中的最大数
#include
#include
#include
using namespace std;int p[501][501],x,y,vis[501],i,j;int main(){
int n,k,t;cin>>t;while (t--){
cin>>n; int max; memset(p,0,sizeof(p)); for(i=1;i<=n;i++) for(j=1;j<=n;j++) cin>>p[i][j]; memset(vis,0,sizeof(vis)); vis[1]=1; for(i=0;i
p[x][j]) p[1][j]=p[x][j]; } }for(k=1;k<=n;k++) if(p[1][k]>max) max=p[1][k];cout<
<
 

Hint

Huge input,scanf is recommended.
 
 
 

转载于:https://www.cnblogs.com/lengxia/p/4387796.html

你可能感兴趣的文章
【转】SVM算法的生动讲解
查看>>
使用swfupload上传超过30M文件,使用FLASH上传组件
查看>>
OkHttp简介
查看>>
如何使用通用Mapper
查看>>
MYSQL建表语法(主键,外键,联合主键)
查看>>
linux基础-第十单元 系统的初始化和服务
查看>>
多线程的通信和同步(Java并发编程的艺术--笔记)
查看>>
Python格式化输出
查看>>
Linux使用du和df查看磁盘和文件夹占用空间
查看>>
java 消息机制 ActiveMQ入门实例
查看>>
CentOS 6.6 MySQL install
查看>>
从零开始用gulp
查看>>
《数据库系统概论》读书笔记
查看>>
27:除以13
查看>>
10分钟看懂社群营销(上集)[转]
查看>>
算法笔记_091:蓝桥杯练习 递推求值(Java)
查看>>
centos7 安装mysql
查看>>
Oracle 多行、多列子查询
查看>>
8 -- 深入使用Spring -- 8...1 Spring提供的DAO支持
查看>>
【webpack】流行的前端模块化工具webpack初探
查看>>