![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
[kuangbin带你飞]专题四 最短路练习
文章平均质量分 85
h1021456873
这个作者很懒,什么都没留下…
展开
-
POJ 2387 Til the Cows Come Home (最短路)
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-03-19 15:34:27 · 266 阅读 · 0 评论 -
POJ3159 最大差距(差分约束系统 ,Dijkstra+Heap)
班上有n个同学,现在有一些糖要分给他们,设第i个同学得到的糖为p[i],分糖必须满足条件:第i个同学要求第j个同学的糖不能超过自己k个,即p[j] - p[i] = 0。要求在满足这些条件的情况下,求出p[n] - p[1]的最大值。由p[j] - p[i] 在单源最短路径的算法中有一步是“若mindis[j] > mindis[i] + dis[i][j],则mindis[j] = mi原创 2017-03-26 11:02:20 · 612 阅读 · 0 评论 -
POJ 1511 Invitation Cards (spfa + 静态邻接表)
题目大意:给出n个点和n条有向边,求所有点到源点1的来回最短路之和(保证每个点都可以往返源点1)解题思路:这个数据范围太大,明显的不能用floyd,dijstra,bellman-ford这些算法,用spfa的话也不能用邻接矩阵存,因为点太多了,所以采用spfa的邻接表存储搞定稍微有点注意的地方是,来回之和只需要将所有的边反向再从1到所有点求最短路就是他们的最短回路,而且这个题的数据有原创 2017-03-25 19:45:10 · 314 阅读 · 0 评论 -
POJ - 1062 昂贵的聘礼 (Floyd)
年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东西,原创 2017-03-25 15:50:20 · 416 阅读 · 0 评论 -
POJ - 2240 汇率 (Floyd)
题目大意:可以简单描述为知道从i到j的汇率,问能不能赚钱Arbitrage 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,原创 2017-03-25 15:07:57 · 210 阅读 · 0 评论 -
POJ 3660 牛的排名 (Floyd 传递闭包)
题意: 有n头牛, 给你m对关系(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少牛的排名。思路:这题的难点就是,牛到达怎么样的状态,才能说他的排名是确定的。。。仔细想想就是比牛强的人 + 比牛弱的人 == n-1 (自己不要考虑进去)然后嘛解决此类办法是 传递闭包了!!!!分析:在这呢先说一下关系闭包: 关系闭包有三种: 自反闭包(原创 2017-03-23 19:11:49 · 348 阅读 · 0 评论 -
POJ 3259 虫洞 (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原创 2017-03-22 23:02:05 · 284 阅读 · 0 评论 -
POJ 1860 换汇币 (BellmanFord)
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原创 2017-03-22 21:15:54 · 249 阅读 · 0 评论 -
POJ - 3268 Silver Cow Party (最短路)
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-03-19 20:47:06 · 207 阅读 · 0 评论 -
POJ 1797 Heavy Transportation (最短路)
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 cu原创 2017-03-19 20:03:19 · 273 阅读 · 0 评论 -
POJ 2253 Frogger (Floyd)
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原创 2017-03-19 16:37:15 · 227 阅读 · 0 评论 -
POJ 1847 火车变轨道 (简单最短路)
题意:火车从一点开到另一点,轨道上有很多岔路口,每个路口都有好几个方向(火车能够选任意一个方向开),但是 默认的是 第一个指向的方向,所以如果要选择别的方向的话得 进行一次切换操作 ,给定一个起点一个终点 ,问最少进行几次 切换操作 能够 使 火车 完成这个历程 , 如果开不到,输出“-1”。貌似很简单啊,直接把与第一个相连的距离置为0,后面相连的置为1然后用最短路的方原创 2017-03-26 16:56:27 · 720 阅读 · 0 评论