summaryrefslogtreecommitdiff
path: root/test/datastructures/dynamicConvexHull.lichao.cpp
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2024-08-06 16:14:04 +0200
committermzuenni <michi.zuendorf@gmail.com>2024-08-06 16:14:04 +0200
commitd88debc398f18d4e3d1c53d221dffe3981f35e41 (patch)
tree6be8f25694423d3ad2fe044eb237492ac687e143 /test/datastructures/dynamicConvexHull.lichao.cpp
parentbbec09408867e82fb9dd9b242e6d99014f9534b6 (diff)
add another test
Diffstat (limited to 'test/datastructures/dynamicConvexHull.lichao.cpp')
-rw-r--r--test/datastructures/dynamicConvexHull.lichao.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/datastructures/dynamicConvexHull.lichao.cpp b/test/datastructures/dynamicConvexHull.lichao.cpp
new file mode 100644
index 0000000..6ab55f0
--- /dev/null
+++ b/test/datastructures/dynamicConvexHull.lichao.cpp
@@ -0,0 +1,38 @@
+#include "../util.h"
+constexpr ll INF = LL::INF;
+constexpr ll inf = LL::INF;
+#include <datastructures/dynamicConvexHull.cpp>
+#include <datastructures/lichao.cpp>
+
+void stress_test(ll range) {
+ ll queries = 0;
+ for (int tries = 0; tries < 1000; tries++) {
+ int n = Random::integer<int>(1, 100);
+ xs = Random::distinct(n, -range, range);
+ sort(all(xs));
+
+ HullDynamic hd;
+ Lichao lichao;
+ for (int i = 0; i < 1000; i++) {
+ ll m = Random::integer<ll>(-range, range);
+ ll c = Random::integer<ll>(-range, range);
+ hd.add(m, c);
+ lichao.insert({-m, -c});
+
+ for (ll x : xs) {
+ ll gotA = hd.query(x);
+ ll gotB = -lichao.query(x);
+
+ if (gotA != gotB) cerr << "gotA: " << gotA << ", gotB: " << gotB << FAIL;
+ queries++;
+ }
+ }
+ }
+ cerr << "tested random queries: " << queries << endl;
+}
+
+int main() {
+ stress_test(100);
+ stress_test(1'000);
+ stress_test(1'000'000);
+}