Demo with two range actions and f and g overlapping out of order.
>>> range_update(table, 3, 10, lambda x: "f")
>>> range_update(table, 5, 15, lambda x: "g")
>>> debugprint(table)
| 0 |
| 0 | 0 |
| 0 | f | g | 0 |
| 0 | 0 | 0 | g | f | 0 | g | 0 |
|0|0|0|f|0|g|0|0|0|0|0|0|0|0|g|0|
The right way to do it when it is not commutative
lambda x: "g" is the lower propagation binary operation lambda x, y: x if x else y with "g" in x.
python>>> table = [0] * SEGTREE_SIZE
>>> range_update(table, 3, 10, lambda x: "f")
>>> down_propagate(table, up(5), lambda x, y: x if x else y, 0)
>>> down_propagate(table, up(15), lambda x, y: x if x else y, 0)
>>> debugprint(table)
| 0 |
| 0 | 0 |
| 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | f | f | 0 | 0 | 0 |
|0|0|0|f|f|f|0|0|0|0|0|0|0|0|0|0|
>>> range_update(table, 5, 15, lambda x: "g")
>>> debugprint(table)
| 0 |
| 0 | 0 |
| 0 | 0 | g | 0 |
| 0 | 0 | 0 | g | f | 0 | g | 0 |
|0|0|0|f|f|g|0|0|0|0|0|0|0|0|g|0|
Appendix: Range of influence of propagation downwards.
This page is auto-translated from /nishio/双対セグメント木の下への伝搬 using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I'm very happy to spread my thought to non-Japanese readers.