結果
| 問題 | No.3018 目隠し宝探し | 
| コンテスト | |
| ユーザー |  Tatsu_mr | 
| 提出日時 | 2025-01-25 14:28:41 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,494 bytes | 
| コンパイル時間 | 4,220 ms | 
| コンパイル使用メモリ | 278,540 KB | 
| 実行使用メモリ | 86,828 KB | 
| 平均クエリ数 | 1.68 | 
| 最終ジャッジ日時 | 2025-01-25 23:21:52 | 
| 合計ジャッジ時間 | 26,899 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge7 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 13 WA * 1 TLE * 7 | 
ソースコード
#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 dist(int i, int j, int ii, int jj) {
    int dii = abs(i - ii);
    int djj = abs(j - jj);
    return dii * dii + djj * djj;
}
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;
    };
    int d = ask(1, 1);
    set<pair<int, int>> s;
    For(i, 1, h + 1) {
        For(j, 1, w + 1) {
            if (dist(i, j, 1, 1) == d) {
                s.insert({i, j});
            }
        }
    }
    while (s.size() > 1) {
        auto it = s.begin();
        auto [i, j] = *it;
        int d = ask(i, j);
        if (d == 0) {
            cout << "! " << i << " " << j << "\n";
            cout.flush();
            return 0;
        }
        while (it != s.end()) {
            auto [ii, jj] = *it;
            if (dist(i, j, ii, jj) != d) {
                it = s.erase(it);
            }
        }
    }
    auto [i, j] = *s.begin();
    cout << "! " << i << " " << j << "\n";
    cout.flush();
    return 0;
}
            
            
            
        