pub struct SegmentTree<T, F> { /* private fields */ }
Expand description
注意⚠ この実装は遅いので time limit の厳しい問題には代わりに ACL のセグメントツリーを使うこと。
セグメントツリーです。
Implementations§
Source§impl<T, F> SegmentTree<T, F>
impl<T, F> SegmentTree<T, F>
Sourcepub fn new(n: usize, e: T, multiply: F) -> Self
pub fn new(n: usize, e: T, multiply: F) -> Self
長さ n
の列を初期値 e
で初期化します。
multiply
は fold に使う二項演算です。
Sourcepub fn fold(&self, range: impl RangeBounds<usize>) -> T
pub fn fold(&self, range: impl RangeBounds<usize>) -> T
range
が l..r
として、multiply(l番目の要素, multiply(..., multiply(r-2番目の要素, r-1番目の要素)))
の値を返します。
Trait Implementations§
Source§impl<T: Clone, F: Clone> Clone for SegmentTree<T, F>
impl<T: Clone, F: Clone> Clone for SegmentTree<T, F>
Source§fn clone(&self) -> SegmentTree<T, F>
fn clone(&self) -> SegmentTree<T, F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T, F> Debug for SegmentTree<T, F>where
T: Debug,
impl<T, F> Debug for SegmentTree<T, F>where
T: Debug,
Auto Trait Implementations§
impl<T, F> Freeze for SegmentTree<T, F>
impl<T, F> RefUnwindSafe for SegmentTree<T, F>where
T: RefUnwindSafe,
F: RefUnwindSafe,
impl<T, F> Send for SegmentTree<T, F>
impl<T, F> Sync for SegmentTree<T, F>
impl<T, F> Unpin for SegmentTree<T, F>
impl<T, F> UnwindSafe for SegmentTree<T, F>where
T: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more