summaryrefslogtreecommitdiff
path: root/datastructures/test/lazyPropagation.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
commit98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch)
tree5113d5cc24d1ad5f93810b6442ce584a36950dc8 /datastructures/test/lazyPropagation.cpp
parentad3856a6b766087df0036de0b556f4700a6498c9 (diff)
parent8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff)
mzuenni tests
Diffstat (limited to 'datastructures/test/lazyPropagation.cpp')
-rw-r--r--datastructures/test/lazyPropagation.cpp102
1 files changed, 0 insertions, 102 deletions
diff --git a/datastructures/test/lazyPropagation.cpp b/datastructures/test/lazyPropagation.cpp
deleted file mode 100644
index df97b14..0000000
--- a/datastructures/test/lazyPropagation.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "lazyPropagation.tmp.cpp"
-
-void test(int n) {
-#ifndef SEGTREE_INIT_DEFAULT
- vector<ll> a(n);
- for (ll &x: a) x = util::randint();
- SegTree seg(a);
-#else
- ll init = util::randint();
-# ifdef SEGTREE_FIRST_NEG
- init = abs(init);
-# endif
- vector<ll> a(n, init);
- SegTree seg(n, init);
-#endif
- 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();
-#ifndef SEGTREE_FIRST_NEG
-# ifndef SEGTREE_MAX
- if (v == 0) v = 1;
-# endif
-#endif
- for (int j = l; j < r; j++) {
-#ifndef SEGTREE_MAX
- a[j] = v;
-#else
- a[j] += v;
-#endif
- }
- seg.update(l, r, v);
- }
- {
- int l = util::randint(n+1);
- int r = util::randint(n+1);
- if (l > r) swap(l, r);
-#ifndef SEGTREE_FIRST_NEG
-# ifndef SEGTREE_MAX
- ll comp = 0;
-# else
- ll comp = numeric_limits<ll>::min();
-# endif
-#else
- ll comp = numeric_limits<ll>::max();
-#endif
- for (int j = l; j < r; j++) {
-#ifndef SEGTREE_FIRST_NEG
-# ifndef SEGTREE_MAX
- comp += a[j];
-# else
- comp = max(comp, a[j]);
-# endif
-#else
- if (comp >= 0 && comp > a[j]) comp = a[j];
-#endif
- }
- assert(seg.query(l, r) == comp);
- }
-#ifdef SEGTREE_MAX
- {
- int l = util::randint(n+1);
- int r = util::randint(n+1);
- if (l > r) swap(l, r);
- ll bound = util::randint();
- int found = -1;
- for (int j = l; j < r; j++) {
- if (a[j] >= bound) {
- found = j;
- break;
- }
- }
- assert(seg.lower_bound(l, r, bound) == found);
- }
-#endif
- }
-}
-
-int main() {
- test(1000);
- test(1);
- {
-#ifndef SEGTREE_INIT_DEFAULT
- vector<ll> a;
- SegTree seg(a);
-#else
- SegTree seg(0);
-#endif
- seg.update(0, 0, util::randint());
-#ifndef SEGTREE_FIRST_NEG
-# ifndef SEGTREE_MAX
- assert(seg.query(0, 0) == 0);
-# else
- assert(seg.query(0, 0) == numeric_limits<ll>::min());
-# endif
-#else
- assert(seg.query(0, 0) == numeric_limits<ll>::max());
-#endif
- }
-}