結果

問題 No.100 直列あみだくじ
ユーザー ayaoniayaoni
提出日時 2021-08-31 00:08:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 5,000 ms
コード長 781 bytes
コンパイル時間 441 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 71,644 KB
最終ジャッジ日時 2023-08-16 00:35:37
合計ジャッジ時間 5,956 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,524 KB
testcase_01 AC 67 ms
71,424 KB
testcase_02 AC 73 ms
71,240 KB
testcase_03 AC 67 ms
71,404 KB
testcase_04 AC 68 ms
71,440 KB
testcase_05 AC 69 ms
71,472 KB
testcase_06 AC 66 ms
71,444 KB
testcase_07 AC 69 ms
71,112 KB
testcase_08 AC 69 ms
71,420 KB
testcase_09 AC 68 ms
71,188 KB
testcase_10 AC 67 ms
71,548 KB
testcase_11 AC 69 ms
71,424 KB
testcase_12 AC 71 ms
71,624 KB
testcase_13 AC 68 ms
71,524 KB
testcase_14 AC 68 ms
71,248 KB
testcase_15 AC 70 ms
71,584 KB
testcase_16 AC 74 ms
71,608 KB
testcase_17 AC 71 ms
71,424 KB
testcase_18 AC 69 ms
71,436 KB
testcase_19 AC 70 ms
71,340 KB
testcase_20 AC 68 ms
71,260 KB
testcase_21 AC 69 ms
71,384 KB
testcase_22 AC 68 ms
71,436 KB
testcase_23 AC 67 ms
71,264 KB
testcase_24 AC 69 ms
71,344 KB
testcase_25 AC 68 ms
71,104 KB
testcase_26 AC 68 ms
71,108 KB
testcase_27 AC 71 ms
71,440 KB
testcase_28 AC 71 ms
71,416 KB
testcase_29 AC 73 ms
71,548 KB
testcase_30 AC 71 ms
71,408 KB
testcase_31 AC 71 ms
71,484 KB
testcase_32 AC 71 ms
71,540 KB
testcase_33 AC 70 ms
71,364 KB
testcase_34 AC 71 ms
71,564 KB
testcase_35 AC 72 ms
71,180 KB
testcase_36 AC 76 ms
71,244 KB
testcase_37 AC 72 ms
71,188 KB
testcase_38 AC 73 ms
71,248 KB
testcase_39 AC 72 ms
71,104 KB
testcase_40 AC 70 ms
71,364 KB
testcase_41 AC 70 ms
71,344 KB
testcase_42 AC 71 ms
71,304 KB
testcase_43 AC 70 ms
71,644 KB
testcase_44 AC 72 ms
71,612 KB
testcase_45 AC 71 ms
71,600 KB
testcase_46 AC 71 ms
71,544 KB
testcase_47 AC 72 ms
71,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
A = [0]+LI()

flag = [0]*(N+1)
size = [0]*(N+1)
for i in range(1,N+1):
    if flag[i]:
        continue
    cur = A[i]
    flag[i] = 1
    count = 1
    while cur != i:
        flag[cur] = 1
        cur = A[cur]
        count += 1
    size[count] ^= 1

for i in range(2,N+1,2):
    if size[i]:
        print('No')
        break
else:
    print('Yes')
0