結果
問題 | No.241 出席番号(1) |
ユーザー |
![]() |
提出日時 | 2015-10-05 23:55:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 1,207 ms |
コンパイル使用メモリ | 161,024 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 21:34:10 |
合計ジャッジ時間 | 2,285 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include "bits/stdc++.h"using namespace std;#define REP(i, n) for(int i=0; i<(n); i++)int N;int ok(vector<int> A, vector<int> B) {REP(i,N) {if (B[i] == A[i]) return i;}return -1;}signed main(){cin >> N;vector<int> A(N);vector<int> B(N);REP(i,N) cin >> A[i];REP(i,N) B[i] = i;int t;int cnt = 0;while((t = ok(A, B)) > -1) {int hate = B[t]; // この番号をほかの人に移したいREP(i,N) {if (A[i] != hate) {swap(B[i], B[t]);break;}}if (cnt++ > 100) break;}if (t != -1) {cout << -1 << endl;return 0;}REP(i,N) cout << B[i] << endl;return 0;}