結果

問題 No.482 あなたの名は
ユーザー Tatsuno
提出日時 2017-02-11 17:35:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 29,588 KB
最終ジャッジ日時 2024-12-29 16:31:57
合計ジャッジ時間 4,669 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k=map(int,input().split())
d=list(map(lambda x: x-1, map(int,input().split())))

dif=False
for i in range(n-1):
    if d[i] == i: continue
    for j in range(i+1,n):
        if d[j] == j or j == d[i]: continue
        if d[j] != i:
            dif = True
            break
    if dif: break

cnt=0
for i in range(n):
    if d[i] == i: continue
    if d[d[i]] == i:
        cnt+=1
        d[d[i]] = d[i]
        d[i] = i
    else:
        cnt+=1

if dif and k >= cnt:
    print("YES")
else:
    print("YES" if cnt == k or (k>cnt and (k-cnt)&1==0) else "NO")
0