結果

問題 No.241 出席番号(1)
ユーザー mamekin
提出日時 2016-02-14 18:49:15
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,182 bytes
コンパイル時間 841 ms
コンパイル使用メモリ 93,552 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 21:35:06
合計ジャッジ時間 2,053 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

unsigned xor128(){
    static unsigned x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        b[i] = i;
    }

    for(int t=0; t<1000; ++t){
        for(int i=0; i<n; ++i){
            int j = i + xor128() % (n - i);
            swap(b[i], b[j]);
        }

        bool ok = true;
        for(int i=0; i<n; ++i){
            if(a[i] == b[i])
                ok = false;
        }

        if(ok){
            for(int i=0; i<n; ++i)
                cout << b[i] << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}
0