题目传送门 题目大意:有F组数据,N表示有N点,M表示有M条边,走一遍边需要花费Ti个时间,还有W个虫洞,可以向前回溯Ti时间,求能否从1点出发,经过一些路或虫洞回到1点后时间为负。 建图后用SPFA判负环即可。 code: ...
分类:
其他好文 时间:
2018-03-03 18:22:39
阅读次数:
172
Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one- ...
分类:
其他好文 时间:
2018-02-10 18:54:24
阅读次数:
184
题意:有向图判负环。 解题关键:spfa算法+hash判负圈。 负圈是指圈上的总和小于0 ...
分类:
其他好文 时间:
2017-11-25 23:42:16
阅读次数:
130
题目链接:http://poj.org/problem?id=3259 Wormholes Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 55082 Accepted: 20543 Description While explo ...
分类:
其他好文 时间:
2017-09-27 22:30:43
阅读次数:
187
会了spfa这么长时间竟然不会判断负环,今天刚回。。 【例题】poj3259 题目大意:当农场主 John 在开垦他的农场时,他发现了许多奇怪的昆虫洞。这些昆虫洞是单向的,并且可以把你从入口送到出口,并且使得时间倒退一段时间。 John 的每个农场包含 N(1≤N≤500)块地,编号从 1~N,这 ...
分类:
其他好文 时间:
2016-09-10 17:31:37
阅读次数:
177
Bellman-Ford可以求有负权的图的最短路,也可以判断是否有负环存在。 单源最短路模板 如果没有环,最多更新n-1次,n是点的个数,如果更新了n次,证明图中有环。因为求的是最短路,所以一般判断的是负环,正环也可以判断的。 poj3259 Wormholes 求是否存在负环 #include < ...
分类:
编程语言 时间:
2016-09-01 21:31:27
阅读次数:
220
Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 44261 Accepted: 16285 Description While exploring his many farms, Farmer John has discovere ...
分类:
其他好文 时间:
2016-08-12 23:39:50
阅读次数:
230
DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path that delivers you to its destination at a t...
分类:
编程语言 时间:
2016-08-12 18:29:06
阅读次数:
222
题意:有n个顶点,m条边,然后有w个洞,过每个洞的时间为-ti,求是否会时光倒流 分析:就是求是否存在负圈,用Bellman-Floyd判定是否存在负圈即可,注意是无向图,所以路径是双向可达的 1 #include <iostream> 2 #include <cstdio> 3 #include ...
分类:
其他好文 时间:
2016-07-19 13:37:53
阅读次数:
113
两道以SPFA算法求解的最短路问题,比较水,第二题需要掌握如何判断负权值回路。 ...
分类:
其他好文 时间:
2016-05-09 23:30:20
阅读次数:
313