結果

問題 No.2085 Directed Complete Graph
ユーザー だれだれ
提出日時 2022-09-23 18:53:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 1,011 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 70,856 KB
実行使用メモリ 24,384 KB
平均クエリ数 2472.00
最終ジャッジ日時 2023-08-24 03:07:10
合計ジャッジ時間 3,777 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,376 KB
testcase_01 AC 26 ms
24,264 KB
testcase_02 AC 152 ms
24,384 KB
testcase_03 AC 146 ms
24,336 KB
testcase_04 AC 159 ms
24,252 KB
testcase_05 AC 85 ms
24,360 KB
testcase_06 AC 90 ms
24,036 KB
testcase_07 AC 150 ms
24,036 KB
testcase_08 AC 117 ms
24,336 KB
testcase_09 AC 147 ms
23,556 KB
testcase_10 AC 155 ms
24,336 KB
testcase_11 AC 156 ms
24,036 KB
testcase_12 AC 156 ms
23,436 KB
testcase_13 AC 155 ms
24,036 KB
testcase_14 AC 156 ms
23,532 KB
testcase_15 AC 26 ms
24,036 KB
testcase_16 AC 26 ms
24,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int edge[2010][2010];
int tmp[2020];
int arr[2020];

void merge_sort(int idx, int _n) {
    if (_n == 1) return;
    auto t = _n / 2;
    merge_sort(idx, t);
    merge_sort(idx + t, _n - t);
    int i = idx, j = idx + t;
    int cnt = 0;
    while (i < idx + t && j < idx + _n) {
        cout << "? " << arr[i] + 1 << " " << arr[j] + 1 << endl;
        int h;
        cin >> h;
        if (h) {
            tmp[cnt++] = arr[i++];
        }
        else {
            tmp[cnt++] = arr[j++];
        }
    }
    while (i < idx + t) {
        tmp[cnt++] = arr[i++];
    }
    while (j < idx + _n) {
        tmp[cnt++] = arr[j++];
    }
    for (int k = 0; k < _n; k++) {
        arr[idx + k] = tmp[k];
    }
    return;
}

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) arr[i] = i;
    merge_sort(0, n);
    cout << "!" << endl;
    cout << n - 1 << endl;
    for (int i = 0; i < n; i++) cout << arr[i] + 1 << (i == n - 1? "\n": " ");
    return 0;
}
0