結果

問題 No.100 直列あみだくじ
ユーザー ayaoni
提出日時 2021-08-31 00:08:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 36 ms / 5,000 ms
コード長 781 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 52,608 KB
最終ジャッジ日時 2024-11-24 09:49:42
合計ジャッジ時間 2,955 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

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