結果

問題 No.2089 置換の符号
ユーザー KudeKude
提出日時 2022-09-30 21:30:49
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 76,400 KB
最終ジャッジ日時 2023-08-24 14:48:39
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,008 KB
testcase_01 AC 72 ms
71,256 KB
testcase_02 AC 71 ms
71,388 KB
testcase_03 AC 71 ms
71,300 KB
testcase_04 AC 71 ms
71,368 KB
testcase_05 AC 71 ms
71,248 KB
testcase_06 AC 70 ms
71,360 KB
testcase_07 AC 72 ms
71,304 KB
testcase_08 AC 72 ms
71,280 KB
testcase_09 AC 71 ms
71,380 KB
testcase_10 AC 72 ms
71,304 KB
testcase_11 AC 72 ms
71,416 KB
testcase_12 AC 72 ms
71,272 KB
testcase_13 AC 71 ms
71,312 KB
testcase_14 AC 72 ms
71,308 KB
testcase_15 AC 71 ms
71,276 KB
testcase_16 AC 71 ms
71,320 KB
testcase_17 AC 73 ms
71,344 KB
testcase_18 AC 71 ms
71,144 KB
testcase_19 AC 72 ms
71,376 KB
testcase_20 AC 71 ms
71,144 KB
testcase_21 AC 71 ms
71,144 KB
testcase_22 AC 72 ms
71,248 KB
testcase_23 AC 72 ms
71,292 KB
testcase_24 AC 71 ms
71,320 KB
testcase_25 AC 72 ms
71,008 KB
testcase_26 AC 71 ms
71,300 KB
testcase_27 AC 77 ms
76,304 KB
testcase_28 AC 76 ms
76,228 KB
testcase_29 AC 78 ms
76,100 KB
testcase_30 AC 78 ms
76,104 KB
testcase_31 AC 79 ms
76,400 KB
testcase_32 AC 81 ms
76,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
visited = [False] * n
c = 0
for i in range(n):
    if visited[i]:
        continue
    c += 1
    while not visited[i]:
        c += 1
        visited[i] = True
        i = a[i] - 1
print((-1) ** c)
0