結果
問題 |
No.3018 目隠し宝探し
|
ユーザー |
|
提出日時 | 2025-02-22 02:51:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 1,182 bytes |
コンパイル時間 | 4,333 ms |
コンパイル使用メモリ | 253,088 KB |
実行使用メモリ | 25,972 KB |
平均クエリ数 | 2.68 |
最終ジャッジ日時 | 2025-02-22 02:51:41 |
合計ジャッジ時間 | 7,495 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
ソースコード
#include <atcoder/all> #include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) template<typename T> bool chmin(T &x, T y) { return x > y ? (x = y, true) : false; } template<typename T> bool chmax(T &x, T y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; int main(){ int h,w; cin>>h>>w; if(h==1&&w==1){ cout<<"! 1 1\n"; return 0; } if(h==1||w==1){ cout<<"? 1 1"<<endl; int dd; cin>>dd; rep(lp,0,max(h,w)+1){ if(lp*lp==dd){ if(h==1){ cout<<"! 1 "<<lp+1<<"\n"; }else{ cout<<"! "<<lp+1<<" 1\n"; } return 0; } assert(lp*lp<dd); } return 0; } int a,b; cout<<"? 1 1"<<endl; cin>>a; if(a==-1) return 0; cout<<"? 1 "<<w<<endl; cin>>b; if(b==-1) return 0; tuple<int,int> tt={a,b}; rep(lh,1,h+1) rep(lw,1,w+1){ int sa=abs(1-lh)*abs(1-lh)+abs(1-lw)*abs(1-lw); int sb=abs(1-lh)*abs(1-lh)+abs(w-lw)*abs(w-lw); tuple<int,int> st={sa,sb}; if(st==tt){ cout<<"! "<<lh<<" "<<lw<<"\n"; return 0; } } assert(-1); }