From 1074350c83504afe32cf4a14f43da82431d93d91 Mon Sep 17 00:00:00 2001 From: MZuenni Date: Wed, 1 Mar 2023 13:41:30 +0100 Subject: made code easier to read --- datastructures/dynamicConvexHull.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'datastructures/dynamicConvexHull.cpp') diff --git a/datastructures/dynamicConvexHull.cpp b/datastructures/dynamicConvexHull.cpp index f88b2ad..7ea1977 100644 --- a/datastructures/dynamicConvexHull.cpp +++ b/datastructures/dynamicConvexHull.cpp @@ -17,12 +17,18 @@ struct HullDynamic : multiset> { } void add(ll m, ll b) { - auto z = insert({m, b, 0}), y = z++, x = y; - while (isect(y, z)) z = erase(z); - if (x != begin() && isect(--x, y)) isect(x, y = erase(y)); - while ((y = x) != begin() && (--x)->p >= y->p) - isect(x, erase(y)); - } + auto x = insert({m, b, 0}); + while (isect(x, next(x))) erase(next(x)); + if (x != begin()) { + x--; + if (isect(x, next(x))) { + erase(next(x)); + isect(x, next(x)); + }} + while (x != begin() && prev(x)->p >= x->p) { + x--; + isect(x, erase(next(x))); + }} ll query(ll x) { auto l = *lower_bound(x); -- cgit v1.2.3