Code is running but output is not comming

i am not able to find what am i doing wrong in this code

Its working on the input given on SPOJ https://ide.codingblocks.com/s/573358 I modified the addEdge function of your code to make the id of nodes 0 indexed

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.