結果
問題 |
No.3018 目隠し宝探し
|
ユーザー |
![]() |
提出日時 | 2025-02-22 03:27:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,789 bytes |
コンパイル時間 | 1,983 ms |
コンパイル使用メモリ | 197,644 KB |
実行使用メモリ | 26,216 KB |
平均クエリ数 | 2.68 |
最終ジャッジ日時 | 2025-02-22 03:27:48 |
合計ジャッジ時間 | 5,209 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> PP; // #define MOD 1000000007 #define MOD 998244353 #define INF 2305843009213693951 #define PI 3.141592653589 #define setdouble setprecision #define REP(i,n) for(ll i=0;i<(n);++i) #define OREP(i,n) for(ll i=1;i<=(n);++i) #define RREP(i,n) for(ll i=(n)-1;i>=0;--i) #define ORREP(i,n) for(ll i=(n);i>=1;--i) #define rep(i,a,b) for(ll i=(a);i<=(b);++i) #define ALL(v) (v).begin(), (v).end() #define chmin(k,m) k = min(k,m) #define chmax(k,m) k = max(k,m) #define GOODBYE do { cout << "-1" << endl; return 0; } while (false) #define MM <<" "<< #define Endl endl ll H,W; ll output(ll i, ll j){ cout << "?" MM i+1 MM j+1 << endl; ll d; cin >> d; if(d==-1){ exit(1); } return d; } void answer(ll i, ll j){ cout << "!" MM i+1 MM j+1 << endl; exit(0); } int main(void){ //cin.tie(nullptr); //ios::sync_with_stdio(false); cin >> H >> W; if(H==1 && W==1){ answer(0,0); } if(H==1){ ll d = output(0,0); answer(0,sqrt(d)); } if(W==1){ ll d = output(0,0); answer(sqrt(d),0); } ll d1 = output(0,0); ll d2 = output(H-1,0); vector<pair<ll,ll>> Ans; REP(i,H){ REP(j,W){ if(i*i+j*j==d1 && (H-1-i)*(H-1-i)+j*j==d2){ Ans.push_back({i,j}); } } } assert(Ans.size() <= 2); if(Ans.size()==1){ answer(Ans[0].first,Ans[0].second); }else{ ll d3 = output(Ans[0].first,Ans[0].second); if(d3==0){ answer(Ans[0].first,Ans[0].second); }else{ answer(Ans[1].first,Ans[1].second); } } return 0; }