結果

問題 No.253 ロウソクの長さ
ユーザー xuzijian629xuzijian629
提出日時 2018-10-27 01:42:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,054 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 198,740 KB
実行使用メモリ 24,396 KB
平均クエリ数 35.19
最終ジャッジ日時 2023-09-23 16:28:40
合計ジャッジ時間 5,064 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,376 KB
testcase_01 AC 25 ms
24,336 KB
testcase_02 AC 26 ms
23,328 KB
testcase_03 AC 25 ms
24,336 KB
testcase_04 AC 24 ms
23,916 KB
testcase_05 AC 25 ms
23,748 KB
testcase_06 AC 26 ms
24,180 KB
testcase_07 AC 25 ms
24,312 KB
testcase_08 AC 24 ms
23,388 KB
testcase_09 AC 25 ms
23,628 KB
testcase_10 AC 24 ms
23,940 KB
testcase_11 WA -
testcase_12 AC 26 ms
23,604 KB
testcase_13 AC 26 ms
24,012 KB
testcase_14 AC 24 ms
23,988 KB
testcase_15 AC 26 ms
23,328 KB
testcase_16 AC 24 ms
24,264 KB
testcase_17 AC 23 ms
23,628 KB
testcase_18 AC 24 ms
24,336 KB
testcase_19 AC 24 ms
23,340 KB
testcase_20 AC 24 ms
23,484 KB
testcase_21 AC 25 ms
23,784 KB
testcase_22 AC 24 ms
23,184 KB
testcase_23 AC 24 ms
24,336 KB
testcase_24 AC 24 ms
23,496 KB
testcase_25 AC 23 ms
23,580 KB
testcase_26 AC 25 ms
23,976 KB
testcase_27 AC 23 ms
23,364 KB
testcase_28 AC 24 ms
23,736 KB
testcase_29 AC 24 ms
23,604 KB
testcase_30 AC 24 ms
23,928 KB
testcase_31 AC 24 ms
23,376 KB
testcase_32 AC 23 ms
23,340 KB
testcase_33 AC 24 ms
23,328 KB
testcase_34 AC 24 ms
24,252 KB
testcase_35 AC 24 ms
24,000 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(res + cnt - 1);
        } else {
            r = m;
        }
        l--;
    }

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