結果
| 問題 | No.253 ロウソクの長さ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-29 15:44:40 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 986 bytes |
| 記録 | |
| コンパイル時間 | 948 ms |
| コンパイル使用メモリ | 109,596 KB |
| 実行使用メモリ | 28,976 KB |
| 平均クエリ数 | 34.64 |
| 最終ジャッジ日時 | 2026-03-08 21:16:52 |
| 合計ジャッジ時間 | 4,078 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;
int main() {
int t = 8;
int a = 0;
while(true){
cout << "? " << max(t-a, 0) << endl;
a++;
int x; cin >> x;
if(!x) {
cout << "! " << t << "\n";
return 0;
}
if(x < 0) break;
t *= 2;
}
int ok = t/2, ng = t;
while(ng-ok > 1){
int mid = (ok+ng)/2;
cout << "? " << max(mid-a, 0) << endl;
int x; cin >> x;
if(!x) {
cout << "! " << mid << endl;
return 0;
}
(x == 1 ? ok : ng) = mid;
a++;
}
cout << "! " << ok << endl;
return 0;
}