結果

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

ソースコード

diff #

def main():
    n,k = map(int,input().split())
    d = list(map(int,input().split()))

    f = [-1 for _ in range(n)]

    for i in range(n):
        d[i] -= 1
        f[d[i]] = i

    ct = 0
    for i in range(n):
        if d[i] == i:
            continue

        x,y = i,f[i]
        d[x],d[y] = d[y],d[x]
        f[d[x]],f[d[y]] = x,y
        ct += 1

    if ct > k:
        return 'NO'

    return 'NO' if (k-ct)%2 == 0 else 'YES'

if __name__ == '__main__':
    print(main())
0