Lazy Segment Tree
Data structure for arrays of monoids and its endomorphism monoid that supports:
- range update:
- range query: find
__init__
Arguments
A: list[T]: array of monoiddot: Callable[[T, T], T]: binary operator corresponding toe: T: identity element ofcompose: Callable[[U, U], U]: binary operator corresponding toid: U: identity element ofact: Callable[[T, U], T]: binary operator corresponding to
Complexities
- time:
- space:
where represents the length of A.
act
Updates the subarray with the endomorphism .
Arguments
l: int: left endpoint of the range (inclusive)r: int: right endpoint of the range (exclusive)f: U: endomorphism to act on the subarray
Complexities
prod
Calculates the product of the subarray .
Arguments
l: int: left endpoint of the range (inclusive)r: int: right endpoint of the range (exclusive)
Returns
T:
