結果

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

ソースコード

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