結果
問題 |
No.513 宝探し2
|
ユーザー |
|
提出日時 | 2020-07-11 18:18:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 920 bytes |
コンパイル時間 | 1,950 ms |
コンパイル使用メモリ | 200,920 KB |
最終ジャッジ日時 | 2025-01-11 19:49:03 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) map<pair<int, int>, int> memo; int ask(int x, int y) { if (memo.count({x, y})) return memo[{x, y}]; cout << x << " " << y << endl; cout.flush(); int d; cin >> d; if (d == 0) exit(0); return memo[{x, y}] = d; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int lx = -1, ux = 100000; int ly = -1, uy = 100000; while (ux - lx > 1) { if (ask(lx, uy) == ask(ux, uy)) { ux = (lx + ux) / 2; break; } else if (ask(lx, uy) < ask(ux, uy)) { ux = (lx + ux) / 2; } else { lx = (lx + ux) / 2; } } while (uy - ly > 1) { if (ask(ux, ly) == ask(ux, uy)) { uy = (ly + uy) / 2; break; } else if (ask(ux, ly) < ask(ux, uy)) { uy = (ly + uy) / 2; } else { ly = (ly + uy) / 2; } } ask(ux, uy); return 0; }