結果

問題 No.2089 置換の符号
ユーザー Akijin_007Akijin_007
提出日時 2022-09-30 22:05:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 1,587 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 76,376 KB
最終ジャッジ日時 2023-08-24 15:38:33
合計ジャッジ時間 4,252 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,364 KB
testcase_01 AC 71 ms
70,924 KB
testcase_02 AC 70 ms
71,120 KB
testcase_03 AC 71 ms
70,996 KB
testcase_04 AC 72 ms
71,072 KB
testcase_05 AC 73 ms
71,228 KB
testcase_06 AC 72 ms
71,072 KB
testcase_07 AC 72 ms
71,132 KB
testcase_08 AC 71 ms
71,228 KB
testcase_09 AC 71 ms
71,076 KB
testcase_10 AC 71 ms
71,344 KB
testcase_11 AC 70 ms
70,996 KB
testcase_12 AC 70 ms
71,000 KB
testcase_13 AC 72 ms
71,300 KB
testcase_14 AC 71 ms
71,092 KB
testcase_15 AC 72 ms
71,068 KB
testcase_16 AC 72 ms
71,064 KB
testcase_17 AC 72 ms
71,336 KB
testcase_18 AC 72 ms
71,120 KB
testcase_19 AC 71 ms
71,424 KB
testcase_20 AC 72 ms
70,992 KB
testcase_21 AC 73 ms
71,084 KB
testcase_22 AC 71 ms
71,248 KB
testcase_23 AC 72 ms
71,188 KB
testcase_24 AC 72 ms
71,220 KB
testcase_25 AC 73 ms
71,212 KB
testcase_26 AC 72 ms
71,064 KB
testcase_27 AC 78 ms
76,376 KB
testcase_28 AC 81 ms
76,152 KB
testcase_29 AC 78 ms
76,132 KB
testcase_30 AC 78 ms
76,288 KB
testcase_31 AC 79 ms
76,164 KB
testcase_32 AC 79 ms
76,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))


N = int(input())
S = list(map(int, input().split()))

p = [0] * N
for i in range(N):
    p[S[i]-1] = i

t = 0
for i in range(N):
    if p[i] != i:
        t += 1
        q = p[i]
        u = S[i]
        S[i], S[q] = S[q], S[i]
        p[i] = i
        p[u-1] = q

# print(S)

print(-(t % 2) * 2 + 1)

0