UVA online judge problem

Can someone help me understand this problem on UVA? Don’t know why I am getting a Wrong Answer.

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=497

Thanks.

output like this,it’s mentioned to output in field of width 3.
use printf("%3d", output_array[i]);

1 Like

I need the algorithm to be followed.

ok,let me see then.

@shraeyas you can just simulate the robot. No cell can be visited more than 4 times, so the complexity is linear with respect to the size of the grid.