Wa spoj 206. Bitmap again and again

Question link:: http://www.spoj.com/problems/BITMAP/

I have been trying again and again but still it is resulting wa
I know how to solve this question using bfs by passing all the ones in a queue…
but i want to know what is wrong in the above stated code using dfs and dp

see this…http://ideone.com/mePHWP i changed ur dx and dy array…u cnnot traverse diagonally…hope this helps…:slight_smile: