CP Python LibraryGitHub

Segment Tree

Data structure for arrays of monoids (M,,e)(M, \cdot, e) that supports:

__init__

Arguments

Complexities

where nn represents the length of A.

__getitem__

Returns the i-th element of the array.

Arguments

Returns

Complexities

__setitem__

Sets the i-th element of the array

Arguments

Complexities

prod

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

Arguments

Returns

Complexities

bisect_left

Finds the largest rr such that product of subarray A[l:r]A[l:r] is less than xx.

Arguments

Returns

Complexities

Code Test