結果
問題 | No.513 宝探し2 |
ユーザー |
|
提出日時 | 2017-05-05 23:53:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 891 bytes |
コンパイル時間 | 1,038 ms |
コンパイル使用メモリ | 68,908 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 64.50 |
最終ジャッジ日時 | 2024-07-16 13:29:45 |
合計ジャッジ時間 | 2,679 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 23 ms
25,348 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 22 ms
25,220 KB |
testcase_06 | WA | - |
testcase_07 | AC | 23 ms
24,580 KB |
testcase_08 | AC | 20 ms
25,220 KB |
testcase_09 | AC | 21 ms
24,580 KB |
testcase_10 | WA | - |
testcase_11 | AC | 22 ms
24,964 KB |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <string> using namespace std; const int n_bit = 20; int query(bool isX, int val) { if (isX) { cout << val << " 0"<< endl; } else { cout << "0 " << val << endl; } int ret; cin >> ret; // printf("query val %3d, ret %3d\n", val, ret); return ret; } int calc(bool isX) { int width = (1 << n_bit) - 1; int point = 0; while (width > 0) { // printf("-- point %3d width %3d\n", point, width); int r = point + width; int l = point - width; int r_val = query(isX, r); int l_val = query(isX, l); if (r_val == l_val) { return point; } else if (r_val < l_val) { point += width / 2; } else { point -= width / 2; } width /= 2; } return point; } int main() { int x = calc(true); int y = calc(false); cout << x << " " << y << endl; return 0; }