Wrong answer on submit

my code is giving wrong answer, please check it :- https://ide.codingblocks.com/s/290308

Hi it is not mentioned though but it is directed graph so u need to apply dfs and cant just count the degree and maintain the count of children for every node and at last just compare the child_count of every node with its parent’s child_count .
Fairly easy questions. And do remember that there may be more than one components so u might have to apply dfs quite a few times.