結果

問題 No.2085 Directed Complete Graph
ユーザー 259_Momone259_Momone
提出日時 2022-09-27 02:00:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 2,711 ms
コンパイル使用メモリ 261,400 KB
実行使用メモリ 24,384 KB
平均クエリ数 2534.65
最終ジャッジ日時 2023-08-24 03:26:04
合計ジャッジ時間 5,754 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,424 KB
testcase_01 AC 23 ms
23,664 KB
testcase_02 AC 150 ms
24,060 KB
testcase_03 AC 142 ms
24,348 KB
testcase_04 AC 155 ms
23,844 KB
testcase_05 AC 84 ms
24,384 KB
testcase_06 AC 90 ms
23,652 KB
testcase_07 AC 153 ms
24,036 KB
testcase_08 AC 118 ms
23,532 KB
testcase_09 AC 150 ms
23,856 KB
testcase_10 AC 155 ms
23,652 KB
testcase_11 AC 159 ms
24,336 KB
testcase_12 AC 156 ms
23,400 KB
testcase_13 AC 157 ms
23,640 KB
testcase_14 AC 157 ms
23,388 KB
testcase_15 AC 24 ms
24,048 KB
testcase_16 AC 22 ms
24,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A{0, 1, 10000};
    const auto query{[](auto i, auto j) -> bool {
        if(i == 0)return true;
        if(i == 10000)return false;
        cout << "? " << i << " " << j << endl;
        unsigned long t;
        cin >> t;
        return t;
    }};
    for(unsigned long i{2}; i <= N; ++i){
        unsigned long l{0}, r{size(A) + 1};
        while(l + 1 < r){
            auto m{(l + r) / 2};
            (query(A[m], i) ? l : r) = m;
        }
        A.insert(begin(A) + l + 1, i);
    }
    A.pop_back();
    A.erase(begin(A));
    cout << "!" << endl;
    cout << N - 1 << endl;
    for(const auto a : A)cout << a << " ";
    cout << endl;
    return 0;
}
0