competitive-programming-java-library

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub shun0923/competitive-programming-java-library

:heavy_check_mark: library/BellmanFord.java

Depends on

Verified with

Code

package library;

import java.util.*;
import library.FastIO;
import library.AbstractGraph;


final class BellmanFord {
	// O(VE)
	public static final long[] dist(final AbstractGraph<? extends WeightedNode, WeightedEdge> g, final int start) { return dist(g, start, null, null); }
	public static final long[] dist(final AbstractGraph<? extends WeightedNode, WeightedEdge> g, final int start, final int[] prv) { return dist(g, start, prv, null); }
	public static final long[] dist(final AbstractGraph<? extends WeightedNode, WeightedEdge> g, final int start, final int[] prv, final WeightedEdge[] prvEdge) { return dist(g.numNode, g.edges(), start, prv, prvEdge); }
	public static final long[] dist(final int numNode, final WeightedNode edges, final int start) { return dist(numNode, edges, start, null, null); }
	public static final long[] dist(final int numNode, final WeightedNode edges, final int start, final int[] prv) { return dist(numNode, edges, start, prv, null); }
	public static final long[] dist(final int numNode, final WeightedNode edges, final int start, final int[] prv, final WeightedEdge[] prvEdge) {
		FastIO.rangeCheck(start, numNode);
		long dist[] = new long[numNode];
		if(prv != null) Arrays.fill(prv, -1);

		Arrays.fill(dist, FastIO.INF);
		dist[start] = 0;
		for(int i = 0; i < numNode - 1; i ++) {
			for(WeightedEdge e : edges) {
				long updated = dist[e.source] + e.cost;
				if(!FastIO.isPlusINF(dist[e.source]) && dist[e.target] > updated) {
					dist[e.target] = updated;
					if(prv != null) prv[e.target] = e.source;
					if(prvEdge != null) prvEdge[e.target] = e;
				}
			}
		}
		for(int i = 0; i < numNode; i ++) {
			for(WeightedEdge e : edges) {
				if(!FastIO.isPlusINF(dist[e.source]) && dist[e.target] > dist[e.source] + e.cost) {
					dist[e.target] = - FastIO.INF;
				}
			}
		}
		return dist;
	}
}
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
    bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/onlinejudge_verify/languages/user_defined.py", line 71, in bundle
    return subprocess.check_output(shlex.split(command))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['false']' returned non-zero exit status 1.
Back to top page