20 inline explicit fenwick_tree(
const std::vector<T>& v) noexcept : n(
int(v.size())) {
21 tree = std::vector<T>(n, 0);
22 for (
int i = 0; i < n; i++) {
34 for (; k >= 0; k = (k & (k + 1)) - 1) {
46 inline T
sum(
int a,
int b) {
return sum(b) -
sum(a - 1); }
54 for (; k < n; k = k | (k + 1)) {
T sum(int k)
sum query function
Definition fenwick_tree.h:32
T sum(int a, int b)
sum query function(from index a to b)
Definition fenwick_tree.h:46
void update(int k, int x)
update query function
Definition fenwick_tree.h:53
fenwick_tree(const std::vector< T > &v) noexcept
default constructor of fenwick tree class
Definition fenwick_tree.h:20