Problem Link (Contest) - https://www.codechef.com/LOCAUG17/problems/GTREE
I tried to solve the above problem from LoC AUG 2017 and wrote a brute force solution (by doing a DFS from each node in its subtree) that fetched 30 pts but couldn't come up with an approach to solve this problem completely.
Can someone explain how to solve this problem?