結果
| 問題 | No.253 ロウソクの長さ |
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-09-27 21:36:42 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 85 ms / 2,000 ms |
| + 1µs | |
| コード長 | 1,653 bytes |
| 記録 | |
| コンパイル時間 | 861 ms |
| コンパイル使用メモリ | 181,088 KB |
| 実行使用メモリ | 9,476 KB |
| 平均クエリ数 | 34.28 |
| 最終ジャッジ日時 | 2026-08-14 20:25:12 |
| 合計ジャッジ時間 | 3,372 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
auto i = vs.begin();
os << "[" << *i;
for (++i; i != vs.end(); ++i) os << " " << *i;
return os << "]";
}
template<class T> istream& operator>>(istream& is, vector<T>& vs) {
for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
return is;
}
void input() {
}
void solve() {
cout << "? 100" << endl;
int y; cin >> y;
if (y == 0) {
cout << "! 100" << endl;
return;
} else if (y > 0) {
// do nothing
} else {
assert(y < 0);
for (int t = 1; ; t++) {
cout << "? 0" << endl;
int y; cin >> y;
if (y == 0) {
cout << "! " << t << endl;
return;
}
}
}
int lb = 10, ub = int(1e9) + 1;
for (int t = 1; ; t++) {
int mid = lb + (ub - lb) / 2;
cout << "? " << mid << endl;
int y; cin >> y;
if (y < 0) {
lb = max(0, lb - 1);
ub = mid;
} else if (y == 0) {
cout << "! " << mid + t << endl;
return;
} else {
assert(y > 0);
lb = max(0, mid - 1);
ub--;
}
}
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura