結果

問題 No.2753 鳩の巣原理
ユーザー 👑 hitonanodehitonanode
提出日時 2024-05-10 22:38:18
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 716 ms
コンパイル使用メモリ 78,692 KB
実行使用メモリ 25,220 KB
平均クエリ数 11.00
最終ジャッジ日時 2024-05-10 22:38:33
合計ジャッジ時間 3,522 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
25,220 KB
testcase_01 AC 25 ms
24,964 KB
testcase_02 AC 25 ms
24,580 KB
testcase_03 AC 24 ms
24,964 KB
testcase_04 AC 28 ms
24,952 KB
testcase_05 AC 27 ms
25,220 KB
testcase_06 AC 28 ms
24,964 KB
testcase_07 AC 27 ms
24,964 KB
testcase_08 AC 27 ms
24,964 KB
testcase_09 AC 28 ms
24,812 KB
testcase_10 AC 28 ms
24,784 KB
testcase_11 AC 27 ms
24,556 KB
testcase_12 AC 28 ms
24,812 KB
testcase_13 AC 28 ms
24,556 KB
testcase_14 AC 28 ms
24,940 KB
testcase_15 AC 28 ms
24,940 KB
testcase_16 AC 27 ms
24,940 KB
testcase_17 AC 28 ms
24,796 KB
testcase_18 AC 27 ms
24,556 KB
testcase_19 AC 27 ms
24,940 KB
testcase_20 AC 29 ms
24,812 KB
testcase_21 AC 28 ms
24,800 KB
testcase_22 AC 26 ms
24,556 KB
testcase_23 AC 27 ms
24,556 KB
testcase_24 AC 28 ms
24,556 KB
testcase_25 AC 27 ms
24,812 KB
testcase_26 AC 26 ms
24,940 KB
testcase_27 AC 28 ms
25,196 KB
testcase_28 AC 28 ms
24,812 KB
testcase_29 AC 27 ms
24,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int ask = 0;

    auto rec = [&](auto &&self, int il, int nl, int ir, int nr) -> void {

        if (il + 1 == ir) {
            while (ask < 10) {
                ++ask;
                cout << "? 1" << endl;
            }
            cout << "Yes " << il << ' ' << ir << endl;
            exit(0);
        }

        ++ask;

        const int ic = (il + ir) / 2;
        cout << "? " << ic << endl;

        int resp = 0;
        cin >> resp;

        if (resp - nl < ic - il) {
            self(self, il, nl, ic, resp);
        } else {
            self(self, ic, resp, ir, nr);
        }
    };

    int N;
    cin >> N;
    rec(rec, 1, 1, N, N - 1);
}
0