unexpected runtime error

can someone please tell me why this code is giving runtime error sigsegv http://www.codechef.com/viewsolution/3801341 it’s an atempt to solve the problem knight fork in lunchtime april 14

//