結果
問題 | No.513 宝探し2 |
ユーザー | k |
提出日時 | 2020-07-11 18:18:14 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 920 bytes |
コンパイル時間 | 4,467 ms |
コンパイル使用メモリ | 206,360 KB |
実行使用メモリ | 24,372 KB |
平均クエリ数 | 30.58 |
最終ジャッジ日時 | 2023-09-24 02:41:52 |
合計ジャッジ時間 | 3,552 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
24,372 KB |
testcase_01 | AC | 26 ms
24,360 KB |
testcase_02 | AC | 27 ms
24,336 KB |
testcase_03 | AC | 26 ms
23,712 KB |
testcase_04 | AC | 27 ms
24,048 KB |
testcase_05 | AC | 26 ms
23,448 KB |
testcase_06 | AC | 26 ms
23,856 KB |
testcase_07 | AC | 27 ms
23,460 KB |
testcase_08 | AC | 27 ms
23,688 KB |
testcase_09 | AC | 26 ms
24,324 KB |
testcase_10 | AC | 25 ms
23,604 KB |
testcase_11 | AC | 26 ms
23,712 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) / 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; }