結果
問題 | No.100 直列あみだくじ |
ユーザー |
![]() |
提出日時 | 2022-11-12 11:57:45 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 40 ms / 5,000 ms |
コード長 | 368 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-09-14 03:38:58 |
合計ジャッジ時間 | 3,551 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 |
ソースコード
import sys input=lambda:sys.stdin.readline().rstrip() N=int(input()) A=list(map(lambda x:int(x)-1,input().split())) cycle=[0 for i in range(N+1)] checked=[0 for i in range(N)] for i in range(N): if not checked[i]: cnt,pt=0,i while not checked[A[pt]]: pt=A[pt] checked[pt]=1 cnt+=1 if cnt%2==0: cycle[cnt]=1-cycle[cnt] print(["Yes","No"][max(cycle)])