結果
問題 |
No.241 出席番号(1)
|
ユーザー |
![]() |
提出日時 | 2023-12-08 20:47:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 930 bytes |
コンパイル時間 | 3,048 ms |
コンパイル使用メモリ | 250,616 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-27 03:05:38 |
合計ジャッジ時間 | 4,258 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include<bits/stdc++.h> #define ll long long #define io ios::sync_with_stdio(0), cin.tie(0); #define endl '\n' #define MXN (int)1e6+5 #define MN (int)1e5+5 constexpr int INF=0x3f3f3f3f; using namespace std; mt19937 gen(hash<string>()(":poop:")); uniform_int_distribution<> dis(0, 1e9); int main(){ io int n; cin>>n; vector<int>v(n); vector<int>ran(n); for(int i=0;i<n;i++){ cin>>v[i]; ran[i]=i; } bool f=false; for(int i=0;i<150;i++){ shuffle(ran.begin(),ran.end(),gen); f=false; for(int j=0;j<n;j++){ if(ran[j]==v[j]){ f=true; break; } } if(f){ continue; } else{ break; } } if(!f){ for(int i=0;i<n;i++){ cout<<ran[i]<<endl; } } else{ cout<<-1<<endl; } return 0; } //test4