結果

問題 No.2085 Directed Complete Graph
ユーザー 259_Momone259_Momone
提出日時 2022-09-27 01:12:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 3,011 ms
コンパイル使用メモリ 260,836 KB
実行使用メモリ 24,408 KB
平均クエリ数 1652.76
最終ジャッジ日時 2023-08-24 03:23:32
合計ジャッジ時間 5,645 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,388 KB
testcase_01 AC 26 ms
24,060 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 59 ms
23,376 KB
testcase_06 AC 62 ms
23,436 KB
testcase_07 AC 95 ms
24,408 KB
testcase_08 AC 79 ms
23,424 KB
testcase_09 AC 102 ms
24,288 KB
testcase_10 AC 103 ms
24,372 KB
testcase_11 AC 102 ms
23,544 KB
testcase_12 AC 98 ms
24,348 KB
testcase_13 AC 101 ms
24,060 KB
testcase_14 AC 101 ms
24,216 KB
testcase_15 AC 27 ms
23,532 KB
testcase_16 AC 26 ms
24,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

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