WA on firesc

I’m trying to solve FIRESC Problem - CodeChef problem.
Im using bfs instead of dfs unlike the editorial.

This is my solution CodeChef: Practical coding for everyone.

Can somebody help me why am i getting WA on here?
This is my first graph problem. Im going insane. Please help.

@tacoder:

u did not initialize the boolean array visited to false(it actually had some random values).

just initializing the visited array as false, gets ur solution accepted :slight_smile:

working solution: http://www.codechef.com/viewsolution/3236064

Enjoy Coding :slight_smile:

Please combine this with your previous question and avoid making duplicate questions