pub struct EulerTour<K>where
K: EulerTourKind,{
pub root: usize,
pub vidx: Vec<[usize; 2]>,
pub eidx: Vec<[usize; 2]>,
pub size: usize,
_marker: PhantomData<fn() -> K>,
}Fields§
§root: usize§vidx: Vec<[usize; 2]>§eidx: Vec<[usize; 2]>§size: usize§_marker: PhantomData<fn() -> K>Implementations§
Source§impl EulerTour<FirstLast>
impl EulerTour<FirstLast>
pub fn get<T>(&self, u: usize, f: impl FnMut(usize) -> T) -> T
Sourcepub fn update<T>(&self, u: usize, x: T, invx: T, f: impl FnMut(usize, T))
pub fn update<T>(&self, u: usize, x: T, invx: T, f: impl FnMut(usize, T))
Examples found in repository?
crates/aizu_online_judge/src/grl/grl_5_d.rs (line 31)
15pub fn grl_5_d(reader: impl Read, writer: impl Write) {
16 prepare_io!(reader, writer);
17 sc!(n, c: [SizedCollect<usize>; iter n]);
18 let edges = c
19 .enumerate()
20 .flat_map(|(u, it)| it.into_iter().map(move |v| (u, v)))
21 .collect();
22 let graph = UndirectedSparseGraph::from_edges(n, edges);
23 let et = graph.path_euler_tour_builder(0).build();
24 let mut bit = BinaryIndexedTree::<AdditiveOperation<_>>::new(et.size);
25
26 sc!(q);
27 for _ in 0..q {
28 sc!(query: Query);
29 match query {
30 Query::Add { v, w } => {
31 et.update(v, w, -w, |k, x| bit.update(k, x));
32 }
33 Query::Get { u } => {
34 let ans = et.fold(u, |k| bit.accumulate(k));
35 pp!(ans);
36 }
37 }
38 }
39}Sourcepub fn fold<T>(&self, u: usize, f: impl FnMut(usize) -> T) -> T
pub fn fold<T>(&self, u: usize, f: impl FnMut(usize) -> T) -> T
Examples found in repository?
crates/aizu_online_judge/src/grl/grl_5_d.rs (line 34)
15pub fn grl_5_d(reader: impl Read, writer: impl Write) {
16 prepare_io!(reader, writer);
17 sc!(n, c: [SizedCollect<usize>; iter n]);
18 let edges = c
19 .enumerate()
20 .flat_map(|(u, it)| it.into_iter().map(move |v| (u, v)))
21 .collect();
22 let graph = UndirectedSparseGraph::from_edges(n, edges);
23 let et = graph.path_euler_tour_builder(0).build();
24 let mut bit = BinaryIndexedTree::<AdditiveOperation<_>>::new(et.size);
25
26 sc!(q);
27 for _ in 0..q {
28 sc!(query: Query);
29 match query {
30 Query::Add { v, w } => {
31 et.update(v, w, -w, |k, x| bit.update(k, x));
32 }
33 Query::Get { u } => {
34 let ans = et.fold(u, |k| bit.accumulate(k));
35 pp!(ans);
36 }
37 }
38 }
39}Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for EulerTour<K>
impl<K> RefUnwindSafe for EulerTour<K>
impl<K> Send for EulerTour<K>
impl<K> Sync for EulerTour<K>
impl<K> Unpin for EulerTour<K>
impl<K> UnsafeUnpin for EulerTour<K>
impl<K> UnwindSafe for EulerTour<K>
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