It seems my code is correct for problem D - Click Here
But I am getting WA in it, I have also covered the corner case (didn’t consider 1 as the special city).
I ran a DFS and calculated the distances of the leaf nodes(special cities) and then I greedily assigned the special cities to the people.
Can anyone point out the mistake, where I am going wrong?
Thank you brother but I don’t get it what difference it makes by taking capital city also. I mean the problem setters purposefully use these kind of wierd and unnecessary condition to penalize or waste time of users. I really don’t find the need of such unnecessary confusions in problem statements as it teaches nothing