結果
問題 | No.241 出席番号(1) |
ユーザー |
![]() |
提出日時 | 2024-12-09 18:24:15 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 597 ms / 2,000 ms |
コード長 | 1,137 bytes |
コンパイル時間 | 2,941 ms |
コンパイル使用メモリ | 249,648 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-09 18:24:21 |
合計ジャッジ時間 | 5,119 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> #include <random> #include <chrono> using namespace std; void debug() {} template<class T> void debug(T var) { cerr << var; } template<class T, class ...P> void debug(T var, P ...t) { cerr << var << ", "; debug(t...); } template<class T> void org(T l, T r) { while(l != r) cerr << *l++ << ' '; } #define de(...) { cerr << "[Line: " << __LINE__ << "][" << #__VA_ARGS__ << "] -> [", debug(__VA_ARGS__), cerr << "]\n"; } #define orange(...) { cerr << "[Line: " << __LINE__ << "][" << #__VA_ARGS__ << "] -> [", org(__VA_ARGS__), cerr << "]\n"; } #define All(x) (x).begin(), (x).end() constexpr int RT = 1e6; mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); int main() { int N; cin >> N; vector<int> A(N); for(auto& i : A) cin >> i; vector<int> ans(N); iota(All(ans), 0); auto check = [&]() -> bool { for(int i = 0; i < N; ++i) { if(ans[i] == A[i]) return false; } return true; }; for(int rt = 0; rt < RT; ++rt) { if(check()) break; shuffle(All(ans), mt); } if(check()) for(auto& i : ans) cout << i << '\n'; else cout << "-1\n"; }