博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cogs—— 310. [POJ2395] Out of Hay
阅读量:6500 次
发布时间:2019-06-24

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

              310. [POJ2395] Out of Hay

      ★☆   输入文件:outofhay.in   输出文件:outofhay.out   简单对比
            时间限制:1 s   内存限制:128 MB

Description

The cows have run out of hay, a horrible event that must be remedied immediately. Bessie intends to visit the other farms to survey their hay situation. There are N (2 <= N <= 2,000) farms (numbered 1..N); Bessie starts at Farm 1. She'll traverse some or all of the M (1 <= M <= 10,000) two-way roads whose length does not exceed 1,000,000,000 that connect the farms. Some farms may be multiply connected with different length roads. All farms are connected one way or another to Farm 1. 
Bessie is trying to decide how large a waterskin she will need. She knows that she needs one ounce of water for each unit of length of a road. Since she can get more water at each farm, she's only concerned about the length of the longest road. Of course, she plans her route between farms such that she minimizes the amount of water she must carry. 
Help Bessie know the largest amount of water she will ever have to carry: what is the length of longest road she'll have to travel between any two farms, presuming she chooses routes that minimize that number? This means, of course, that she might backtrack over a road in order to minimize the length of the longest road she'll have to traverse.

Input

* Line 1: Two space-separated integers, N and M. 
* Lines 2..1+M: Line i+1 contains three space-separated integers, A_i, B_i, and L_i, describing a road from A_i to B_i of length L_i.

Output

* Line 1: A single integer that is the length of the longest road required to be traversed.

Sample Input

3 31 2 232 3 10001 3 43

Sample Output

43

Hint

OUTPUT DETAILS: 
In order to reach farm 2, Bessie travels along a road of length 23. To reach farm 3, Bessie travels along a road of length 43. With capacity 43, she can travel along these roads provided that she refills her tank to maximum capacity before she starts down a road.
 
 
题目大意:求贝西所走路的最长路的长度。
思路:求最小生成树最大边、、、
代码
#include
#include
#include
#include
#include
#define N 10010using namespace std;int x,y,z,n,m,ans,fa[N];int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){
if(ch=='-')f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();} return x*f;} struct Edge{ int x,y,z;}edge[N];int cmp(Edge a,Edge b){ return a.z

 

转载于:https://www.cnblogs.com/z360/p/7388514.html

你可能感兴趣的文章
hadoopt -cat 命令查看_linux运维命令实践:使用cat命令合并文件和查看文件内容
查看>>
python开发节目程序_Python获取央视节目单的实现代码
查看>>
python的image用法_python使用Image处理图片常用技巧分析
查看>>
JDBC_MySQL_jdbc连接mysql_MySQL
查看>>
新手学习python零基础_新手零基础学习Python第一步,搭建开发环境!
查看>>
mysql cte的好处_Mysql 8 重要新特性 - CTE 通用表表达式
查看>>
zcu106 固化_xilinx zcu106 vcu demo
查看>>
java 打印万年历_Java基础之打印万年历
查看>>
java ftpclient 代码_java后台代码ftpclient下载文件
查看>>
java mina 长连接_MINA实现TCP长连接(二)——服务端实现
查看>>
java数据库生成model_继承BaseModelGenerator 生成Model时添加数据库表字段 生成代码示例...
查看>>
https redirects java_java HttpURLConnection 得到 Redirect 转向的例子
查看>>
java读取html文件并替换_java读取html并替换相关内容
查看>>
java面向对象的概念_java面向对象(上)-- 面向对象的概念
查看>>
dbscan算法python实现_Python实现DBScan
查看>>
java智能聊天软件_Java使用青云客智能聊天接口做一个小助手
查看>>
java定义player类_Java自定义一个异常类NoThisSongException和Player类
查看>>
java 字符串 算法 面试题_java笔试手写算法面试题大全含答案
查看>>
java内部类访问外部类变量 final_Java内部类引用外部类中的局部变量为什么必须是final问题解析...
查看>>
java编程思想第四章_《JAVA编程思想》学习笔记——第四章 控制执行流程
查看>>