Problem 1719 · Hard

Number Of Ways To Reconstruct A Tree

Nodes related to every other node in a group must form a chain at its top, so the tree is peeled layer by layer and any tie in a chain doubles the count.

Open the interactive visualisation