
最短路
文章平均质量分 78
Unin88
这个作者很懒,什么都没留下…
展开
-
POJ 1125 Stockbroker Grapevine
http://poj.org/problem?id=1125原创 2014-09-21 21:32:11 · 365 阅读 · 0 评论 -
POJ 1125 Stockbroker Grapevine
http://poj.org/problem?id=1125全源最短路问题:Floyd算法的简单应用!#include #include #include #include using namespace std;const int MAXV = 110;const int INF = 0x3f3f3f3f;int G[MAXV][MAXV],n;void Init原创 2014-12-09 15:07:12 · 401 阅读 · 0 评论 -
SGU 103 Traffic Lights
http://acm.sgu.ru/problem.php?contest=0&problem=103有条件限制的最短路问题,当且仅当点的颜色一样时可以通行否则需要等到符合条件时才可以通行。等待的时间与通行时间之和用于判断松弛。AC代码:#include #include #include #include #include #include #include原创 2014-12-09 14:27:20 · 524 阅读 · 0 评论 -
POJ 1502 MPI Maelstrom
http://poj.org/problem?id=1502许久没写最短路 还是1A 哈哈!裸最短路!#include #include #include #include #include using namespace std;const int MAXV = 110;const int INF = 0x3f3f3f3f;int n;int G[MAXV][MA原创 2014-12-09 15:58:09 · 345 阅读 · 0 评论 -
poj 1178 Camelot
题目大意:有一种棋盘游戏,棋盘有8x8共64个方格,有两种棋子:国王和骑士,国王只有一个,骑士可以有多个。国王每移动一步可以从当前位置移动到八个方向的相邻方格(共有8种走法),移动的时候不能越界。骑士也是8种走法,但走的是“日”字,移动的时候也不能越界。当国王遇到骑士时,骑士可以带上国王,该骑士和国王看作一个骑士,按骑士走法走,每走一步只算一步(即国王从此可以忽略)。现在要求出将棋盘上所有骑士原创 2015-01-28 14:39:34 · 627 阅读 · 0 评论 -
E. Breaking Good
本题是在最短路的基础上 要求修改的路是最少的 后面也满足贪心性质 因此都是最短路的算法 只不过松弛操作有不同之处。由于点数过多 使用邻接表进行图的存储。最后要找到最短路中所涉及的边 还要用到map来进行映射。#include #include #include #include #include #include #include using namespace std原创 2015-01-27 15:00:15 · 436 阅读 · 0 评论 -
HDU 2544 最短路
vector实现邻接表 && 优先队列优化dijkstra原创 2014-10-13 13:25:30 · 409 阅读 · 0 评论 -
HDU 1596 find the safest road
http://acm.hdu.edu.cn/showproblem.php?pid=1596原创 2014-10-22 14:51:55 · 365 阅读 · 0 评论 -
HDU 1385 Minimum Transport Cost
http://acm.hdu.edu.cn/showproblem.php?pid=1385原创 2014-10-22 09:01:06 · 336 阅读 · 0 评论 -
POJ 2387 Til the Cows Come Home
http://poj.org/problem?id=2387使用bellman_fordji原创 2014-09-03 16:04:56 · 356 阅读 · 0 评论 -
POJ 3259 Wormholes
http://poj.org/problem?id=3259原创 2014-09-02 11:09:35 · 328 阅读 · 0 评论 -
HDU 2544 最短路
http://acm.hdu.edu.cn/showproblem.php?pid=2544原创 2014-09-14 22:13:19 · 374 阅读 · 0 评论 -
HDU 2066 一个人的旅行
http://acm.hdu.edu.cn/showproblem.php?pid=2066迪杰斯特拉原创 2014-09-12 10:58:37 · 412 阅读 · 0 评论 -
HDU 2680 Choose the best route
http://acm.hdu.edu.cn/showproblem.php?pid=2680原创 2014-09-12 10:25:42 · 362 阅读 · 0 评论 -
HDU 1596 find the safest road
http://acm.hdu.edu.cn/showproblem.php?pid=1596原创 2014-09-09 21:15:03 · 381 阅读 · 0 评论 -
hdu 1598 find the most comfortable road
题意给出n个点m条边以及边的权值,求出点a到点b的一条路,这条路上所有边的最大值-最小值的值最小。这个题有两种做法:1.二分+最短路:枚举差值和最小值。2.并查集+Kruscal:排序后,枚举每一条边。AC代码(第二种做法)#include #include #include #include using namespace std;const int INF原创 2015-04-06 22:14:22 · 500 阅读 · 0 评论