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

:warning: library/TwoSat.java

Depends on

Code

package library;

import library.FastIO;
import library.AbstractGraph;
import library.Scc;

class TwoSat extends UnweightedListGraph {
	private final int n;
	private final boolean ans[];

	// O(V)
	TwoSat(int n, boolean directed) { super(n * 2, directed); this.n = n; ans = new boolean[n]; }
	TwoSat(int n) { this(n, true); }

	// O(1)
	public final void addClause(int i, boolean f, int j, boolean g) {
		FastIO.rangeCheck(i, n);
		FastIO.rangeCheck(j, n);
		add((i << 1) + (f ? 0 : 1), (j << 1) + (g ? 1 : 0));
		add((j << 1) + (g ? 0 : 1), (i << 1) + (f ? 1 : 0));
	}
	public final void addImplication(int i, boolean f, int j, boolean g) { addClause(i, !f, j, g); }
	public final void addNand(int i, boolean f, int j, boolean g) { addClause(i, !f, j, !g); }

	// O(V+E)
	public final boolean satisfiable() {
		int id[] = Scc.calIds(this);
		for(int i = 0; i < n; i++) {
			if(id[i << 1] == id[(i << 1) | 1]) return false;
			ans[i] = id[i << 1] < id[(i << 1) | 1];
		}
		return true;
	}
	public final boolean[] cal() { satisfiable(); return ans; }
}
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