package POJ; import java.util.*; public class POJ_3259 { static int f,n,m,w; public int from,to; public double rate,commisions; static int edges;//边数 static class edge{ public int from,to,se; edge(){} edge(int from,int to,int se){ this.from=from;this.to=to;this.se=se;...
package pro.proclass.chaopengfan; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer;publicclassVjudgeN {staticclassEdge {ints;inte;intv;publicEdge(ints,inte,intv) {this.s =s;this.e =e;this.v =v; } }publicstaticv...
首先这个可以用Floyd去跑一遍,然后遍历每个点看看有没有能得到负权的点,想看Floyd做法的可以看看这篇博客:POJ 3259 Wormholes(Floyd判负环),这篇博客是用spfa去跑的,从一个点出发,我们只需要看在这个图中有没有负环存在(就是一个环的权值和为负的),如果有的话,我们就可以以这个负环中的任意一点为起点,最终...
To help FJ find out whether this is possible or not, he will supply you with complete maps to F (1 ≤ F ≤ 5) of his farms. No paths will take longer than 10,000 seconds to travel and no wormhole can bring FJ back in time by more than 10,000 seconds. Input Line 1: A single...
Wormholes Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 6 Accepted Submission(s) : 2 Problem Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it...
POJ 3259 Wormholes (判负环) Wormholes Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 6 Accepted Submission(s) : 2 Problem Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A ...
思路:用bellman-ford 判断有没有负权回路,如果有他就能看到自己。 不过,我认为应该判断每个点有没有负权回路,而不仅仅只判断第一个点就行了(如果某位大牛路过看到,觉得理解不对 希望多多指教) #include<iostream> #include<cstdio> #include<cstring> ...
As FJ is an avid time-traveling fan, he wants to do the following: start at some field, travel through some paths and wormholes, and return to the starting field a time before his initial departure. Perhaps he will be able to meet himself :) . ...