結果

問題 No.2085 Directed Complete Graph
ユーザー ぷらぷら
提出日時 2022-09-26 01:29:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,252 bytes
コンパイル時間 2,159 ms
コンパイル使用メモリ 204,212 KB
実行使用メモリ 24,528 KB
平均クエリ数 1908.00
最終ジャッジ日時 2023-08-24 03:08:43
合計ジャッジ時間 5,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,424 KB
testcase_01 AC 25 ms
24,324 KB
testcase_02 WA -
testcase_03 AC 155 ms
23,856 KB
testcase_04 WA -
testcase_05 AC 68 ms
24,336 KB
testcase_06 AC 73 ms
23,700 KB
testcase_07 AC 113 ms
23,436 KB
testcase_08 AC 89 ms
23,856 KB
testcase_09 AC 115 ms
24,036 KB
testcase_10 AC 122 ms
24,288 KB
testcase_11 AC 119 ms
24,156 KB
testcase_12 AC 122 ms
24,348 KB
testcase_13 AC 119 ms
23,544 KB
testcase_14 AC 118 ms
23,592 KB
testcase_15 AC 25 ms
23,388 KB
testcase_16 AC 25 ms
23,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int>ans;
    ans.push_back(1);
    for(int i = 2; i <= N; i++) {
        cout << "? " << ans.back() << " " << i << endl;
        int f;
        cin >> f;
        if(f) {
            ans.push_back(i);
            continue;
        }
        if(i == 2) {
            ans = {2,1};
            continue;
        }
        int l = -1,r = i-2;
        while(l+1 < r) {
            int mid = (l+r)/2;
            cout << "? " << ans[mid] << " " << i << endl;
            cin >> f;
            if(f) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
        vector<int>nxt;
        for(int j = 0; j < ans.size(); j++) {
            if(l == -1 && j == 0) {
                nxt.push_back(i);
            }
            if(j <= l) {
                nxt.push_back(ans[j]);
            }
            if(j == l) {
                nxt.push_back(i);
            }
            if(l < j) {
                nxt.push_back(ans[j]);
            }
        }
        ans = nxt;
    }
    cout << "!" << endl;
    cout << N-1 << endl;
    for(int i = 0; i <= N; i++) {
        cout << ans[i] << ((i == N)?"\n":" ");
    }
}
0