結果

問題 No.2085 Directed Complete Graph
ユーザー 259_Momone
提出日時 2022-09-27 01:12:12
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 801 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,622 ms
コンパイル使用メモリ 288,204 KB
実行使用メモリ 30,020 KB
平均クエリ数 1652.76
最終ジャッジ日時 2026-06-27 18:53:06
合計ジャッジ時間 3,660 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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