TLE in spiral maze

can someone plz tell me why this code gives TLE

for question(http://www.codechef.com/problems/TIC05): http://www.codechef.com/viewsolution/3874966

while it works fine on ideone and on my pc: http://ideone.com/E4hbTa

would be grateful… thnx

a little help would be nice… thnx