Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 37906   Accepted: 13954 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-way p…
题目链接:http://poj.org/problem?id=3259 题目大意是给你n个点,m条双向边,w条负权单向边.问你是否有负环(虫洞). 这个就是spfa判负环的模版题,中间的cnt数组就是记录这个点松弛进队的次数,次数超过点的个数的话,就说明存在负环使其不断松弛. #include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace st…
原题链接:http://poj.org/problem?id=3259 题意 有个很厉害的农民,它可以穿越虫洞去他的农场,当然他也可以通过道路,虫洞都是单向的,道路都是双向的,道路会花时间,虫洞会倒退时间,问你这个农民可不可以回到起点,并且在他出发的时间之前. 题解 就虫洞用负边链接,然后判断是否有负环即可. 代码 #include<iostream> #include<cstring> #include<vector> #include<string> #…
Wormholes Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 46123 Accepted: 17033 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-way path…
Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 36425   Accepted: 13320 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-way p…
题意 : 给出 N 个点,以及 M 条双向路,每一条路的权值代表你在这条路上到达终点需要那么时间,接下来给出 W 个虫洞,虫洞给出的形式为 A B C 代表能将你从 A 送到 B 点,并且回到 C 个时间点之前,也就是时光倒流了 C 个时间并且此时你在 B 点,现在问你是否能够在图上的这些点中走,使得在某一个点刚好碰到之前的自己 分析 : 冷静分析一下,只要是有负权回路的某一条边属于虫洞的,那么肯定是能在这个环上一直绕,直到遇到之前的自己,如果将虫洞看作一条负权边的话,那么问题就变成了只要存在负…
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-way path that delivers you to its destination at a time that is BEFORE you entered the wormhole! Eac…
题意: 给一个混合图,求判断是否有负环的存在,若有,输出YES,否则NO.有重边. 思路: 这是spfa的功能范围.一个点入队列超过n次就是有负环了.因为是混合图,所以当你跑一次spfa时发现没有负环,但是负环仍可能存在,因为有向边! 但是单源最短路也有起点啊,难道穷举起点?不用,负环是必须有某些边是带负权的,那么我们只要穷举负权边的起点就行了,因为单单跑一次spfa不能保证能遍历所有点,但是如果穷举负权边起点还没有找到负环,那么负环不可能存在(剩下的都是正权,怎么可能有负环). //#incl…
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-way path that delivers you to its destination at a time that is BEFORE you entered the wormhole! Eac…
 POJ 3259 Wormholes Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu   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-way…