結果

問題 No.2085 Directed Complete Graph
ユーザー 259_Momone259_Momone
提出日時 2022-09-27 01:05:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 969 bytes
コンパイル時間 2,827 ms
コンパイル使用メモリ 263,440 KB
実行使用メモリ 24,516 KB
平均クエリ数 3129.94
最終ジャッジ日時 2023-08-24 03:23:09
合計ジャッジ時間 6,127 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,072 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 26 ms
24,360 KB
testcase_16 AC 25 ms
24,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    iota(begin(A), end(A), 1);
    mt19937_64 mt{random_device{}()};
    const auto cmp{[](unsigned long x){
        return [x](unsigned long y) -> bool {
            if(x == y)return 0;
            cout << "? " << y << " " << x << endl;
            unsigned long t;
            cin >> t;
            return t;
        };
    }};
    [rec_impl{[&A, &mt, &cmp](auto&& f, unsigned long l, unsigned long r) -> void {
        while(l + 1 < r){
            unsigned long d{uniform_int_distribution<unsigned long>{l, r - 1}(mt)};
            const auto m{partition(begin(A) + l, begin(A) + r, cmp(A[d])) - begin(A)};
            f(f, l, m);
            l = m + 1;
        }
    }}, &N]{rec_impl(rec_impl, 0, N);}();
    cout << "!" << endl;
    cout << N - 1 << endl;
    for(const auto a : A)cout << a << " ";
    cout << endl;
    return 0;
}
0