How to handle updates in DSU on trees

Правка en3, от huzaifa242, 2019-05-28 13:55:29

I read this Blog on DSU on trees.

Now, I have a doubt.

Given a tree with n nodes and each node has some color c[i], following query needs to be answered

1 x y: change color of node x to y

2 u c: count all the nodes with color c in subtree of u.

How to approach this??

Thanks for help in advance.

Теги dsu, trees

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский huzaifa242 2019-05-28 13:55:29 5 Tiny change: 'I read your [this Blo' -> 'I read [this Blo'
en2 Английский huzaifa242 2019-05-28 13:52:08 2 Tiny change: 'e x to y\n2 u c: c' -> 'e x to y\n\n2 u c: c'
en1 Английский huzaifa242 2019-05-28 13:38:42 397 Initial revision (published)