WA on BITMAP spoj question

Here’s my question SPOJ.com - Problem BITMAP
and heres my solution
DXgLHE - Online C++0x Compiler & Debugging Tool - Ideone.com
What I am doing here is BFS. First i am putting all white pixels in queue then the non white pixels just next to them and so on and to avoid repetition i am using a visited array.But still i am getting WA. Any hints on what is wrong with my solution?