結果
問題 | No.594 壊れた宝物発見機 |
ユーザー | masa |
提出日時 | 2017-11-10 23:32:34 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 1,285 bytes |
コンパイル時間 | 594 ms |
コンパイル使用メモリ | 70,676 KB |
実行使用メモリ | 24,312 KB |
平均クエリ数 | 54.90 |
最終ジャッジ日時 | 2023-09-23 14:55:22 |
合計ジャッジ時間 | 4,007 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 105 ms
23,316 KB |
testcase_01 | AC | 100 ms
23,316 KB |
testcase_02 | AC | 100 ms
24,024 KB |
testcase_03 | AC | 99 ms
23,472 KB |
testcase_04 | AC | 103 ms
23,340 KB |
testcase_05 | AC | 100 ms
23,616 KB |
testcase_06 | AC | 101 ms
24,048 KB |
testcase_07 | AC | 100 ms
24,300 KB |
testcase_08 | AC | 103 ms
23,772 KB |
testcase_09 | AC | 101 ms
23,556 KB |
testcase_10 | AC | 100 ms
23,304 KB |
testcase_11 | AC | 103 ms
23,244 KB |
testcase_12 | AC | 101 ms
23,652 KB |
testcase_13 | AC | 100 ms
24,312 KB |
testcase_14 | AC | 100 ms
23,628 KB |
testcase_15 | AC | 99 ms
23,412 KB |
testcase_16 | AC | 100 ms
23,544 KB |
testcase_17 | AC | 100 ms
23,784 KB |
testcase_18 | AC | 100 ms
23,604 KB |
testcase_19 | AC | 103 ms
24,012 KB |
ソースコード
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <string> using namespace std; int ask(int x, int y, int z) { int d; cout << "?" << " " << x << " " << y << " " << z << endl; cin >> d; return d; } int ask(int val, char which) { int d = -99; switch (which) { case 'x': d = ask(val, 0, 0); break; case 'y': d = ask( 0, val, 0); break; case 'z': d = ask( 0, 0, val); break; default: break; } return d; } // 回答クエリ void answer(int x, int y, int z) { cout << "!" << " " << x << " " << y << " " << z << endl; } int calc(char which) { int upper = 150; int mid = 0; int lower = -150; while (upper - lower > 2) { int d_upper = ask(upper, which); int d_lower = ask(lower, which); if (d_upper > d_lower) { upper = mid; mid = (lower + mid) / 2; } else { lower = mid; mid = (mid + upper) / 2; } } int d_upper = ask(upper, which); int d_mid = ask(mid, which); int d_lower = ask(lower, which); int d_min = min({d_lower, d_mid, d_upper}); if (d_min == d_upper) { return upper; } else if (d_min == d_mid) { return mid; } else { return lower; } } int main() { int x = calc('x'); int y = calc('y'); int z = calc('z'); answer(x, y, z); return 0; }