結果
| 問題 | No.3018 目隠し宝探し | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-01-25 14:05:29 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,211 bytes | 
| コンパイル時間 | 2,125 ms | 
| コンパイル使用メモリ | 198,328 KB | 
| 実行使用メモリ | 25,972 KB | 
| 平均クエリ数 | 2.64 | 
| 最終ジャッジ日時 | 2025-01-25 23:06:57 | 
| 合計ジャッジ時間 | 5,866 ms | 
| ジャッジサーバーID (参考情報) | judge10 / judge8 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 16 RE * 5 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(a, b, c) for (int a = b; a < (int)c; ++a)
vector<int> xm = {-1, 1, 0, 0};
vector<int> ym = {0, 0, 1, -1};
const ll MOD = 998244353;
int power(int x, int y)
{
    return x * x + y * y;
}
int main()
{
    int h, w;
    cin >> h >> w;
    cout << "? 1 1" << endl;
    int dist;
    cin >> dist;
    assert(dist != -1);
    if (dist == 0)
    {
        cout << "! 1 1" << endl;
        return 0;
    }
    vector<int> x, y;
    rep(i, 1, h + 1)
    {
        rep(j, 1, w + 1)
        {
            if (power(i - 1, j - 1) == dist)
            {
                x.push_back(i);
                y.push_back(j);
            }
        }
    }
    cout << "? " << x[0] << " " << y[0] << endl;
    int dist2;
    cin >> dist2;
    assert(dist2 != -1);
    if (dist2 == 0)
    {
        cout << "! " << x[0] << " " << y[0] << endl;
        return 0;
    }
    for (int i = x.size() - 1; i >= 1; i--)
    {
        if (power(x[0] - x[i], y[0] - y[i]) != dist2)
        {
            x.erase(begin(x) + i);
            y.erase(begin(y) + i);
        }
    }
    cout << "! " << x[1] << " " << y[1] << endl;
}
            
            
            
        