This is my attempt at the question:
http://codeforces.me/contest/793/submission/27930364
As I couldn't see the test case for which it is failing I was scrolling through other solutions and found 1 that is very similar, but that has passed. Any help with telling me why mine fails?
Similar solution that passes: http://codeforces.me/contest/793/submission/27902199
Here is a test case your code fail:
basically, you are checking whether a grid is visited or not, but not the direction in which it is travelling. So you will need 1 more dimension for the direction. (something like v[i][j][dir] instead)