結果

問題 No.3018 目隠し宝探し
ユーザー ponjuice
提出日時 2025-02-22 02:47:54
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,382 bytes
コンパイル時間 4,156 ms
コンパイル使用メモリ 278,068 KB
実行使用メモリ 26,224 KB
平均クエリ数 2.64
最終ジャッジ日時 2025-02-22 02:48:02
合計ジャッジ時間 6,762 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) begin(a), end(a)
#define rep(i,a,b) for(ll i = a; i < (b); i++)

int main(){
    int h,w;
    cin >> h >> w;
    if(h == 1 && w == 1){
        cout << "! " << 1 << " " << 1 << endl;
        return 0;
    }
    if(h == 1){
        cout << "? 1 1" << endl;
        int a;
        cin >> a;
        rep(i,1,w+1){
            if(i * i == a){
                cout << "! " << 1 << " " << a << endl;
            }
        } 
        return 0;
    }
    if(w == 1){
        cout << "? 1 1" << endl;
        int a;
        cin >> a;
        rep(i,1,h+1){
            if(i * i == a){
                cout << "! " << a << " " << 1 << endl;
            }
        } 
        return 0;
    }

    ll a,b;
    cout << "? 1 1" << endl;
    cin>> a;
    vector<pair<ll,ll>> res;
    rep(i,1,h+1){
        rep(j,1,w+1){
            if((i-1)*(i-1) + (j-1)*(j-1) == a){
                res.push_back({i,j});
            }
        }
    }
    if(res.size() == 1){
        cout << "! " << res[0].first << " " << res[0].second << endl;
    }
    cout << "? 1 2" << endl;
    cin>> b;
    rep(i,1,h+1){
        rep(j,1,w+1){
            if((i-1)*(i-1) + (j-1)*(j-1) == a && (i-1)*(i-1) + (j-2)*(j-2) == b){
                cout << "! " << i << " " << j << endl;
            }
        }
    }

    return 0;
}

// 1 3
// 4 + 
0