KFORK - can't find problem in code

Hey guys,

I tried solving the KFORK problem in today’s lunchtime. My algorithm is almost equivalent to the one given on the editorial for the problem. For some reason, it’s not getting AC (passes only the first test case). I’m unable to find the problem and would really appreciate any help.

Code: http://www.codechef.com/viewsolution/3795576

@midhul you are not checking your diagonal cases completely.