結果

問題 No.482 あなたの名は
ユーザー roarisroaris
提出日時 2019-08-03 11:38:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 38,680 KB
最終ジャッジ日時 2023-09-18 18:39:07
合計ジャッジ時間 5,467 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,508 KB
testcase_01 AC 19 ms
8,580 KB
testcase_02 AC 18 ms
8,408 KB
testcase_03 AC 19 ms
8,516 KB
testcase_04 AC 18 ms
8,600 KB
testcase_05 AC 18 ms
8,596 KB
testcase_06 AC 18 ms
8,604 KB
testcase_07 AC 19 ms
8,592 KB
testcase_08 AC 21 ms
8,684 KB
testcase_09 AC 19 ms
8,508 KB
testcase_10 AC 19 ms
8,580 KB
testcase_11 AC 19 ms
8,628 KB
testcase_12 AC 20 ms
8,620 KB
testcase_13 AC 19 ms
8,472 KB
testcase_14 AC 19 ms
8,564 KB
testcase_15 AC 240 ms
38,676 KB
testcase_16 AC 247 ms
38,560 KB
testcase_17 AC 241 ms
38,672 KB
testcase_18 AC 247 ms
38,596 KB
testcase_19 AC 245 ms
38,600 KB
testcase_20 AC 244 ms
38,556 KB
testcase_21 AC 237 ms
38,508 KB
testcase_22 AC 240 ms
38,680 KB
testcase_23 AC 239 ms
38,468 KB
testcase_24 AC 238 ms
38,480 KB
testcase_25 AC 247 ms
38,580 KB
testcase_26 AC 243 ms
38,664 KB
testcase_27 AC 236 ms
38,660 KB
testcase_28 AC 240 ms
38,560 KB
testcase_29 AC 224 ms
38,604 KB
testcase_30 AC 18 ms
8,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N, K = map(int, input().split())
D = list(map(int, input().split()))
position = defaultdict(int)
cnt = 0

for i in range(N):
    position[D[i]] = i

for i in range(N):
    if D[i] == i + 1:
        continue
    D[position[i+1]] = D[i]
    position[D[i]] = position[i+1]
    D[i] = i + 1
    position[i+1] = i
    cnt += 1

if cnt > K or (K - cnt) % 2 == 1:
    print('NO')
else:
    print('YES')
0