結果

問題 No.241 出席番号(1)
ユーザー niyarinniyarin
提出日時 2016-08-23 22:09:17
言語 Python2
(2.7.18)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 543 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 6,160 KB
最終ジャッジ日時 2023-08-20 17:55:25
合計ジャッジ時間 2,630 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,160 KB
testcase_01 AC 9 ms
6,108 KB
testcase_02 AC 9 ms
5,992 KB
testcase_03 AC 9 ms
6,060 KB
testcase_04 AC 8 ms
5,980 KB
testcase_05 AC 9 ms
5,976 KB
testcase_06 AC 9 ms
6,160 KB
testcase_07 AC 9 ms
6,108 KB
testcase_08 AC 8 ms
5,984 KB
testcase_09 AC 9 ms
5,976 KB
testcase_10 AC 9 ms
6,008 KB
testcase_11 AC 10 ms
6,064 KB
testcase_12 AC 9 ms
6,136 KB
testcase_13 AC 10 ms
6,160 KB
testcase_14 AC 10 ms
5,988 KB
testcase_15 AC 10 ms
6,012 KB
testcase_16 AC 9 ms
6,064 KB
testcase_17 AC 10 ms
6,008 KB
testcase_18 AC 9 ms
5,900 KB
testcase_19 AC 9 ms
6,084 KB
testcase_20 AC 9 ms
6,092 KB
testcase_21 AC 9 ms
6,004 KB
testcase_22 AC 9 ms
6,004 KB
testcase_23 AC 9 ms
6,076 KB
testcase_24 AC 10 ms
6,060 KB
testcase_25 AC 9 ms
6,112 KB
testcase_26 AC 9 ms
6,104 KB
testcase_27 AC 9 ms
6,108 KB
testcase_28 AC 9 ms
6,064 KB
testcase_29 AC 9 ms
6,108 KB
testcase_30 AC 9 ms
6,012 KB
testcase_31 AC 9 ms
5,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
A = [input() for i in range(N)]

nyrn = [ i for i in range(N)]
iyada = []
imp = False
for i in range(N):
    if A[i] == nyrn[i]:
        iyada.append(i)
while iyada:
    if (len(iyada) > 2):
        a = iyada.pop()
        b = iyada.pop()
        nyrn[a],nyrn[b] = nyrn[b],nyrn[a]
    else:
        a = iyada.pop()
        b = -1
        for i in range(N):
            if nyrn[a] != A[i]:
                b = i
        if b == -1:
            imp = True
            break
        nyrn[a],nyrn[b] = nyrn[b],nyrn[a]
if not imp:
    for n in nyrn:
        print n
else:
    print -1
0