POJ2387 Til the Cows Come Home (最短路 dijkstra)
Farmer John's field has N (2 <= N <= 1000) landmarks in it, uniquely numbered 1..N. Landmark 1 is the barn; the apple tree grove in which Bessie stands all day is landmark N. Cows travel in the field using T (1 <= T <= 2000) bidirectional cow-trails of various lengths between the landmarks. Bessie is not confident of her navigation ability, so she always stays on a trail from its start to its end once she starts it.
Given the trails between the landmarks, determine the minimum distance Bessie must walk to get back to the barn. It is guaranteed that some such route exists.
Input
* Lines 2..T+1: Each line describes a trail as three space-separated integers. The first two integers are the landmarks between which the trail travels. The third integer is the length of the trail, range 1..100.
Output
Sample Input
5 5
1 2 20
2 3 30
3 4 20
4 5 20
1 5 100
Sample Output
90
Hint
There are five landmarks.
OUTPUT DETAILS:
Bessie can get home by following trails 4, 3, 2, and 1.
POJ2387 Til the Cows Come Home (最短路 dijkstra)的更多相关文章
- Til the Cows Come Home 最短路Dijkstra+bellman(普通+优化)
Til the Cows Come Home 最短路Dijkstra+bellman(普通+优化) 贝西在田里,想在农夫约翰叫醒她早上挤奶之前回到谷仓尽可能多地睡一觉.贝西需要她的美梦,所以她想尽快回 ...
- POJ-2387 Til the Cows Come Home ( 最短路 )
题目链接: http://poj.org/problem?id=2387 Description Bessie is out in the field and wants to get back to ...
- POj2387——Til the Cows Come Home——————【最短路】
A - Til the Cows Come Home Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & ...
- POJ2387 Til the Cows Come Home(SPFA + dijkstra + BallemFord 模板)
Til the Cows Come Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37662 Accepted ...
- (Dijkstra) POJ2387 Til the Cows Come Home
Til the Cows Come Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 81024 Accepted ...
- 【POJ - 2387】Til the Cows Come Home(最短路径 Dijkstra算法)
Til the Cows Come Home 大奶牛很热爱加班,他和朋友在凌晨一点吃完海底捞后又一个人回公司加班,为了多加班他希望可以找最短的距离回到公司.深圳市里有N个(2 <= N < ...
- poj2387 Til the Cows Come Home 最短路径dijkstra算法
Description Bessie is out in the field and wants to get back to the barn to get as much sleep as pos ...
- poj2387 Til the Cows Come Home
解题思路:最短路的模板题,注意一个细节处理即可. 见代码: #include<cstdio> #include<cstring> #include<algorithm&g ...
- POJ2387 Til the Cows Come Home 【Dijkstra】
题目链接:http://poj.org/problem?id=2387 题目大意; 题意:给出两个整数T,N,然后输入一些点直接的距离,求N和1之间的最短距离.. 思路:dijkstra求单源最短路, ...
随机推荐
- Linux Expect自动交互脚本
https://likegeeks.com/expect-command/ In the previous post, we talked about writing practical shell ...
- SQL Server中一些不常见的查询
把一些不常见但又会用到的SQL查询整理备份一下 --筛选出某个字段中包含中文的记录 SELECT * FROM temp WHERE W1 LIKE '%[吖-座]%' --筛选出某个字段在哪些表中存 ...
- day_work_02
day_work_02 ------Python是一个优雅的大姐姐 作业一 设计思路(四个if一个while) 首先我先把商品用列表加元组的形式保存,然后将商品遍历出来. 键盘输入薪水. (if)判断 ...
- poj 3320 jessica's Reading PJroblem 尺取法 -map和set的使用
jessica's Reading PJroblem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9134 Accep ...
- Linux命令-文件传输
Linux命令-文件传输 Linux lprm命令 Linux lprm命令用于将一个工作由打印机贮列中移除 尚未完成的打印机工作会被放在打印机贮列之中,这个命令可用来将常未送到打印机的工作取消.由于 ...
- vue-cli中route和router的区别
在使用vue-router的时候经常分不清router和route的区别: 在函数式编程中: this.$router.push('/login') 或者Router.push() 在动态获取路由参数 ...
- 安装python及其它
https://www.liaoxuefeng.com/wiki/1016959663602400/1016959856222624
- golang网络通信超时设置
网络通信中,为了防止长时间无响应的情况,经常会用到网络连接超时.读写超时的设置. 本文结合例子简介golang的连接超时和读写超时设置. 1.超时设置 1.1 连接超时 func DialTimeou ...
- leecode 309. 最佳买卖股票时机含冷冻期
/***** //sell[i]表示截至第i天,最后一个操作是卖时的最大收益: //buy[i]表示截至第i天,最后一个操作是买时的最大收益: //cool[i]表示截至第i天,最后一个操作是冷冻期时 ...
- leetcode 454 四数相加
采用一个哈希表存储两个数的和,再遍历另外两个数组的和,time O(n2) space O(n2) class Solution { public: int fourSumCount(vector&l ...