結果

問題 No.482 あなたの名は
コンテスト
ユーザー htkb
提出日時 2018-05-22 21:49:00
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 290 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 603 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 34,500 KB
最終ジャッジ日時 2026-03-17 14:09:50
合計ジャッジ時間 6,350 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, K = map(int, input().split())
a = tuple(map(int, input().split()))
x = 0
pair = 0
for i, n in enumerate(a, start=1):
    if i == n:
        continue
    if a[n-1] == i:
        pair += 1
    else:
        x += 1
x = max(0, x-1) + pair//2
print("YES" if x <= K and (K-x)%2 == 0 else "NO")
0