From f76378213f4dd463f9bce208a7371cbe23726d9e Mon Sep 17 00:00:00 2001 From: iagorrr Date: Tue, 13 Aug 2024 19:50:54 -0300 Subject: [PATCH] fix error in Lazy Segment Tree Increment Update Query Max --- .../Increment Update Query Max.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/algorithms/data-structures/Segment Tree Range Update (bottom up)/Increment Update Query Max.cpp b/algorithms/data-structures/Segment Tree Range Update (bottom up)/Increment Update Query Max.cpp index 0d067b16..982e9e79 100644 --- a/algorithms/data-structures/Segment Tree Range Update (bottom up)/Increment Update Query Max.cpp +++ b/algorithms/data-structures/Segment Tree Range Update (bottom up)/Increment Update Query Max.cpp @@ -15,6 +15,7 @@ inline QueryT combine(QueryT ln, QueryT rn, pii lr1, pii lr2){ using LazyT=SegT; inline QueryT applyLazyInQuery(QueryT q, LazyT l, pii lr){ + if(q.v==QueryT().v)q.v=0; q.v+=l; return q; } @@ -26,6 +27,7 @@ inline LazyT applyLazyInLazy(LazyT a,LazyT b){ using UpdateT=SegT; inline QueryT applyUpdateInQuery(QueryT q,UpdateT u, pii lr){ + if(q.v==QueryT().v)q.v=0; q.v+=u; return q; }