Under construction

Still being built. Things may change

An Interactive Problem

Time limit2sMemory limit1024 MB

Summary
Find the largest value in a hidden n by n grid of distinct numbers by querying cells by coordinate, within n^2 + 100 queries, with n unknown up to 100.
Level

Medium4 of 10

Topics
Matrix, Implementation
Solved
No attempts yet

문제

The jury is in trouble. NWERC is tomorrow, and the problem set still needs a good interactive problem. All n2n^2 jury members have an idea, and after hours of arguing they cannot decide which idea is the nicest. They decide to draw lots.

Each jury member draws a lot from a collection of unique numbers. The lots lie face-down on a table, arranged in the shape of a square. You are the independent lot-drawer. You cannot see the table, so you pick lots by shouting coordinates. The jury is in a hurry, so you must find the lot with the highest number in at most n2+100n^2 + 100 commands. You do not know the size of the square in advance, but you know 1≤n≤1001 \le n \le 100.

Examples1

  1. Example 1

    Input
    
    314
    
    ArrayIndexOutOfBoundsException
    
    123456
    
    26
    
    11
    
    2022
    
    1337
    
    ArrayIndexOutOfBoundsException
    
    1
    
    42
    
    999
    
    
    Expected output
    ? 1 1
    
    ? 4 5
    
    ? 2 2
    
    ? 1 3
    
    ? 2 3
    
    ? 3 3
    
    ? 1 2
    
    ? 1 4
    
    ? 3 2
    
    ? 3 1
    
    ? 2 1
    
    ! 123456