結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2018-10-27 01:21:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,523 bytes |
コンパイル時間 | 2,169 ms |
コンパイル使用メモリ | 194,216 KB |
最終ジャッジ日時 | 2025-01-06 14:48:40 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 30 TLE * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; using i64 = int64_t; using vi = vector<i64>; using vvi = vector<vi>; int main() { int l = 0, r = 1e9, res; cout << "? " << r << endl; cin >> res; if (res == 0) { cout << "! " << r - 1 << endl; return 0; } int hoge = 0; while (l < r - 4) { if (hoge) { cout << "? " << l << endl; cin >> res; if (res == 0) { if (l == 0) { cout << "! 0" << endl; return 0; } else { cout << "! " << l - 1 << endl; return 0; } } } else { int m = (l + r) / 2; cout << "? " << m << endl; cin >> res; if (res == 1) { l = m; } else if (res == -1) { r = m; } else { if (m == 0) { cout << "! 0" << endl; return 0; } else { cout << "! " << m - 1 << endl; return 0; } } } hoge = 1 - hoge; } while (1) { cout << "? " << l << endl; cin >> res; if (res == 0) { if (l == 0) { cout << "! 0" << endl; return 0; } else { cout << "! " << l - 1 << endl; return 0; } } } }