├──最短路径
文章平均质量分 78
Kuro同学
这个作者很懒,什么都没留下…
展开
-
POJ 1122 FDNY to the Rescue! 反向dijkstra
链接:1122题意:一个城市中有N个交叉路口,给出从一个交叉路口i到另一个交叉路口j所需要的时间(i,j=1~N,单向)如果edge[i][j]=-1 则表示不通给出一个火警的位置(终点) 和X个消防站(起点) 输出:每一行描述了一个消防站的信息,这些信息按消防站到达火警位置所需时间从小到大排列。这些信息包括:消防站的原创 2015-01-27 15:54:37 · 1087 阅读 · 0 评论 -
CSUOJ 1336 Interesting Calculator spfa / 优先队列
DescriptionThere is an interesting calculator. It has 3 rows of buttons. Row 1: button 0, 1, 2, 3, ..., 9. Pressing each button appends that digit to the end of the display.Row 2: button +0,原创 2014-09-06 11:02:07 · 1306 阅读 · 1 评论 -
csu 1106 最优对称路径 最短路+记忆化搜索.
题目链接:csu1106解题思路:首先思考如何得到一条对称的路径:分别从起点和终点出发,并走对称的方向,最后在对角线汇合,所有点权之和即是这条路径的的路程我们很容易发现,模拟 终点到对角线的过程 是多余的,因为它的路径和 起点到对角线所走的路径 是对称的.....我们只需要将整个地图沿对角线对折,重合的点累加,那么我们从起点(已和终原创 2015-08-24 14:25:28 · 1196 阅读 · 0 评论 -
POJ3592 Instantaneous Transference 强连通+最长路
题目链接:poj3592题意:给出一幅n X m的二维地图,每个格子可能是矿区,障碍,或者传送点 用不同的字符表示;有一辆矿车从地图的左上角(0,0)出发,只能往右走或往下走,或者通过传送点 选择是否 传送到特定地点采过的矿的格子 矿会消失;问这辆矿车最多能采多少矿解题思路:首先重新建图,将图中二维的顶点压缩成一维的顶点原创 2015-07-10 17:40:52 · 899 阅读 · 0 评论 -
ZOJ 2027 Traveling fee dp+floyed
题目链接:2027题意:暑假快到了,Samball 想取旅行,现在可以制定一个计划了。选定旅行目的地后,接下来就是选择旅行路线了。由于他并没有多少钱,所以他想找一条最省钱的路线。Samball 得知旅游公司在暑假会推出一个折扣方案:选定一条线路后,在这条线路上连接两个城市间机票费用最贵的费用将被免去,这可是个好消息。给定出发地和目的地,以及所有机票的费用,请计算最小的费原创 2015-03-10 20:30:19 · 883 阅读 · 0 评论 -
POJ 1062 昂贵的聘礼 最短路
Description年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换原创 2014-07-27 21:58:29 · 912 阅读 · 0 评论 -
HDU 2377 Bus Pass spfa
Problem DescriptionYou travel a lot by bus and the costs of all the seperate tickets are starting to add up.Therefore you want to see if it might be advantageous for you to buy a bus pass.原创 2015-01-18 10:24:14 · 934 阅读 · 0 评论 -
HDU 2544 最短路 SPFA 邻接表 模板
Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗? Input输入包括多组数据。每组数据第一行是两个整数N、M(N输入保证至少存在1条商店到赛场的路线。 O原创 2014-10-22 12:45:43 · 1013 阅读 · 1 评论 -
HDU 1596 最短路
Problem DescriptionXX星球有很多城市,每个城市之间有一条或多条飞行通道,但是并不是所有的路都是很安全的,每一条路有一个安全系数s,s是在 0 和 1 间的实数(包括0,1),一条从u 到 v 的通道P 的安全度为Safe(P) = s(e1)*s(e2)…*s(ek) e1,e2,ek是P 上的边 ,现在8600 想出去旅游,面对这这么多的路,他想找一条最安全的路。但是86原创 2014-08-14 21:24:58 · 886 阅读 · 0 评论 -
ZOJ1456 Minimum Transport Cost 用floyd记录路径
These are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transpor原创 2014-10-20 11:27:19 · 955 阅读 · 0 评论 -
POJ 3268 Silver Cow Party 最短路 dij
DescriptionOne 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) unidirecti原创 2014-09-29 11:14:07 · 670 阅读 · 0 评论 -
poj 2240 Arbitrage bellman ford
DescriptionArbitrage is the use of discrepancies in currency exchange rates to transform one unit of a currency into more than one unit of the same currency. For example, suppose that 1 US Dollar bu原创 2014-10-16 20:29:28 · 839 阅读 · 0 评论 -
HDU 1874 畅通工程续 最短路径入门(dijkstra)
Problem Description某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。 Input本题目包含多组数据,请处理到文件结束。每组数据第一行包原创 2014-07-22 15:56:33 · 1148 阅读 · 0 评论 -
POJ 1135 Domino Effect 最短路
DescriptionDid you know that you can use domino bones for other things besides playing Dominoes? Take a number of dominoes and build a row by standing them on end with only a small distance in betwe原创 2014-09-15 21:35:26 · 792 阅读 · 0 评论 -
POJ 3259 Wormholes SPFA 判断负权回路
DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination a原创 2014-10-30 20:31:55 · 774 阅读 · 0 评论 -
poj1511||hdu1535 Invitation Cards spfa
题目链接:Invitation Cards题意:给出一个M个点N条边的单向图 1 题解:1 代码:#include#include#include#include#define maxx 0x3f3f3f3fusing namespace std;struct node{原创 2015-01-30 16:45:03 · 866 阅读 · 0 评论 -
ZOJ3088 Easter Holidays spfa 最长路 最短路 路径打印
题目链接:3088题意:一个滑雪胜地包含了n 个地点,m 个滑雪斜坡,k 架雪橇,其中2≤n≤1000、1≤m≤1000、1≤k≤1000。滑雪斜坡和雪橇总是从一个地点到另一个地点:滑雪斜坡是从高地点到低地点,而雪橇刚好相反(注意,雪橇不能下降)。Per 是一个滑雪初学者,他很害怕雪橇,尽管他想滑得尽可能快。现在,他发现他可以选择不同的雪橇和滑雪斜坡。他现在原创 2015-02-01 13:43:05 · 1016 阅读 · 0 评论 -
zoj1232 Adventure of Super Mario dp+floyed
题目链接:zoj1232题意:一幅无向图有n1个村庄(1~n1),n2个城堡(n1~n1+n2),它们之间有m条边,马里奥知道每条边的距离且他1s能走1单位距离马里奥要从1号村庄走到n1+n2号城堡,他有一双可以使用k次的跑鞋,每使用一次可以从一个地方迅速到达另一个地方,但中间不能经过城堡,且两个地方的距离不能超过L问,马里奥最少需要多少时间原创 2015-08-22 17:16:00 · 992 阅读 · 0 评论