naivedyam's blog

By naivedyam, history, 3 hours ago, In English

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?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
2 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

you are finding the corners wrong, the correct way is:


if(distance<n) corner1 = {distance+1,1}; else corner1 = {n, distance-n+2}; if(distance<k) corner2 = {1, distance+1}; else corner2 = {distance-k+2, k};