How to use segment trees on rooted trees?

Revision en1, by WalidMasri, 2016-01-30 18:46:17

Hello CodeForces!

I have the following problem : Given a rooted tree, i have 2 types of queries: 1 q : Mark the Node q colored/uncolored. (Initially they are all uncolored). 2 p : Get the sum of the colored nodes in the p-subtree.

How can i solve this problem using segmentTrees? I couldn't figure out the part where i need to transform my rooted tree into an array, how to do that as well?

Thanks!

Tags segment tree, trees, queries on tree

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English WalidMasri 2016-01-30 18:46:17 497 Initial revision (published)