题目名称 310. [POJ2395] Out of Hay
输入输出 outofhay.in/out
难度等级 ★☆
时间限制 1000 ms (1 s)
内存限制 128 MiB
测试数据 11
题目来源 GravatarBYVoid 于2009-04-06加入
开放分组 全部用户
提交状态
分类标签
USACO 最小生成树 并查集
分享题解
通过:63, 提交:101, 通过率:62.38%
GravatarAAAAAAAAAA 100 0.000 s 0.00 MiB C++
Gravatar乐未殇 100 0.000 s 0.00 MiB C++
Gravatar┭┮﹏┭┮ 100 0.000 s 0.00 MiB C++
Gravatarzhk 100 0.002 s 0.31 MiB C++
Gravatar521 100 0.006 s 0.00 MiB C++
GravatarQSZIO 100 0.012 s 0.47 MiB C++
GravatarHzoi_chairman 100 0.014 s 0.44 MiB C++
Gravatar金身人面兽 100 0.014 s 0.57 MiB C++
Gravatar乌龙猹 100 0.017 s 0.52 MiB C++
GravatarQSZIO 100 0.018 s 0.47 MiB C++
关于 Out of Hay 的近10条评论(全部评论)
数组越界不RE而是WA什么鬼……
GravatarSPA
2016-09-11 06:21 6楼
<><><><><><><><><><><>
Gravatar521
2016-08-15 17:22 5楼
看了评论的我连编译都没编译就改了个文件名就交了。。。。
GravatarSky_miner
2016-03-07 17:09 4楼
直接粘过来就对了。。
Gravatar一個人的雨
2015-04-09 11:34 3楼
注意数据范围不同、
Gravatar乌龙猹
2014-11-04 14:53 2楼
跟1109“修复公路”那题完全一样(反正是连通的对吧)……改几个常量就可以直接用了……
Gravatarcstdio
2013-02-03 18:49 1楼

310. [POJ2395] Out of Hay

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

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 3
1 2 23
2 3 1000
1 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.