WA on firesc

I’m trying to solve http://www.codechef.com/problems/FIRESC/ problem.
Im using bfs instead of dfs unlike the editorial.

This is my solution http://www.codechef.com/viewsolution/3235157.

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

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


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: