結果
| 問題 | No.3018 目隠し宝探し | 
| コンテスト | |
| ユーザー |  Tatsu_mr | 
| 提出日時 | 2025-01-25 18:14:10 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 84 ms / 2,000 ms | 
| コード長 | 1,352 bytes | 
| コンパイル時間 | 3,100 ms | 
| コンパイル使用メモリ | 274,892 KB | 
| 実行使用メモリ | 25,960 KB | 
| 平均クエリ数 | 2.68 | 
| 最終ジャッジ日時 | 2025-01-26 00:00:35 | 
| 合計ジャッジ時間 | 6,189 ms | 
| ジャッジサーバーID (参考情報) | judge12 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 21 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define For(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) For(i, 0, n)
#define rFor(i, a, b) for(int i = (a); i >= (b); i--)
#define ALL(v) (v).begin(), (v).end()
#define rALL(v) (v).rbegin(), (v).rend()
using lint = long long;
using ld = long double;
int INF = 2000000000;
lint LINF = 1000000000000000000;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w;
    cin >> h >> w;
    auto ask = [](int i, int j) -> int {
        cout << "? " << i << " " << j << "\n";
        cout.flush();
        int d;
        cin >> d;
        return d;
    };
    auto ans = [](int i, int j) -> void {
        cout << "! " << i << " " << j << "\n";
        cout.flush();
        exit(0);
    };
    if (h == 1 && w == 1) {
        ans(1, 1);
    } else if (h == 1 || w == 1) {
        int d = ask(1, 1);
        (h == 1 ? ans(1, 1 + sqrt(d)) : ans(1 + sqrt(d), 1));
    } else {
        int d1 = ask(1, 1), d2 = ask(1, 2);
        auto dist = [](int i1, int j1, int i2, int j2) -> int {
            return (i1 - i2) * (i1 - i2) + (j1 - j2) * (j1 - j2);
        };
        For(i, 1, h + 1) {
            For(j, 1, w + 1) {
                if (dist(1, 1, i, j) == d1 && dist(1, 2, i, j) == d2) {
                    ans(i, j);
                }
            }
        }
    }
}
            
            
            
        