Why is my solution 281599833 failing on case 5? What is the issue with my logic?

# | User | Rating |
---|---|---|

1 | tourist | 4009 |

2 | jiangly | 3839 |

3 | Radewoosh | 3646 |

4 | jqdai0815 | 3620 |

4 | Benq | 3620 |

6 | orzdevinwang | 3612 |

7 | Geothermal | 3569 |

8 | ecnerwala | 3494 |

9 | Um_nik | 3396 |

10 | gamegame | 3386 |

# | User | Contrib. |
---|---|---|

1 | Um_nik | 164 |

2 | -is-this-fft- | 162 |

2 | maomao90 | 162 |

4 | atcoder_official | 158 |

4 | cry | 158 |

4 | awoo | 158 |

7 | nor | 155 |

7 | adamant | 155 |

9 | TheScrasse | 153 |

10 | maroonrk | 152 |

Why is my solution 281599833 failing on case 5? What is the issue with my logic?

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?

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/06/2024 22:48:37 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|