Problem: Given an array a1, a2, ..., an (1 <= n <= 1e6) and q queries, for each query has two types.
1 l r x: a[i] = min(a[i], x) (l <= i <= r).
2 i : print value in position i.
I dont know use lazy update to solve operator 1, help me pls (sorry i'm poor E).
Auto comment: topic has been updated by _Bunny (previous revision, new revision, compare).
instead of setting tree[id].min value to x just set it to min(tree[id].min, x)
tr[x].val = min (tr[x] . val , v);
Above problem can be solved using a simple segment tree, without doing lazy propagation since the operation 1 is commutative.
To learn "Lazy propagation" you can refer to "Segment Tree, part-2" of Edu section.
From now, lazy is also a new category just like greedy
You don't need lazy, Use the approach of the cses Range Update Queries.
Here: Code