結果
問題 | No.241 出席番号(1) |
ユーザー |
![]() |
提出日時 | 2024-12-05 21:46:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 819 bytes |
コンパイル時間 | 3,539 ms |
コンパイル使用メモリ | 275,824 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-05 21:46:59 |
合計ジャッジ時間 | 5,082 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; int arr[100]; int ans[100]; signed main(){ ios::sync_with_stdio(0); cin.tie(0); mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); // uniform_int_distribution<> gen(0 , 1e9); int n; cin >> n; for(int i = 0 ; i < n ; i++) ans[i] = i , cin >> arr[i]; shuffle(ans, ans+n , mt); int t = 500; bool flag = 0; while(t--) { flag = 0; for(int i = 0 ; i < n ; i++) { if(ans[i] == arr[i]) { shuffle(ans , ans+n , mt); flag = 1; break; } } if(flag) continue; else break; } if(flag==0) { for(int i = 0 ; i < n ; i++) cout << ans[i] << '\n'; }else{ puts("-1"); } return 0; }