Beautiful Vertices question Codingblocks

Sample testcase passed.
Wrong answer on Submit…

@phantom

have u check for the different component of the graph

Hanji…

check for
10
4
1 2
1 3
3 4
3 5

0

ans =1
3-> 2 child
1 parent

oh I thought that we have to select a single parent node in the whole component, whose index is minimum …

my mistake.

Directed Graph or Non Directed Graph?

Updated Code->https://ide.codingblocks.com/s/87544

Why wrong answer on Submission. Please check.
@phantom

@phantom

Please check.