結果

問題 No.3018 目隠し宝探し
ユーザー neet
提出日時 2025-01-25 19:53:09
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 540 ms
コンパイル使用メモリ 64,896 KB
実行使用メモリ 26,084 KB
平均クエリ数 2.59
最終ジャッジ日時 2025-01-26 00:04:01
合計ジャッジ時間 3,845 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int in;
int Q(int y, int x){
    cout<<"? "<<y<<" "<<x<<endl;
    cin>>in;
    return in;
}
void A(int y, int x){
    cout<<"! "<<y<<" "<<x<<endl;
    exit(0);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int H,W;
    cin>>H>>W;
    
    if(H==1&&W==1){
        A(1,1);
    }

    int a=Q(1,1);
    int c=0,y,x;
    for(int i=H+1;--i;)for(int j=W+1;--j;){
        if((i-1)*(i-1)+(j-1)*(j-1)==a){
            y=i;
            x=j;
            c++;
        }
    }
    if(c==1){
        A(y,x);
    }
    int b=Q(1,W);
    for(int i=H+1;--i;)for(int j=W+1;--j;){
        if((i-1)*(i-1)+(j-1)*(j-1)==a && (i-1)*(i-1)+(j-W)*(j-W)==b){
            A(i,j);
        }
    }
    
}
0