結果

問題 No.482 あなたの名は
ユーザー TatsunoTatsuno
提出日時 2017-02-11 17:09:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 379 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 30,048 KB
最終ジャッジ日時 2023-08-28 14:43:42
合計ジャッジ時間 4,035 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,784 KB
testcase_01 AC 15 ms
7,900 KB
testcase_02 AC 15 ms
7,816 KB
testcase_03 AC 15 ms
7,748 KB
testcase_04 AC 16 ms
7,936 KB
testcase_05 AC 16 ms
7,752 KB
testcase_06 AC 14 ms
7,772 KB
testcase_07 AC 15 ms
7,756 KB
testcase_08 AC 15 ms
7,804 KB
testcase_09 AC 14 ms
7,832 KB
testcase_10 AC 15 ms
7,868 KB
testcase_11 AC 14 ms
7,840 KB
testcase_12 AC 15 ms
7,900 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 158 ms
30,004 KB
testcase_18 AC 154 ms
29,840 KB
testcase_19 WA -
testcase_20 AC 156 ms
29,836 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 161 ms
30,008 KB
testcase_25 AC 154 ms
29,840 KB
testcase_26 AC 158 ms
29,980 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 160 ms
29,848 KB
testcase_30 AC 15 ms
7,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k=map(int,input().split())
d=list(map(lambda x: x-1, map(int,input().split())))
dif=False
cnt=0
for i in range(n):
    j = d[i]
    if d[i] == i: continue
    if d[j] == i:
        cnt+=1
        d[i] = i
        d[j] = j
    else:
        cnt+=1
        dif = True
if dif and k >= cnt:
    print("YES")
else:
    print("YES" if cnt == k or (k>cnt and (k-cnt)&1==0) else "NO")
0