
最短路
LLL_yx
这个作者很懒,什么都没留下…
展开
-
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-08-10 22:11:00 · 312 阅读 · 0 评论 -
HDU - 1385 Minimum Transport Cost(floyd打印路径)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1385题意:给你一张图的邻接矩阵和每个城市的收费,最后给你若干个起点和终点,求最短路径并打印思路:多源最短路想到的肯定是floyd,用path[i][j]来表示从i到j经过的第一个点是哪个。代码:#include <bits/stdc++.h> #define INF 0x3f3f3f3f ...原创 2018-03-15 20:40:12 · 203 阅读 · 0 评论 -
HDU - 3339 In Action(最短路+dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3339 题意:是n个发电站,m条路,每条路有各自的距离,每个发电站有各自的发电量,现在需要炸毁它们,一辆坦克只能炸毁一个发电站,而且需要炸毁的发电厂的发电量需要大于所有发电站所产生的总电量的一半,求坦克走的最短距离 思路:先用最短路求出起点到各点的距离,然后01背包得出大于一半电量时最短的距离就行了原创 2017-12-05 19:54:03 · 238 阅读 · 0 评论 -
POJ - 1511 Invitation Cards (SPFA最短路)
In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want to propagate theater and, most of all, Antique Comedies. They原创 2017-08-15 19:21:15 · 368 阅读 · 0 评论 -
POJ - 3660 Cow Contest(变用Floyd)
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is un原创 2017-08-15 15:20:02 · 244 阅读 · 0 评论 -
POJ - 1860 Currency Exchange(反用bellman求正环)
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-08-14 20:53:04 · 261 阅读 · 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 ro原创 2017-08-14 13:48:18 · 256 阅读 · 0 评论 -
POJ - 3255 Roadblocks(次短路)
题目链接:http://poj.org/problem?id=3255(《挑战》) 题意:就是求1到n的次短路 思路:同时求出最短路和次短路,如何判断次短路呢?要么就是1到某个非终点的u的最短路,再加上d(u ,v ),要么是1到某个非终点的u的次短路,再加上d(u ,v ),只有这两种可能 (具体可以看代码的注释) 代码: #include #include #includ原创 2017-08-20 22:46:28 · 277 阅读 · 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-08-12 21:06:43 · 236 阅读 · 0 评论 -
Frogger POJ - 2253(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-08-11 21:02:03 · 357 阅读 · 0 评论 -
POJ - 3311 Hie with the Pie (状压dp+最短路)
题目链接:http://poj.org/problem?id=3311 题意:给你一个图,求从0点经过所有点再回到0点的最短路径。 思路:1表示经过了这个点,0表示没经过,压缩成状态sta,dp[sta][i]表示现在是sta状态,此时到达点i的最短距离。 那么dp[sta][i]=min( dp[sta][i] , dp[没经过i的状态][j] + dis[j][i] ) j点为中间点,像...原创 2018-08-25 23:28:04 · 235 阅读 · 0 评论