Centroid decomposition is a relatively common method used to solve trickier problems on trees. For a long time I've wanted to make a nice and simple template for centroid decomposition, something that you can just copy paste into your code. This code is the result of those ideas. I'm really happy with the result.
Centroid decomposition is a relatively common method used to solve trickier problems on trees. For a long time I've wanted to make a nice and simple template for centroid decomposition, something that you can just copy paste into your code. This code is the result of those ideas. I'm really happy with the result.