
最短路径
Dreamlandzxx
这个作者很懒,什么都没留下…
展开
-
HDU 3790 最短路径问题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3790 题目大意:就是找出最短路经同时输出最短路经所对应的花费,若有多个最短路径输出花费较少的路径。 思路:就是定义两个二维数组,一个用来储存最短路径,一个用来储存花费。然后找出你最短路经,将最短路径的每条路的花费相加即可。 具体代码:#include<iostream>#include<cstd原创 2016-05-24 16:06:03 · 427 阅读 · 0 评论 -
NYOJ 1238 最少换乘
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=1238 题目大意:给你n条公交车的路线,现在让你算从第一个点到第n个点最少换乘公交车数,若不能到达则输出NO。 题目思路:同一条路线的两点间的权值都为1,这样最后算出的最小权值-1就是最小换乘数 具体代码:#include<stdio.h>#include<string.h>#in原创 2016-05-26 17:55:09 · 823 阅读 · 0 评论 -
POJ 2253 Frogger
题目链接:http://poj.org/problem?id=2253 题目大意:第一行开始位置的坐标,第二行终止位置的坐标,剩下的n-2行是水中石头的坐标,求从开始到终止每次选取最小的权值,在每点的最小权值中输出最大的 思路:简单的最短路的比较 具体代码:#include<stdio.h>#include<string.h>#include<algorithm>#include<ios原创 2016-05-26 18:06:16 · 276 阅读 · 0 评论 -
HUD 2544 最短路
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 题目大意: 求从商场到赛场的最短时间。 思路:即求最短路径问题。 分别用三种解决最短路径代码如下: 方法一:Dijkstar求最短路径#include<stdio.h>#include<string.h>#include<algorithm>#include<queue>#incl原创 2016-05-18 18:28:45 · 443 阅读 · 0 评论 -
HDU 2066 一个人的旅行
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2066 题意:应该看懂了。。。 思路:就是简单的最短路径的模板,下面我用三种方法来做这道题。 (1)Floyd:#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<climits>#inclu原创 2016-05-22 21:20:02 · 387 阅读 · 0 评论 -
Til the Cows Come Home POJ - 2387
Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b原创 2017-04-28 10:07:35 · 345 阅读 · 0 评论 -
Silver Cow Party POJ - 3268
One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party to be held at farm #X (1 ≤ X ≤ N). A total of M (1 ≤ M≤ 100,000) unidirectional (one-way r原创 2017-04-28 17:53:57 · 386 阅读 · 0 评论