結果

問題 No.100 直列あみだくじ
ユーザー tnodino
提出日時 2022-04-08 20:31:20
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 388 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-28 11:19:59
合計ジャッジ時間 2,714 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
a = list(map(int,input().split()))
G = [0] * N
for i in range(N):
    G[i] = a[i] - 1
flg = [1] * N
cnt = 0
for i in range(N):
    if flg[i]:
        idx = i
        cnt2 = 0
        while flg[idx]:
            flg[idx] = 0
            idx = G[idx]
            cnt2 += 1
        if not cnt2 % 2:
            cnt += 1
if not cnt % 2:
    print('Yes')
else:
    print('No')
0