結果

問題 No.2085 Directed Complete Graph
ユーザー momoyuumomoyuu
提出日時 2023-04-23 01:33:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,372 bytes
コンパイル時間 3,878 ms
コンパイル使用メモリ 282,252 KB
実行使用メモリ 39,088 KB
最終ジャッジ日時 2024-04-25 02:25:08
合計ジャッジ時間 10,472 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int64_t seed = chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count();
    mt19937_64 rnd(seed);
    int n;
    cin>>n;
    uniform_int_distribution<int> mm(1,n);
    deque<int> que;
    int l = 1;
    int r = 2;
    cout<<"? 1 2";
    int t;
    cin>>t;
    if(t==1);
    else swap(l,r);
    que.push_back(l);
    que.push_back(r);
    int ni = 3;
    vector<int> vis(n+1,0);
    vis[1] = 1;
    vis[2] = 1;
    while(que.size()<n){
        ni = mm(rnd);
        if(vis[ni]) continue;
        int t1,t2;
        cout<<"? "<<que.front()<<" "<<ni<<endl;
        cin>>t1;
        cout<<"? "<<que.back()<<" "<<ni<<endl;
        cin>>t2;
        if(t2==1){
            que.push_back(ni);
            vis[ni] = 1;
            continue;
        }
        if(t1==0){
            que.push_front(ni);
            vis[ni] = 1;
            continue;
        }
        int t3;
        cout<<"? "<<que.front()<<" "<<que.back()<<endl;
        cin>>t3;
        if(t3==0){
            que.push_front(que.back());
            que.pop_back();
            que.push_front(ni);
            vis[ni] = 1;
            continue;
        }
    }
    cout<<n-1<<endl;
    for(int i = 0;i<n;i++){
        if(i!=0) cout<<" ";
        cout<<que[i];
    }
    cout<<endl;
}

0