pub struct StaticTopTreeDp<'a, C>where
C: Cluster,{
tree: &'a StaticTopTree,
vertices: Vec<<C as Cluster>::Vertex>,
edges: Vec<<C as Cluster>::Edge>,
compressed: Vec<InnerValue<<C as Cluster>::Path>>,
raked: Vec<InnerValue<<C as Cluster>::Point>>,
light_points: Vec<<C as Cluster>::Point>,
all_point: <C as Cluster>::Point,
}Fields§
§tree: &'a StaticTopTree§vertices: Vec<<C as Cluster>::Vertex>§edges: Vec<<C as Cluster>::Edge>§compressed: Vec<InnerValue<<C as Cluster>::Path>>§raked: Vec<InnerValue<<C as Cluster>::Point>>§light_points: Vec<<C as Cluster>::Point>§all_point: <C as Cluster>::PointImplementations§
Source§impl<'a, C> StaticTopTreeDp<'a, C>where
C: Cluster,
impl<'a, C> StaticTopTreeDp<'a, C>where
C: Cluster,
Sourcepub fn new(
tree: &'a StaticTopTree,
vertices: Vec<<C as Cluster>::Vertex>,
edges: Vec<<C as Cluster>::Edge>,
) -> Self
pub fn new( tree: &'a StaticTopTree, vertices: Vec<<C as Cluster>::Vertex>, edges: Vec<<C as Cluster>::Edge>, ) -> Self
Sourcepub fn set_vertex(&mut self, vertex: usize, value: <C as Cluster>::Vertex)
pub fn set_vertex(&mut self, vertex: usize, value: <C as Cluster>::Vertex)
Examples found in repository?
crates/library_checker/src/tree/point_set_tree_path_composite_sum_fixed_root.rs (line 124)
106pub fn point_set_tree_path_composite_sum_fixed_root(reader: impl Read, mut writer: impl Write) {
107 let s = read_all_unchecked(reader);
108 let mut scanner = Scanner::new(&s);
109 scan!(
110 scanner,
111 n,
112 q,
113 value: [MInt; n],
114 (graph, edges): @TreeGraphScanner::<usize, (MInt, MInt)>::new(n)
115 );
116
117 let top_tree = graph.static_top_tree(0);
118 let mut dp = top_tree.dp::<Dp>(value, edges);
119
120 for _ in 0..q {
121 scan!(scanner, query: Query);
122 match query {
123 Query::SetVertex { v, x } => {
124 dp.set_vertex(v, x);
125 writeln!(writer, "{}", dp.fold_all().sum).ok();
126 }
127 Query::SetEdge { e, a, b } => {
128 dp.set_edge(e, (a, b));
129 writeln!(writer, "{}", dp.fold_all().sum).ok();
130 }
131 }
132 }
133}More examples
crates/library_checker/src/tree/point_set_tree_path_composite_sum.rs (line 158)
140pub fn point_set_tree_path_composite_sum(reader: impl Read, mut writer: impl Write) {
141 let s = read_all_unchecked(reader);
142 let mut scanner = Scanner::new(&s);
143 scan!(
144 scanner,
145 n,
146 q,
147 value: [MInt; n],
148 (graph, edges): @TreeGraphScanner::<usize, (MInt, MInt)>::new(n)
149 );
150
151 let top_tree = graph.static_top_tree(0);
152 let mut dp = top_tree.dp::<Dp>(value, edges);
153
154 for _ in 0..q {
155 scan!(scanner, query: Query);
156 match query {
157 Query::SetVertex { v, x, r } => {
158 dp.set_vertex(v, x);
159 writeln!(writer, "{}", dp.fold_path(r).reverse.sum).ok();
160 }
161 Query::SetEdge { e, a, b, r } => {
162 dp.set_edge(e, (a, b));
163 writeln!(writer, "{}", dp.fold_path(r).reverse.sum).ok();
164 }
165 }
166 }
167}Sourcepub fn set_edge(&mut self, edge: usize, value: <C as Cluster>::Edge)
pub fn set_edge(&mut self, edge: usize, value: <C as Cluster>::Edge)
Examples found in repository?
crates/library_checker/src/tree/point_set_tree_path_composite_sum_fixed_root.rs (line 128)
106pub fn point_set_tree_path_composite_sum_fixed_root(reader: impl Read, mut writer: impl Write) {
107 let s = read_all_unchecked(reader);
108 let mut scanner = Scanner::new(&s);
109 scan!(
110 scanner,
111 n,
112 q,
113 value: [MInt; n],
114 (graph, edges): @TreeGraphScanner::<usize, (MInt, MInt)>::new(n)
115 );
116
117 let top_tree = graph.static_top_tree(0);
118 let mut dp = top_tree.dp::<Dp>(value, edges);
119
120 for _ in 0..q {
121 scan!(scanner, query: Query);
122 match query {
123 Query::SetVertex { v, x } => {
124 dp.set_vertex(v, x);
125 writeln!(writer, "{}", dp.fold_all().sum).ok();
126 }
127 Query::SetEdge { e, a, b } => {
128 dp.set_edge(e, (a, b));
129 writeln!(writer, "{}", dp.fold_all().sum).ok();
130 }
131 }
132 }
133}More examples
crates/library_checker/src/tree/point_set_tree_path_composite_sum.rs (line 162)
140pub fn point_set_tree_path_composite_sum(reader: impl Read, mut writer: impl Write) {
141 let s = read_all_unchecked(reader);
142 let mut scanner = Scanner::new(&s);
143 scan!(
144 scanner,
145 n,
146 q,
147 value: [MInt; n],
148 (graph, edges): @TreeGraphScanner::<usize, (MInt, MInt)>::new(n)
149 );
150
151 let top_tree = graph.static_top_tree(0);
152 let mut dp = top_tree.dp::<Dp>(value, edges);
153
154 for _ in 0..q {
155 scan!(scanner, query: Query);
156 match query {
157 Query::SetVertex { v, x, r } => {
158 dp.set_vertex(v, x);
159 writeln!(writer, "{}", dp.fold_path(r).reverse.sum).ok();
160 }
161 Query::SetEdge { e, a, b, r } => {
162 dp.set_edge(e, (a, b));
163 writeln!(writer, "{}", dp.fold_path(r).reverse.sum).ok();
164 }
165 }
166 }
167}Sourcepub fn fold_all(&self) -> &<C as Cluster>::Point
pub fn fold_all(&self) -> &<C as Cluster>::Point
Examples found in repository?
crates/library_checker/src/tree/point_set_tree_path_composite_sum_fixed_root.rs (line 125)
106pub fn point_set_tree_path_composite_sum_fixed_root(reader: impl Read, mut writer: impl Write) {
107 let s = read_all_unchecked(reader);
108 let mut scanner = Scanner::new(&s);
109 scan!(
110 scanner,
111 n,
112 q,
113 value: [MInt; n],
114 (graph, edges): @TreeGraphScanner::<usize, (MInt, MInt)>::new(n)
115 );
116
117 let top_tree = graph.static_top_tree(0);
118 let mut dp = top_tree.dp::<Dp>(value, edges);
119
120 for _ in 0..q {
121 scan!(scanner, query: Query);
122 match query {
123 Query::SetVertex { v, x } => {
124 dp.set_vertex(v, x);
125 writeln!(writer, "{}", dp.fold_all().sum).ok();
126 }
127 Query::SetEdge { e, a, b } => {
128 dp.set_edge(e, (a, b));
129 writeln!(writer, "{}", dp.fold_all().sum).ok();
130 }
131 }
132 }
133}Sourcepub fn fold_path(&self, vertex: usize) -> <C as Cluster>::Path
pub fn fold_path(&self, vertex: usize) -> <C as Cluster>::Path
Examples found in repository?
crates/library_checker/src/tree/point_set_tree_path_composite_sum.rs (line 159)
140pub fn point_set_tree_path_composite_sum(reader: impl Read, mut writer: impl Write) {
141 let s = read_all_unchecked(reader);
142 let mut scanner = Scanner::new(&s);
143 scan!(
144 scanner,
145 n,
146 q,
147 value: [MInt; n],
148 (graph, edges): @TreeGraphScanner::<usize, (MInt, MInt)>::new(n)
149 );
150
151 let top_tree = graph.static_top_tree(0);
152 let mut dp = top_tree.dp::<Dp>(value, edges);
153
154 for _ in 0..q {
155 scan!(scanner, query: Query);
156 match query {
157 Query::SetVertex { v, x, r } => {
158 dp.set_vertex(v, x);
159 writeln!(writer, "{}", dp.fold_path(r).reverse.sum).ok();
160 }
161 Query::SetEdge { e, a, b, r } => {
162 dp.set_edge(e, (a, b));
163 writeln!(writer, "{}", dp.fold_path(r).reverse.sum).ok();
164 }
165 }
166 }
167}Sourcefn update_from_vertex(&mut self, vertex: usize)
fn update_from_vertex(&mut self, vertex: usize)
Sourcefn update_compress(
&mut self,
id: usize,
path: <C as Cluster>::Path,
) -> <C as Cluster>::Path
fn update_compress( &mut self, id: usize, path: <C as Cluster>::Path, ) -> <C as Cluster>::Path
Examples found in repository?
crates/competitive/src/tree/static_top_tree.rs (line 555)
546 fn update_from_vertex(&mut self, mut vertex: usize) {
547 assert!(vertex < self.tree.n);
548 while vertex != usize::MAX {
549 let links = self.tree.vertex_links[vertex];
550 let base = C::add_vertex(
551 &self.light_points[vertex],
552 &self.vertices[vertex],
553 self.tree.parent_edge_ref(&self.edges, vertex),
554 );
555 let path = self.update_compress(links.compress_parent, base);
556 let point = C::add_edge(&path);
557 let point = self.update_rake(links.rake_parent, point);
558 if links.heavy_parent == usize::MAX {
559 self.all_point = point;
560 } else {
561 self.light_points[links.heavy_parent] = point;
562 }
563 vertex = links.heavy_parent;
564 }
565 }Sourcefn update_rake(
&mut self,
id: usize,
point: <C as Cluster>::Point,
) -> <C as Cluster>::Point
fn update_rake( &mut self, id: usize, point: <C as Cluster>::Point, ) -> <C as Cluster>::Point
Examples found in repository?
crates/competitive/src/tree/static_top_tree.rs (line 557)
546 fn update_from_vertex(&mut self, mut vertex: usize) {
547 assert!(vertex < self.tree.n);
548 while vertex != usize::MAX {
549 let links = self.tree.vertex_links[vertex];
550 let base = C::add_vertex(
551 &self.light_points[vertex],
552 &self.vertices[vertex],
553 self.tree.parent_edge_ref(&self.edges, vertex),
554 );
555 let path = self.update_compress(links.compress_parent, base);
556 let point = C::add_edge(&path);
557 let point = self.update_rake(links.rake_parent, point);
558 if links.heavy_parent == usize::MAX {
559 self.all_point = point;
560 } else {
561 self.light_points[links.heavy_parent] = point;
562 }
563 vertex = links.heavy_parent;
564 }
565 }Auto Trait Implementations§
impl<'a, C> Freeze for StaticTopTreeDp<'a, C>
impl<'a, C> RefUnwindSafe for StaticTopTreeDp<'a, C>where
<C as Cluster>::Point: RefUnwindSafe,
<C as Cluster>::Vertex: RefUnwindSafe,
<C as Cluster>::Edge: RefUnwindSafe,
<C as Cluster>::Path: RefUnwindSafe,
impl<'a, C> Send for StaticTopTreeDp<'a, C>
impl<'a, C> Sync for StaticTopTreeDp<'a, C>
impl<'a, C> Unpin for StaticTopTreeDp<'a, C>
impl<'a, C> UnsafeUnpin for StaticTopTreeDp<'a, C>
impl<'a, C> UnwindSafe for StaticTopTreeDp<'a, C>where
<C as Cluster>::Point: UnwindSafe,
<C as Cluster>::Vertex: UnwindSafe,
<C as Cluster>::Edge: UnwindSafe,
<C as Cluster>::Path: 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