Run Time Error?

While solving this problem, I’m getting a runtime error, I tried to manually detect the error but i could not find it.

Here’s the question : KNIGHTATTACK Problem | CodeChef

And here’s my submissions
C++ : CodeChef | Competitive Programming | Participate & Learn
Java : CodeChef | Competitive Programming | Participate & Learn

Runtime error generally occurs when you are trying to access an invalid memory location. Generally in C++, you should always take some extra size of arrays so that such issues don’t arise.

If we change line 9 of your code from int chess[8][8]; to int chess[10][10];, your code starts giving Wrong Answer. Thus the runtime error is resolved, but there is still an error in your logic somewhere.

To debug that, here is the test case on which your code is failing after the above change.

Thanks for the help. I managed to fix the error with your help.