結果

問題 No.241 出席番号(1)
ユーザー vjudge1
提出日時 2023-12-08 20:29:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 3,021 ms
コンパイル使用メモリ 161,720 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-27 03:04:33
合計ジャッジ時間 3,890 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
    int N;
    cin >> N;
    vector<int> hate(N),rr(N);
    for(auto &i:hate) cin >> i;
    for(int i = 0; i < N;i++)rr[i] = i;
    int T =1000;
    bool found = false;
    while(T--){
        shuffle(rr.begin(),rr.end(),mt);
        int i = 0;
        for( i = 0; i <N;i++){
            if(rr[i] == hate[i]) break;
        }
        if(i==N) {
            found = true;
            break;
        }
    }
    if(found) for(auto &i:rr) cout << i<<'\n';
    else cout << "-1\n";

    return 0;
}
0