@shangjingbo: thanks. I couldn’t understand because of not knowing LCT well . Now I have read it and therefore understood what your solution meant.
i got it!! in dsu whenever we are adding a node and if the parent of any node changes then we can store it in a vector and then redo those steps one by one from last(cost me a few WA)
3 Likes
But how do you redo those steps?
could anyone provide an understanable code of sqrt decomposition , ive gone through the solutions above but unable to keep tract as this is new topic for me