結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2017-02-11 13:56:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 501 bytes |
| 記録 | |
| コンパイル時間 | 478 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 29,588 KB |
| 最終ジャッジ日時 | 2024-12-29 12:15:30 |
| 合計ジャッジ時間 | 4,285 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 9 |
ソースコード
#!/usr/bin/env python3
def judge(n, k, ds):
ps = [ds[i] for i in range(n)]
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()
はむ吉🐹