KCHESS - Getting correct output for Test case given in the Problem, but getting WA after submission. Where is my code failing?

This is my code for the KCHESS Problem. What can be the corner case for which my code is failing? Or is it that I am just printing wrong output to the console? I tried only with the test case given on the problem page and it’s giving the correct output. But after submission I am getting WA.

My Code: Solution: 21521221 | CodeChef

Thanks.

You’re storing the knight positions in a map and use the x-value of a knight’s position as the key and the y-value as the value in the map. When you have two knights in the same file(x-position) the second knight will overwrite the first one in the std::map and then won’t be there when you check for check-mate.

1 Like