結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2018-05-22 22:05:57 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 218 ms / 2,000 ms |
コード長 | 343 bytes |
コンパイル時間 | 74 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 33,772 KB |
最終ジャッジ日時 | 2024-06-28 15:54:06 |
合計ジャッジ時間 | 4,561 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
N, K = map(int, input().split()) a = [0]+list(map(int, input().split())) x = 0 visited = set() add = visited.add for i in range(1, N+1): if i in visited or a[i] == i: continue cnt = 0 while i not in visited: add(i) cnt += 1 i = a[i] x += cnt - 1 print("YES" if x <= K and (K-x)%2 == 0 else "NO")