結果
問題 | No.3018 目隠し宝探し |
ユーザー |
👑 ![]() |
提出日時 | 2025-01-25 13:35:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 1,295 bytes |
コンパイル時間 | 666 ms |
コンパイル使用メモリ | 73,156 KB |
実行使用メモリ | 25,972 KB |
平均クエリ数 | 2.68 |
最終ジャッジ日時 | 2025-01-25 22:51:17 |
合計ジャッジ時間 | 3,551 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge10 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
ソースコード
#ifdef NACHIA #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #include <iostream> #include <string> #include <vector> #include <algorithm> using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<int(n); i++) const i64 INF = 1001001001001001001; template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; } template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; } using namespace std; int ask(int u, int v){ cout << "? " << u << " " << v << "\n"; cout.flush(); int x; cin >> x; if(x < 0) exit(0); return x; } int isqrt(int x){ int y = 0; while((y+1)*(y+1) <= x) y++; return y; } void ans(int u, int v){ cout << "! " << u << " " << v << "\n"; cout.flush(); exit(0); } void testcase(){ int H, W; cin >> H >> W; if(H == 1 && W == 1) ans(1, 1); if(H == 1) ans(1, isqrt(ask(1,1))+1); if(W == 1) ans(isqrt(ask(1,1))+1, 1); int a = ask(1,1); int b = ask(H,1); for(int y=1; y<=H; y++) for(int x=1; x<=W; x++){ int dx = x - 1, dy = y - 1; if(dx*dx + dy*dy != a) continue; dy = y - H; if(dx*dx + dy*dy != b) continue; ans(y,x); } } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); testcase(); return 0; }