
最短路径
疯的世界
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
poj_1258 Agri-Net
Agri-Net Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28121 Accepted: 11149 题目链接:http://poj.org/problem?id=1258 Description Farmer John has bee原创 2012-08-03 17:15:52 · 667 阅读 · 0 评论 -
Bellman-Ford 算法实现单源最短路径
/* 从某一个点到任意一点的最短距离,该算法可以解决负边权问题,但是不能存在环的权值为负这种情况。这算法的复杂度O(点数*边数) */ #include #include #include #define MAX 400003 #define VALUE 999999 using namespace std; struct edge {//定义边 int from; int t原创 2012-08-09 13:43:48 · 1105 阅读 · 0 评论 -
Dijkstra 算法求单源最短路径
//Dijkstra算法只能处理正边权问题 #include #include #include #define MAX 100 #define VALUE 0xffffff using namespace std; int g[MAX][MAX]; int d[MAX];//某一点到所有点的最短距离 bool used[MAX];//已经被使用的标记 int v,e;//点数和边数 voi原创 2012-08-09 14:00:27 · 1021 阅读 · 0 评论 -
poj_1135 Domino Effect
Domino Effect Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5637 Accepted: 1425 题目链接:http://poj.org/problem?id=1135 Description Did you know tha原创 2012-08-16 18:07:09 · 985 阅读 · 0 评论 -
poj_2240 Arbitrage
Arbitrage Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10954 Accepted: 4608 题目链接:http://poj.org/problem?id=2240 Description Arbitrage is the us原创 2012-08-16 18:01:54 · 835 阅读 · 0 评论 -
poj_1847 Tram
Tram Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7135 Accepted: 2583 题目链接:http://poj.org/problem?id=1847 Description Tram network in Zagrebcon原创 2012-08-16 18:04:54 · 890 阅读 · 0 评论 -
Floyd算法
正如我们所知道的,Floyd算法用于求最短路径。Floyd算法可以说是Warshall算法的扩展,三个for循环就可以解决问题,所以它的时间复杂度为O(n^3)。 Floyd算法的基本思想如下:从任意节点A到任意节点B的最短路径不外乎2种可能,1是直接从A到B,2是从A经过若干个节点X到B。所以,我们假设Dis(AB)为节点A到节点B的最短路径的距离,对于每一个节点X,我们检查Dis(AX) +转载 2012-08-16 16:21:05 · 698 阅读 · 0 评论 -
poj_1797 Heavy Transportation
Heavy Transportation Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 15487 Accepted: 4026 题目链接http://poj.org/problem?id=1797原创 2012-07-28 14:43:18 · 600 阅读 · 0 评论 -
poj_2387 Til the Cows Come Home
Til the Cows Come Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20550 Accepted: 6864 题目链接:http://poj.org/problem?id=2387 Description Bessie原创 2012-07-27 16:16:45 · 756 阅读 · 0 评论 -
poj_2263 Heavy Cargo (Dijkstra)
Heavy Cargo Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2264 Accepted: 1252 题目链接:http://poj.org/problem?id=2263 Description Big Johnsson Truck原创 2012-08-09 16:23:06 · 873 阅读 · 0 评论 -
poj_3925 Minimal Ratio Tree
Minimal Ratio Tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 836 Accepted: 304 题目链接:http://poj.org/problem?id=3925 Description For a tree, w原创 2012-08-08 14:42:22 · 736 阅读 · 0 评论 -
SPFA算法求最短路径(解决负边权问题)
SPFA算法是对bellman-fort算法的进一步优化,更大程度的减小时间复杂度; 具体看代码 #include #include #include #define info 99999 #define maxn 100 using namespace std; int dis[maxn]; int v,e;//点,边 queue q; int flag[maxn];//表示原创 2013-05-27 21:34:24 · 1628 阅读 · 0 评论