結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2017-02-11 13:56:18 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 501 bytes |
| 記録 | |
| コンパイル時間 | 468 ms |
| コンパイル使用メモリ | 20,824 KB |
| 実行使用メモリ | 34,500 KB |
| 最終ジャッジ日時 | 2026-06-03 06:53:14 |
| 合計ジャッジ時間 | 5,554 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()
はむ吉🐹