diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-04-28 19:44:14 +0200 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2024-04-28 19:44:14 +0200 |
| commit | 2d09c91b8e3a4482ed94fab44ec1aab42ab72da9 (patch) | |
| tree | 6ed90ac02b644e68bf2241e716a77ce547f82e5a /datastructures/test/segmentTree2.cpp | |
| parent | d6d3b6183df2e1d40154f406916993f9b15b3cae (diff) | |
remove all() and sz() from segment tree and add tests
Diffstat (limited to 'datastructures/test/segmentTree2.cpp')
| -rw-r--r-- | datastructures/test/segmentTree2.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/datastructures/test/segmentTree2.cpp b/datastructures/test/segmentTree2.cpp new file mode 100644 index 0000000..f403a1d --- /dev/null +++ b/datastructures/test/segmentTree2.cpp @@ -0,0 +1,26 @@ +#include "segmentTree2.tmp.cpp" + +void test(int n) { + vector<ll> a(n); + for (ll &x: a) x = util::randint(); + SegTree seg(a); + for (int i = 0; i < 5*n; i++) { + { + int l = util::randint(n+1); + int r = util::randint(n+1); + if (l > r) swap(l, r); + ll v = util::randint(); + for (int i = l; i < r; i++) a[i] += v; + seg.modify(l, r, v); + } + { + int j = util::randint(n); + assert(seg.query(j) == a[j]); + } + } +} + +int main() { + test(1000); + test(1); +} |
