結果

問題 No.3018 目隠し宝探し
ユーザー t98slider
提出日時 2025-01-25 13:30:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 822 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 197,872 KB
実行使用メモリ 26,356 KB
平均クエリ数 2.64
最終ジャッジ日時 2025-01-25 22:49:14
合計ジャッジ時間 5,101 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, d;
    cin >> h >> w;
    cout << "? 1 1" << endl;
    cin >> d;
    vector<pair<int,int>> cand;
    for(int y = 1; y <= h; y++){
        for(int x = 1; x <= w; x++){
            if((y - 1) * (y - 1) + (x - 1) * (x - 1) == d){
                cand.emplace_back(y, x);
            }
        }
    }
    if(cand.size() == 1){
        auto [y, x] = cand[0];
        cout << "! " << y << ' ' << x << endl;
        return 0;
    }
    cout << "? " << h << ' ' << 1 << endl;
    cin >> d;
    for(auto [y, x] : cand){
        if((y - h) * (y - h) + (x - 1) * (x - 1) == d){
            cout << "! " << y << ' ' << x << endl;
            return 0;
        }
    }
    assert(false);
}
0