結果
問題 | No.513 宝探し2 |
ユーザー | k |
提出日時 | 2020-07-11 18:08:52 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 936 bytes |
コンパイル時間 | 2,561 ms |
コンパイル使用メモリ | 206,216 KB |
実行使用メモリ | 24,324 KB |
平均クエリ数 | 29.58 |
最終ジャッジ日時 | 2023-09-24 03:50:20 |
合計ジャッジ時間 | 4,622 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 27 ms
23,460 KB |
testcase_03 | AC | 27 ms
23,796 KB |
testcase_04 | AC | 26 ms
24,264 KB |
testcase_05 | WA | - |
testcase_06 | AC | 26 ms
23,904 KB |
testcase_07 | WA | - |
testcase_08 | AC | 26 ms
24,324 KB |
testcase_09 | AC | 26 ms
23,388 KB |
testcase_10 | AC | 25 ms
23,616 KB |
testcase_11 | AC | 25 ms
23,340 KB |
ソースコード
#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 + 1) / 2; } else { lx = (lx + ux + 1) / 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 + 1) / 2; } else { ly = (ly + uy + 1) / 2; } } ask(ux, uy); return 0; }