Help in question TREE3: April LunchTime

I tried out the problem https://www.codechef.com/problems/TREE3 from April 18 LUNCHTIME. Can anyone help me to find out where I am going wrong.
I used BFS to find out the count of each node in the tree whether it is connected to ‘x’ number of nodes, where x is divisible by 3.
Link to my code: https://www.codechef.com/viewsolution/18390307
Thanks in advance :slight_smile:

yours solution fails for:

1
7
1 2
1 3
1 4
1 5
2 6
2 7
1 Like

Can you explain the approach how to solve it