![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dijkstra
文章平均质量分 66
skajre
这个作者很懒,什么都没留下…
展开
-
Codeforces 707B Bakery(最短路)
这题是个水题,构建一个超级原点,把非仓库点全部连上去,然后权值为0,从超级原点出发,走一遍最短路,然后遍历仓库点,输出最小路径,唯一的注意点就是权值L会超int范围,所以要用long long。 // // main.cpp // Richard // // Created by 邵金杰 on 16/8/21. // Copyright © 2016年 邵金杰. All rights r原创 2016-08-21 09:26:15 · 251 阅读 · 0 评论 -
POJ 3159 Candies
一道求最短路的题,时间卡得很紧,需要用优先队列(堆)来优化。 // // main.cpp // Richard // // Created by 邵金杰 on 16/8/13. // Copyright © 2016年 邵金杰. All rights reserved. // #include #include #include #include using namespace原创 2016-08-13 11:05:40 · 257 阅读 · 0 评论 -
图论 最短路径dijkstra算法
#include #include using namespace std; #define MAX 100 #define INFINITY 10000 typedef struct{ int arc[MAX][MAX]; int vex,edge; }AdjMatrix; void Dijkstra(AdjMatrix *G,int v0,int d[MAX]) { i原创 2016-05-12 18:23:04 · 351 阅读 · 0 评论 -
UVA 11374 Airport Express(dijkstra+枚举)
一开始想的是加一个flip标记,每条路只能由一个flip标记,但是最后发现这个标记对于记录最短时间的d数组是没有影响的。原创 2016-11-17 15:06:41 · 173 阅读 · 0 评论 -
UVA 10917 Walk Through the Forest (dijkstra+记忆化搜索)
水题1A。 #include #include #include #include #include #include using namespace std; const int maxn=1000+5; const int inf=100000000; struct HeapNode{ int d,u; bool operator < (const HeapNode &rhs原创 2016-11-17 20:30:57 · 185 阅读 · 0 评论 -
UVA 1416 Warare And Logistics(dijkstra)
思路是先暴力算出每个点的出发的最短路,然后记录下最短路树的边,枚举边,如果是最短路树上的边,那么可以删除,此时再做了一次djikstra。 自己想的时候非常贴合这个思路了,感觉只能暴力了,但是感觉这样做时间复杂度太高,最后算了下时间复杂度O(n^2mlogn),大概是刚好1e8,刚好卡着时间范围= = 。 以后想到思路还是仔细算一下复杂度,然后再决定写不写,好多次感觉时间爆了不敢写。原创 2016-11-17 21:50:00 · 197 阅读 · 0 评论 -
HDU 1535 Invitation Cards(dijkstra)
#include #include #include #include #include #include using namespace std; const int maxn=1000000+5; const int inf=100000000; typedef long long LL; struct HeapNode{ LL d; int u; bool opera原创 2016-11-19 14:27:03 · 230 阅读 · 0 评论 -
UVA 10537 The Toll! Revisited(dijkstra输出字典序最小的路径)
这题就是SB题,思路很好想,但输出字典序最小的路径卡住了,一直跑不出来,最后看了别人的代码,瞬间觉得自己的代码好挫,就把别人的代码码了出来,当作最短路输出路径的模版了。#include #include #include #include #include #include #include using namespace std; typedef long long LL; const int原创 2016-11-18 21:11:14 · 405 阅读 · 0 评论