MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / fenwick_tree_sq

Class fenwick_tree_sq

code/data-structures/fenwick_tree.cpp:12–20  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 int rsq(int a, int b) { return query(b) - query(a - 1); }
11};
12struct fenwick_tree_sq {
13 int n; fenwick_tree x1, x0;
14 fenwick_tree_sq(int _n) : n(_n), x1(fenwick_tree(n)),
15 x0(fenwick_tree(n)) { }
16 // insert f(y) = my + c if x <= y
17 void update(int x, int m, int c) {
18 x1.update(x, m); x0.update(x, c); }
19 int query(int x) { return x*x1.query(x) + x0.query(x); }
20};
21void range_update(fenwick_tree_sq &s, int a, int b, int k) {
22 s.update(a, k, k * (1 - a)); s.update(b+1, -k, k * b); }
23int range_query(fenwick_tree_sq &s, int a, int b) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected