結果

問題 No.2085 Directed Complete Graph
ユーザー 259_Momone
提出日時 2022-09-27 01:12:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 801 bytes
コンパイル時間 2,755 ms
コンパイル使用メモリ 251,880 KB
最終ジャッジ日時 2025-02-07 16:37:59
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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