結果

問題 No.3018 目隠し宝探し
ユーザー nouka28
提出日時 2025-01-25 13:41:59
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 956 bytes
コンパイル時間 6,648 ms
コンパイル使用メモリ 333,228 KB
実行使用メモリ 26,228 KB
平均クエリ数 2.64
最終ジャッジ日時 2025-01-25 22:56:38
合計ジャッジ時間 9,412 ms
ジャッジサーバーID
(参考情報)
judge5 / judge11
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#include<atcoder/all>
using namespace atcoder;
using mint=atcoder::modint998244353;

#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define int long long

signed 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 d;cin>>d;
		for(int i=0;i<W;i++){
			if(i*i==d){
				cout<<"!"<<" "<<1<<" "<<i+1<<endl;
				return 0;
			}
		}
	}

	if(W==1){
		cout<<"?"<<" "<<1<<" "<<1<<endl;
		int d;cin>>d;
		for(int i=0;i<H;i++){
			if(i*i==d){
				cout<<"!"<<" "<<i+1<<" "<<1<<endl;
				return 0;
			}
		}
	}

	cout<<"?"<<" "<<1<<" "<<1<<endl;
	int d;cin>>d;
	if(d==0){
		cout<<"!"<<" "<<1<<" "<<1<<endl;
		return 0;
	}
	cout<<"?"<<" "<<1<<" "<<2<<endl;
	int d2;cin>>d2;
	int y=1+(d2-d-1)/-2;

	for(int i=1;i<=H;i++){
		if((i-1)*(i-1)+(y-1)*(y-1)==d){
			cout<<"!"<<" "<<i<<" "<<y<<endl;
			return 0;
		}
	}
}
0