結果
| 問題 |
No.100 直列あみだくじ
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-01-01 18:29:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 642 bytes |
| コンパイル時間 | 113 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-11-22 13:24:08 |
| 合計ジャッジ時間 | 3,301 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 19 WA * 26 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
"""
・巡回置換の長さ
・2n+1 -> 2n+1
・2n -> n, n
・結局、偶数は同数ずつないといけないというのが条件
"""
N,*A = map(int,read().split())
A = [0] + A
period = [0] * (N+1)
for i,x in enumerate(A):
p = 0
y = x
while True:
y = A[y]
p += 1
if y == x:
break
period[i] = p
counter = [0] * (N+10)
for x in period[1:]:
counter[x] += 1
answer = 'Yes'
for i in range(0,N+10,2):
if counter[i] % 2 != 0:
answer = 'No'
print(answer)
maspy