結果

問題 No.100 直列あみだくじ
ユーザー tnodino
提出日時 2022-04-09 13:29:04
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-29 11:33:34
合計ジャッジ時間 3,018 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 9
権限があれば一括ダウンロードができます

ソースコード

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
        Roop = 0
        while flg[idx]:
            flg[idx] = 0
            idx = G[idx]
            Roop += 1
        if Roop % 2 == 0:
            cnt2 = -1
            while Roop % 2 == 0:
                Roop //= 2
                cnt2 += 1
            cnt += pow(2, cnt2)
if cnt % 2 == 0:
    print('Yes')
else:
    print('No')
0