BEAUTIFUL VERTICES graphs

code: https://ide.codingblocks.com/s/41729
ques: https://hack.codingblocks.com/contests/c/511/782

here’s my code i am getting wrong ans for both the test cases and unable to figure out.

You are getting wrong answer because you are creating unidirectional edges. if input is u v then u is parent and v is child , this is not the case parent child relation ship depends on master parent, so add the edges in both the vertex, then deal with this case ahead ( code need to be complete to handle it , try to think after this point)

Hit like if you get it! :stuck_out_tongue:

1 Like