結果

問題 No.253 ロウソクの長さ
ユーザー xuzijian629xuzijian629
提出日時 2018-10-27 01:47:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,053 bytes
コンパイル時間 1,866 ms
コンパイル使用メモリ 198,304 KB
実行使用メモリ 24,312 KB
平均クエリ数 37.97
最終ジャッジ日時 2023-09-24 02:00:00
合計ジャッジ時間 4,642 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,748 KB
testcase_01 AC 22 ms
24,024 KB
testcase_02 AC 22 ms
23,988 KB
testcase_03 AC 22 ms
23,904 KB
testcase_04 AC 22 ms
23,652 KB
testcase_05 AC 21 ms
23,328 KB
testcase_06 AC 23 ms
24,312 KB
testcase_07 AC 23 ms
23,652 KB
testcase_08 AC 23 ms
24,312 KB
testcase_09 AC 21 ms
23,592 KB
testcase_10 AC 22 ms
24,300 KB
testcase_11 AC 23 ms
23,532 KB
testcase_12 AC 23 ms
23,616 KB
testcase_13 AC 22 ms
23,616 KB
testcase_14 AC 22 ms
23,304 KB
testcase_15 AC 24 ms
23,544 KB
testcase_16 AC 22 ms
23,652 KB
testcase_17 AC 22 ms
23,544 KB
testcase_18 AC 24 ms
23,676 KB
testcase_19 AC 21 ms
24,252 KB
testcase_20 AC 22 ms
24,312 KB
testcase_21 AC 23 ms
23,484 KB
testcase_22 AC 22 ms
23,856 KB
testcase_23 AC 22 ms
23,544 KB
testcase_24 AC 24 ms
23,460 KB
testcase_25 AC 23 ms
23,472 KB
testcase_26 AC 22 ms
23,988 KB
testcase_27 AC 24 ms
23,640 KB
testcase_28 AC 23 ms
24,312 KB
testcase_29 AC 25 ms
23,316 KB
testcase_30 AC 25 ms
24,228 KB
testcase_31 AC 25 ms
23,928 KB
testcase_32 AC 25 ms
23,904 KB
testcase_33 AC 25 ms
23,472 KB
testcase_34 AC 23 ms
24,000 KB
testcase_35 AC 25 ms
23,424 KB
権限があれば一括ダウンロードができます

ソースコード

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 - 10) {
        int m = (l + r) / 2;
        ask(m);
        cin >> res;
        if (res == 1) {
            l = m;
        } else if (res == 0) {
            ans(m + cnt - 1);
        } else {
            r = m;
        }
        l--;
    }

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