poj 3259 Wormholes 判断负权值回路】的更多相关文章

Wormholes Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u   Java class name: Main [Submit] [Status] [Discuss] Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A w…
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…
题意: 农夫约翰农场里发现了很多虫洞,他是个超级冒险迷,想利用虫洞回到过去,看再回来的时候能不能看到没有离开之前的自己,农场里有N块地,M条路连接着两块地,W个虫洞,连接两块地的路是双向的,而虫洞是单向的,去到虫洞之后时间会倒退T秒,如果能遇到离开之前的自己就输出YES,反之就是NO. 分析: 就是求一幅图中有没有负权环路, 可以bellman n-1次后再跑一次看看能不能更新, 能更新说明有环. 也可以spfa记录入队次数, 入队次数大于等于N说明有负权环路 #include<cstdio>…
 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…
题意:John的农场里n块地,m条路连接两块地,k个虫洞,虫洞是一条单向路,不但会把你传送到目的地,而且时间会倒退Ts.我们的任务是知道会不会在从某块地出发后又回来,看到了离开之前的自己. 思路:虫洞连接的边是负权值的,如果途中存在一个负环的话,他可以沿着这个换一直走,时间肯定为负值. #include<string.h> #include<stdio.h> const int N=510; const int inf=0x3fffffff; int start,num,n,dis…
//判断负环 dist初始化为正无穷 //正环 负无穷 #include<iostream> #include<cstring> #include<queue> #include<algorithm> using namespace std; , M = ; int dist[N]; int h[N], e[M], w[M], ne[M], idx; int n,m,z; void add(int a,int b,int c) { e[idx]=b; w[i…
题目链接:http://poj.org/problem?id=3259 Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 45077   Accepted: 16625 Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is ver…
题意:给你m条路花费时间(双向正权路径),w个虫洞返回时间(单向负权路径),问你他能不能走一圈回到原点之后,时间倒流. 思路:题意有点难看懂,我们建完边之后找一下是否存在负权回路,存在则能,反之不能.判断负权回路可以用一个cnt,这个spfa板子里有. 代码: #include<cstdio> #include<set> #include<vector> #include<cmath> #include<queue> #include<cs…
Wormholes Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 42366 Accepted: 15560 传送门 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…
POJ 3259 Wormholes(最短路径,求负环) 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…