結果

問題 No.241 出席番号(1)
ユーザー kurenai3110kurenai3110
提出日時 2016-08-23 23:02:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 68,992 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 22:31:00
合計ジャッジ時間 4,626 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 AC 2 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
4,380 KB
testcase_28 WA -
testcase_29 AC 2 ms
4,380 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long

int n;
vector<int> seat,a;

int main() {

	cin >> n;
	seat.resize(n);
	a.resize(n);
	rep(i, n) {
		cin >> a[i];
		seat[i] = i;
	}
	
	bool flag = true, flag2 = true;
	while (flag && flag2) {
		bool flag3 = false;
		rep(i,n) {
			if (a[i] == seat[i]) {
				flag3 = true;
				rep(j, n) {
					if (a[j] != seat[i]) {
						cout << 1 << endl;
						swap(seat[i], seat[j]);
						break;
					}
					if (j == n - 1) {
						cout << -1 << endl;
						flag2 = false;
					}
				}
				flag = false;
				rep(j, n) {
					if (a[j] == seat[j]) flag = true;
				}
				break;
			}
			if (!flag3 && (i == n - 1)) {
				flag = false;
			}
		}
	}

	if (flag2) {
		rep(i, n) {
			cout << seat[i] << endl;
		}
	}
	return 0;
}
0