Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
AtCoder.Extra.Monoid.RangeAdd
Contents
Description
Monoid action f:x→x+d.
Since: 1.0.0.0
RangeAdd
Monoid action f:x→x+d.
Example (action on Sum
)
>>>
import AtCoder.Extra.Monoid (SegAct(..), RangeAdd(..))
>>>
import AtCoder.LazySegTree qualified as LST
>>>
import Data.Semigroup (Sum(..))
>>>
seg <- LST.build @_ @(RangeAdd (Sum Int)) @(Sum Int) $ VU.generate 3 Sum -- [0, 1, 2]
>>>
LST.applyIn seg 0 3 $ RangeAdd (Sum 5) -- [5, 6, 7]
>>>
getSum <$> LST.prod seg 0 3
18
Example (action on Max
)
>>>
import AtCoder.Extra.Monoid (SegAct(..), RangeAdd(..))
>>>
import AtCoder.LazySegTree qualified as LST
>>>
import Data.Semigroup (Max(..))
>>>
seg <- LST.build @_ @(RangeAdd (Max Int)) @(Max Int) $ VU.generate 3 Max -- [0, 1, 2]
>>>
LST.applyIn seg 0 3 $ RangeAdd (Max 5) -- [5, 6, 7]
>>>
getMax <$> LST.prod seg 0 3
7
Since: 1.0.0.0
Constructors
RangeAdd a |
Instances
Constructor
unRangeAdd :: RangeAdd a -> a Source #
O(1) Retrieves the internal value of RangeAdd
.
Since: 1.1.0.0