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/FenwickTree.java

Depends on

Verified with

Code

package library;

import library.FastIO;

class FenwickTree {
	int n;
	long nodes[];

	FenwickTree(int n) { FastIO.nonNegativeCheck(n); init(n); } // O(N)
	FenwickTree(long[] a) { init(a.length); for(int i = 0; i < n; i ++) add(i, a[i]); }// O(NlogN)
	void init(int n) {
		FastIO.nonNegativeCheck(n);
		this.n = n;
		nodes = new long[n];
	}

	void add(int a, long x) { // O(logN)
		FastIO.rangeCheck(a, n);
		a ++;
		while(a <= n) {
			nodes[a - 1] += x;
			a += a & - a;
		}
	}
	long sum(int r) { // return sum of [0, r) // O(logN)
		FastIO.inclusiveRangeCheck(r, n);
		long sum = 0;
		while(r > 0) {
			sum += nodes[r - 1];
			r -= r & - r;
		}
		return sum;
	}
	long sum(int l, int r) { // return sum of [l, r) // O(logN)
		FastIO.inclusiveRangeCheck(l, n);
		FastIO.inclusiveRangeCheck(r, n);
		if(l > r) return 0;
		else return sum(r) - sum(l);
	}
}
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