結果
問題 | No.241 出席番号(1) |
ユーザー | masa |
提出日時 | 2015-07-10 22:59:22 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 577 ms |
コンパイル使用メモリ | 70,104 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 21:22:29 |
合計ジャッジ時間 | 1,836 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream>#include <cstdio>#include <vector>#include <algorithm>#include <utility>#include <string>#include <set>using namespace std;int main() {int n;cin >> n;vector<int> a(n, 0);set<int> nums;for (int i = 0; i < n; i++) {cin >> a[i];nums.insert(a[i]);}if (nums.size() == 1 && a[0] < n) {cout << -1 << endl;return 0;}vector<int> s(n);for (int i = 0; i < n; i++) {s[i] = i;}bool ok;while(1) {ok = true;for (int i = 0; i < n; i++) {if (s[i] == a[i]) {ok = false;break;}}if (ok) {break;}random_shuffle(s.begin(), s.end());}for (int i = 0; i < n; i++) {cout << s[i] << endl;}return 0;}