Dynamically rooted trees ?

Revision en1, by svg_af, 2016-03-06 19:04:53

Hello there

so i found this problem on spoj

we have a tree where each node has an integer weight and two types of queries

1- print sum of weights in subtree of given node

2- change root to given node

now first type of queries is no issue if the root is fixed ... i would solve it with segment tree, but changing the root kinda ruins everything

any hints about how i should think about this would be really appreciated :D

Tags tree, dynamic, root, queries

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English svg_af 2016-03-06 19:04:53 506 Initial revision (published)