This is the link to my code ==>> https://www.codechef.com/viewsolution/8869656
I have used vector array to make adjacency list and run DFS on it without Stack implementation, with the help of a parent array. Still I cant why is it throwing NZEC error. Out of Memory flow is not there because I have tested it on the boundary condition.