結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
はむ吉🐹
|
| 提出日時 | 2017-02-11 13:56:18 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 501 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 15,104 KB |
| 実行使用メモリ | 31,456 KB |
| 最終ジャッジ日時 | 2026-10-09 08:06:41 |
| 合計ジャッジ時間 | 4,148 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()
はむ吉🐹