結果

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

ソースコード

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