結果
問題 |
No.241 出席番号(1)
|
ユーザー |
![]() |
提出日時 | 2024-12-05 20:08:04 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,902 bytes |
コンパイル時間 | 6,996 ms |
コンパイル使用メモリ | 278,568 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-05 20:15:22 |
合計ジャッジ時間 | 8,292 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define masterspark ios::sync_with_stdio(0), cin.tie(0),cout.tie(0),cin.exceptions(cin.failbit); template<class F, class S> ostream &operator<<(ostream &s, pair<F, S> v) { return s << "(" << v.first << ", " << v.second << ")";} template<class F, class S> istream &operator>>(istream &s, pair<F, S> &v) { return s >> v.first >> v.second; } template<class T> istream &operator>>(istream &s, vector<T> &a) { for (auto &x:a) s>>x; return s; } template<class T> ostream &operator<<(ostream &s, vector<T> &a) { int n=a.size(); if (!n) return s; s<<a[0]; for (int i=1; i<n; i++) s<<' '<<a[i]; return s; } #define int long long #define pp pair<int, int> #define ff first #define ss second #define forr(i,n) for(int i = 1; i <= n;++i) #define rep(i,j,n) for(int i = j; i < n;++i) #define PB push_back #define PF push_front #define EB emplace_back #define all(v) (v).begin(), (v).end() #define FZ(x) memset(x, 0, sizeof(x)) //fill zero #define SZ(x) ((int)x.size()) bool chmin(auto &a, auto b) { return (b < a) and (a = b, true); } bool chmax(auto &a, auto b) { return (a < b) and (a = b, true); } using i128 = __int128_t; using i64 = int64_t; using i32 = int32_t; mt19937 mt(chrono::steady_clock::now().time_since_epoch().count()); void solve(){ int n; cin >> n; vector<int> B(n,0),A(n,0); iota(all(B),0); cin >> A; int t = 5000; while(t--){ shuffle(all(B),mt); bool valid = true; for(int i = 0; i < n;++i){ if(A[i] == B[i]) valid = false; } if(valid){ for(auto c:B) cout << c << '\n'; return; } } cout << "-1\n"; } signed main() { masterspark int t = 1; // freopen("stdin","r",stdin); // freopen("stdout","w",stdout); // cin >> t; while(t--){ solve(); } return 0; } /* /\_/\ (= ._.) / > \> */