I need some help in this problem. I think that my approach is correct, but I am getting WA unfortunately. Please do help..

Here's the link to the question: http://www.spoj.com/problems/CATM/

My approach is as follows :

If the mouse is at the edge of the field,i.e., if its x-co-ordinate=1 or n and if its y-co-ordinate=1 or m, then it can escape.

If both the cats and the mouse lie in a diagonal(either left diagonal or right diagonal) with the mouse in the middle, then the mouse can't escape.

For any other condition, the mouse can escape.

Here's the link to my solution : http://ideone.com/exE3j3