What's Wrong With this Solution?

Revision en1, by naivedyam, 2024-08-25 08:56:27

I am stuck on my solution to 277938667. It gets stuck on testcase 2 subcase 21 and since it is interactive I can neither debug it nor see the specific test case where it fails.

Here is my approach — I will first query the point (1,1) and find the distance of the closest mine to it. If the distance is 0 that's the location of the mine so I return. Else, all the possible cells where the mine can lie are along a diagonal of the rectangle. Now, I query the starting and ending points of the diagonals. Again if the distance is 0 I report them. Else, there are two possible cases — either both return the distance to the mine on the diagonal or one returns that mine and the other returns distance to a cell to the other mine. Now Here, I know the cells lying on the diagonal follow a certain pattern. I assume both of the distances I got while querying those points to be distances to a mine on the diagonal and calculate the coordinates of those cells accordingly. Now for the last query, I query about one of the cells I calculated. If the distance is 0 that is my answer. Else, the other one has to be my answer. I don't see anything wrong with the approach. Can someone help?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English naivedyam 2024-08-25 08:56:27 1228 Initial revision (published)