WA on FIRESC

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

Can someone please help me find where im going wrong?
This is my solution http://www.codechef.com/viewsolution/3235207

Im losing my mind over here.(first graph problem)

@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:

1 Like

Thank you, i did initialise the array(fill function) but i did it only upto n, instead of n+1.

happy to help :slight_smile: