CompProgLibrary

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

View the Project on GitHub RTnF/CompProgLibrary

:warning: Binary Indexed Tree (Fenwick Tree)
(cpp/segment_tree/binary_indexed_tree.hpp)

Depends on

Code

#pragma once
#include "template/small_template.hpp"

/**
 * @brief Binary Indexed Tree (Fenwick Tree)
 */
template <class T = ll> class BinaryIndexedTree {
  vector<T> tree; // 1-indexed
public:
  BinaryIndexedTree() {}
  BinaryIndexedTree(int n) : tree(n + 1) {}
  BinaryIndexedTree(const vector<T> &v) : tree(v.size() + 1) {
    for (int i = 0; i < (int)v.size(); i++) {
      tree[i + 1] = v[i];
    }
    for (int i = 1; i < (int)v.size(); i++) {
      tree[i + (i & -i)] += tree[i];
    }
  }
  // sum of A[0, r)
  T sum(int r) const {
    T s = 0;
    for (; r > 0; r -= (r & -r)) {
      s += tree[r];
    }
    return s;
  }
  // sum of A[l, r)
  T sum(int l, int r) const { return sum(r) - sum(l); }
  // A[i] += val
  void add(int i, T val) {
    i++;
    for (; i < (int)tree.size(); i += (i & -i)) {
      tree[i] += val;
    }
  }
};
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/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.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
    bundler.update(path)
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
    self.update(self._resolve(pathlib.Path(included), included_from=path))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 260, in _resolve
    raise BundleErrorAt(path, -1, "no such header")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: template/small_template.hpp: line -1: no such header
Back to top page