
最短路
最短路
Wanidde
本人很懒,什么都没有留下 ^_^
展开
-
HDU 1874 - 畅通工程续 (Floyd 最短路)
某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。 Input 本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0<N<200,0<M...原创 2018-07-25 14:41:43 · 233 阅读 · 0 评论 -
HDU 1595 - find the longest of the shortest(枚举+最短路(dijkstra))
Problem Description Marica is very angry with Mirko because he found a new girlfriend and she seeks revenge.Since she doesn't live in the same city, she started preparing for the long journey.We know...原创 2018-12-10 17:14:49 · 224 阅读 · 4 评论 -
HDU 2066 - 一个人的旅行 (dijkstra)
虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女……眼看寒假就快到了,这么一大段时间,可不能浪费啊,一定要给自己好好的放个假...原创 2018-11-30 13:20:26 · 137 阅读 · 0 评论 -
POJ 1860 - Currency Exchange (正权回路 Bellman - Ford)
Several currency exchange points are working in our city. Let us suppose that each point specializes in two particular currencies and performs exchange operations only with these currencies. There can...原创 2018-07-28 11:45:56 · 166 阅读 · 0 评论 -
POJ 3268 - Silver Cow Party (dijkstra)
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 ro...原创 2018-08-05 17:17:59 · 309 阅读 · 0 评论 -
POJ 1062 - 昂贵的聘礼 (dijkstra)
年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东西,...原创 2018-07-27 17:14:59 · 153 阅读 · 0 评论 -
最短路的四种的求解方法+模板
一、Floyd算法: Floyd算法只有五行代码,代码简单,三个for循环就可以解决问题,所以它的时间复杂度为O(n*n*n),可以求多源最短路问题。 Floyd算法可以处理带有负权边,但不能处理带有“负权回路”的图。 核心代码: for(k=1;k<=n;k++) for(i=1;i<=n;i++) for(j=1;j<=n;j...原创 2018-07-28 09:18:12 · 3540 阅读 · 0 评论 -
POJ 1797 - Heavy Transportation (最短路变形 Dijkstra)
Background Hugo Heavy is happy. After the breakdown of the Cargolifter project he can now expand business. But he needs a clever man who tells him whether there really is a way from the place his cust...原创 2018-07-27 14:46:50 · 313 阅读 · 0 评论 -
POJ 3259 - Wormholes ( Floyd || Bellman - Ford)
While 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 at a time that i...原创 2018-07-26 21:03:23 · 171 阅读 · 0 评论 -
POJ 2253 - Frogger(Dijkstra最短路)
Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sun...原创 2018-07-26 20:51:32 · 360 阅读 · 0 评论 -
POJ 1502 - MPI Maelstrom (Dijkstra最短路)
BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsystem. Valentine McKee's research advi...原创 2018-07-26 20:33:36 · 187 阅读 · 0 评论 -
HDU 2544 - 最短路 (Floyd 最短路)
在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗? Input 输入包括多组数据。每组数据第一行是两个整数N、M(N<=100,M<=10000),N表示成都的大街上有几个路口,标号为1的路口是商店所在地,标号为N的路口是...原创 2018-07-25 14:44:39 · 137 阅读 · 0 评论 -
NYOJ 1238 - 最少换乘 (dijkstra)
1238-最少换乘 题目描述: 欧洲某城是一个著名的旅游胜地,每年都有成千上万的人前来观光旅行。Dr. Kong决定利用暑假好好游览一番。。 年轻人旅游不怕辛苦,不怕劳累,只要费用低就行。但Dr. Kong年过半百,他希望乘坐BUS从住的宾馆到想去游览的景点,期间尽可量地少换乘车。 Dr. Kon买了一张旅游...原创 2019-04-29 19:29:18 · 464 阅读 · 0 评论