結果
問題 | No.482 あなたの名は |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:08:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 542 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,300 KB |
実行使用メモリ | 108,348 KB |
最終ジャッジ日時 | 2025-03-20 21:08:57 |
合計ジャッジ時間 | 3,240 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
N, K = map(int, input().split())D = list(map(int, input().split()))visited = [False] * (N + 1) # 1-based indexings_min = 0for i in range(1, N + 1):if not visited[i]:cycle_length = 0current = iwhile not visited[current]:visited[current] = Truecurrent = D[current - 1] # D is 0-based list for 1-based elementscycle_length += 1s_min += (cycle_length - 1)# Check the conditionsif K >= s_min and (K - s_min) % 2 == 0:print("YES")else:print("NO")