結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-02-11 14:01:42 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 223 ms / 2,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 671 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 40,992 KB |
最終ジャッジ日時 | 2024-12-29 20:36:27 |
合計ジャッジ時間 | 5,698 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#!/usr/bin/env python3 def judge(n, k, ds): ps = {d: i for i, d in enumerate(ds)} c = 0 for i in range(n): if ds[i] != i: j = ps[i] ds[i], ds[j] = ds[j], ds[i] ps[ds[i]] = i ps[ds[j]] = j c += 1 return c <= k and (c + k) % 2 == 0 def main(): n, k = (int(x) for x in input().split()) ds = [int(x) - 1 for x in input().split()] print("YES" if judge(n, k, ds) else "NO") if __name__ == '__main__': main()