結果

問題 No.3018 目隠し宝探し
ユーザー takoyaki782
提出日時 2025-07-14 17:01:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,875 bytes
コンパイル時間 4,234 ms
コンパイル使用メモリ 253,576 KB
実行使用メモリ 25,984 KB
平均クエリ数 2.68
最終ジャッジ日時 2025-07-14 17:01:16
合計ジャッジ時間 7,611 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll inf_ll = 9223372036854775807;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using mint = atcoder::modint998244353;
using mint1 = atcoder::modint1000000007;
using Pa = std::pair<ll, ll>;

int Yes(bool x){
    if(x) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}

int main(){
    ll H, W;
    cin >> H >> W;
    if(H == 1 && W == 1){
        cout << "! 1 1" << endl;
        cout << flush;
        return 0;
    }
    if(H == 1){
        cout << "? 1 1" << endl;
        cout << flush;
        ll d;
        cin >> d;
        rep(j, W){
            if(j*j == d){
                cout << "! 1 ";
                cout << j+1 << endl;
                cout << flush;
                break;
            }
        }
        return 0;
    }
    if(W == 1){
        cout << "? 1 1" << endl;
        cout << flush;
        ll d;
        cin >> d;
        rep(i, H){
            if(i*i == d){
                cout << "! 1 ";
                cout << i+1 << endl;
                cout << flush;
                break;
            }
        }
        return 0;
    }
    ll a, b;
    cout << "? 1 1" << endl;
    cout << flush;
    cin >> a;
    cout << "? 2 1" << endl;
    cout << flush;
    cin >> b;
    for(ll i = 1; i <= H; i++){
        for(ll j = 1; j <= W; j++){
            if((i-1)*(i-1)+(j-1)*(j-1) == a){
                if((i-2)*(i-2)+(j-1)*(j-1) == b){
                    cout << "! " << i << " " << j << endl;
                    cout << flush;
                    return 0;
                }
            }
        }
    }
}
0