summaryrefslogtreecommitdiff
path: root/datastructures/test/fenwickTree.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-03-10 20:48:51 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-03-10 20:48:51 +0100
commitcd870938f6cf266292e0e5cecb2d96d604b2ad9d (patch)
treea1615ad3cac2c505c33e9952fc72cced5931d6c9 /datastructures/test/fenwickTree.cpp
parent0cebc901e79c21168601071e29ed8e4f4b6f9505 (diff)
make Fenwick Tree prefix sum exclusive
Diffstat (limited to 'datastructures/test/fenwickTree.cpp')
-rw-r--r--datastructures/test/fenwickTree.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/datastructures/test/fenwickTree.cpp b/datastructures/test/fenwickTree.cpp
index 4bc812a..f9dd619 100644
--- a/datastructures/test/fenwickTree.cpp
+++ b/datastructures/test/fenwickTree.cpp
@@ -10,10 +10,10 @@ void test(int n) {
update(p, delta);
naive[p] += delta;
- int r = util::randint(n+1) - 1;
+ int r = util::randint(n+1);
ll naive_result = 0;
- for (int i = 0; i <= r; i++) naive_result += naive[i];
+ for (int i = 0; i < r; i++) naive_result += naive[i];
ll fenwick_result = prefix_sum(r);
assert(naive_result == fenwick_result);
}