結果

問題 No.482 あなたの名は
ユーザー Mr.FukuMr.Fuku
提出日時 2018-08-08 16:40:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 367 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 31,844 KB
最終ジャッジ日時 2023-10-24 10:59:42
合計ジャッジ時間 4,545 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,100 KB
testcase_01 AC 30 ms
10,100 KB
testcase_02 AC 34 ms
10,100 KB
testcase_03 AC 31 ms
10,100 KB
testcase_04 AC 50 ms
10,100 KB
testcase_05 AC 30 ms
10,100 KB
testcase_06 AC 30 ms
10,100 KB
testcase_07 AC 30 ms
10,188 KB
testcase_08 AC 31 ms
10,144 KB
testcase_09 AC 30 ms
10,104 KB
testcase_10 AC 29 ms
10,140 KB
testcase_11 AC 30 ms
10,164 KB
testcase_12 AC 30 ms
10,180 KB
testcase_13 AC 30 ms
10,140 KB
testcase_14 AC 29 ms
10,132 KB
testcase_15 AC 159 ms
31,844 KB
testcase_16 AC 157 ms
31,844 KB
testcase_17 AC 160 ms
31,844 KB
testcase_18 AC 159 ms
31,844 KB
testcase_19 AC 160 ms
31,844 KB
testcase_20 AC 159 ms
31,844 KB
testcase_21 AC 160 ms
31,844 KB
testcase_22 AC 163 ms
31,844 KB
testcase_23 AC 167 ms
31,844 KB
testcase_24 AC 160 ms
31,844 KB
testcase_25 AC 163 ms
31,844 KB
testcase_26 AC 166 ms
31,844 KB
testcase_27 AC 160 ms
31,844 KB
testcase_28 AC 159 ms
31,844 KB
testcase_29 AC 148 ms
31,844 KB
testcase_30 AC 29 ms
10,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
lst = [0]+list(map(int,input().split()))

cnt = 0
def change(i,x):
    global cnt
    lst[i] = lst[x]
    lst[x] = x
    cnt+=1
    if cnt>K:
        print("NO")
        exit(0)
    if i!=lst[i]:
        change(i,lst[i])

for i in range(N+1):
    x = lst[i]
    if x!=i:
        change(i,x)

print("NO" if cnt>K or (K-cnt)%2 else "YES")
0