Persistent Centroid Tree

I have described about Centroid Decomposition in my earlier blog post (original @ quora). I had authored a problem on codeforces which involves a nice reduction of making the centroid tree persistent, which enables us to perform more powerful operations in sublinear complexity. I call the trick Persistent Centroid Tree. This article is to give some visibility to the problem and the trick explained by me in the editorial of the problem.  The links to the problem and the editorial are given below.


Editorial & Explanation:

If you have seen problems that require a similar trick, or can be solved more efficiently using this trick, please comment below and I’ll create a list here.

Happy Coding!