結果

問題 No.253 ロウソクの長さ
ユーザー xuzijian629xuzijian629
提出日時 2018-10-27 01:43:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 191,604 KB
最終ジャッジ日時 2025-01-06 14:51:04
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int cnt;

void ask(int x) {
    cout << "? " << x << endl;
    cnt++;
}

void ans(int x) {
    cout << "! " << x << endl;
    exit(0);
}

int res;

int main() {
    bool ge100;
    ask(100);
    cin >> res;
    if (res == 0) {
        ans(100);
    } else if (res == 1) {
        ge100 = true;
    } else {
        ge100 = false;
    }

    if (!ge100) {
        while (1) {
            ask(8);
            cin >> res;
            if (res == 0) {
                ans(8 + cnt - 1);
            }
        }
    }

    int l = 99, r = 1e9 + 1;
    while (l < r - 15) {
        int m = (l + r) / 2;
        ask(m);
        cin >> res;
        if (res == 1) {
            l = m;
        } else if (res == 0) {
            ans(res + cnt - 1);
        } else {
            r = m;
        }
        l--;
    }

    l -= 2;
    while (1) {
        ask(l);
        cin >> res;
        if (res == 0) {
            ans(l + cnt - 1);
        }
    }
}
0