結果

問題 No.253 ロウソクの長さ
ユーザー xuzijian629xuzijian629
提出日時 2018-10-27 01:36:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,041 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 197,780 KB
実行使用メモリ 24,384 KB
平均クエリ数 31.89
最終ジャッジ日時 2023-09-23 16:28:52
合計ジャッジ時間 6,332 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,336 KB
testcase_01 AC 25 ms
24,288 KB
testcase_02 AC 28 ms
23,592 KB
testcase_03 AC 24 ms
23,940 KB
testcase_04 AC 26 ms
23,556 KB
testcase_05 AC 25 ms
23,832 KB
testcase_06 AC 24 ms
23,496 KB
testcase_07 AC 23 ms
23,652 KB
testcase_08 AC 23 ms
23,796 KB
testcase_09 AC 24 ms
23,940 KB
testcase_10 AC 25 ms
23,976 KB
testcase_11 WA -
testcase_12 AC 25 ms
23,616 KB
testcase_13 AC 25 ms
23,544 KB
testcase_14 AC 24 ms
23,988 KB
testcase_15 AC 29 ms
24,240 KB
testcase_16 AC 24 ms
23,628 KB
testcase_17 AC 23 ms
23,340 KB
testcase_18 AC 25 ms
23,352 KB
testcase_19 AC 24 ms
23,580 KB
testcase_20 AC 25 ms
23,928 KB
testcase_21 AC 26 ms
23,616 KB
testcase_22 AC 25 ms
24,276 KB
testcase_23 WA -
testcase_24 AC 26 ms
23,604 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 25 ms
23,796 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 28 ms
23,340 KB
testcase_31 AC 24 ms
24,012 KB
testcase_32 AC 23 ms
23,508 KB
testcase_33 AC 25 ms
24,252 KB
testcase_34 AC 22 ms
23,976 KB
testcase_35 AC 23 ms
24,348 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 - 5) {
        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--;
    }

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