結果

問題 No.241 出席番号(1)
ユーザー vjudge1
提出日時 2024-12-09 00:34:52
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 3,352 ms
コンパイル使用メモリ 279,004 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-09 00:34:59
合計ジャッジ時間 4,665 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;

mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<> dis(0, 1e9);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> vec(n), arr(n);
    for (int &i : arr)
        cin >> i;
    for (int i = 0; i < n; i++)
        vec[i] = i;

    for (int k = 0; k < 100; k++) {
        shuffle(all(vec), mt);
        bool cc = true;
        for (int i = 0; i < n; i++) {
            if (arr[i] == vec[i])
                cc = false;
        }
        if (cc) {
            for (int i = 0; i < n; i++)
                cout << vec[i] << '\n';
            cout << '\n';
            return 0;
        }
    }

    cout << "-1\n";

    return 0;
}
0