class

AtCoder::LazySegTree(S, F)

Inherits Reference / Object

Implements atcoder::lazy_segtree.

The identity element will be implicitly defined as nil, so you don't have to manually define it. In the other words, you cannot include nil into an element of the monoid.

Similarly, the identity map of F will be implicitly defined as nil, so you don't have to manually define it. In the other words, you cannot include nil into an element of the set F.

op = ->(a : Int32, b : Int32) { [a, b].min }
mapping = ->(f : Int32, x : Int32) { f }
composition = ->(a : Int32, b : Int32) { a }
tree = AtCoder::LazySegTree(Int32, Int32).new((0...100).to_a, op, mapping, composition)
tree[10...50] # => 10
tree[20...60] = 0
tree[50...80] # => 0

Constructors

new(values : Array(S), operator : S, S -> S, application : F, S -> S, composition : F, F -> F)
Source

Instance methods

[](index : Int)

Implements atcoder::lazy_segtree.get(index).

Source
[](range : Range)

Implements atcoder::lazy_segtree.prod(left, right).

Source
[]=(index : Int, applicator : F)

Implements atcoder::lazy_segtree.apply(index, applicator).

Source
[]=(range : Range, applicator : F)

Implements atcoder::lazy_segtree.apply(left, right, applicator). ameba:disable Metrics/CyclomaticComplexity

Source
all_prod

Implements atcoder::lazy_segtree.all_prod().

Source
max_right(left, e : S | Nil = nil, & : S -> Bool)

Implements atcoder::lazy_segtree.max_right(left, g).

Source
min_left(right, e : S | Nil = nil, & : S -> Bool)

Implements atcoder::lazy_segtree.min_left(right, g).

Source
set(index : Int, value : S)

Implements atcoder::lazy_segtree.set(index, applicator).

Source