結果
問題 |
No.513 宝探し2
|
ユーザー |
![]() |
提出日時 | 2018-03-08 19:55:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,188 bytes |
コンパイル時間 | 449 ms |
コンパイル使用メモリ | 64,636 KB |
実行使用メモリ | 25,604 KB |
平均クエリ数 | 9.33 |
最終ジャッジ日時 | 2024-07-16 15:39:28 |
合計ジャッジ時間 | 1,603 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
// No.513 宝探し2 // https://yukicoder.me/problems/no/513 // #include <iostream> using namespace std; int check_distance(int x, int y); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int dist; dist = check_distance(0, 0); int lx = 0; int rx = dist; bool lx_update = true; bool rx_update = true; int ldist = 0; int rdist = 0; while (dist != 0) { if (lx_update) { ldist = check_distance(lx, dist - lx); lx_update = false; if (ldist == 0) break; } if (rx_update) { rdist = check_distance(rx, dist - rx); rx_update = false; if (rdist == 0) break; } if (ldist == rdist) { lx = (lx + rx) / 2; lx_update = true; } else if (ldist < rdist) { rx = (lx + rx) / 2; rx_update = true; } else { lx = (lx + rx) / 2; lx_update = true; } } } int check_distance(int x, int y) { cout << x << " " << y << endl << flush; int res; cin >> res; return res; }