
最短路
KEIke0
这个作者很懒,什么都没留下…
展开
-
Silver Cow Party POJ 3268
n头牛去x和n头牛从x返回到原来的点,路是单向路,因为dijkstra的算法是从一个顶点开始遍历,dis记载这个顶点到其他点的最短距离,没有方向。所以来一次和去一次的时候,路要反转一次,虽然算的还是顶点到其他点的距离是多少,但是遍历的时候,如果是单向路的话,经过反转已经不能走了,找其他的路。 #include<iostream> #include<cstring> #i...原创 2019-12-14 17:14:01 · 142 阅读 · 0 评论 -
Wormholes POJ 3259
用Bellman-ford算法看这张图有没有负权回路。 还不是很懂要多看看 #include<iostream> #include<algorithm> #include<cstring> using namespace std; const int MAXN=10050; const int INF=0x3f3f3f3f; struct node{...原创 2019-12-11 22:33:04 · 145 阅读 · 0 评论 -
Six Degrees of Cowvin Bacon POJ 2139
n个学生,m个团体。每个团体有联系的话距离就是1。用floyd写 #include<iostream> #include<algorithm> using namespace std; const int INF=0x3f3f3f3f; int map[305][305]; int a[10005]; void init() { for(int i=1;i&...原创 2019-12-11 17:10:42 · 122 阅读 · 0 评论