結果

問題 No.482 あなたの名は
ユーザー trineutron
提出日時 2021-01-12 12:00:42
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 335 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 29,692 KB
最終ジャッジ日時 2024-11-21 09:41:50
合計ジャッジ時間 4,925 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
d = list(map(int, input().split()))
idx = [0] * n
for i in range(n):
    d[i] -= 1
    idx[d[i]] = i
swaps = 0
for i in range(n):
    if d[i] == i:
        continue
    x = idx[i]
    d[i], d[x] = d[x], d[i]
    swaps += 1
if k >= swaps and (k - swaps) % 2 == 0:
    print('YES')
else:
    print('NO')
0