CP Python LibraryGitHub

Lazy Segment Tree

Data structure for arrays of monoids (M,,e)(M, \cdot, e) and its endomorphism monoid (End(M),,id)(\text{End}(M), \circ, \text{id}) that supports:

__init__

Arguments

Complexities

where nn represents the length of A.

act

Updates the subarray A[l:r]A[l:r] with the endomorphism ff.

Arguments

Complexities

prod

Calculates the product of the subarray A[l:r]A[l:r].

Arguments

Returns

Complexities

Code Test