結果

問題 No.482 あなたの名は
ユーザー imulanimulan
提出日時 2017-02-12 04:19:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 66 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 30,080 KB
最終ジャッジ日時 2023-08-28 16:21:52
合計ジャッジ時間 3,597 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,796 KB
testcase_01 AC 15 ms
7,756 KB
testcase_02 AC 14 ms
7,980 KB
testcase_03 AC 14 ms
7,952 KB
testcase_04 AC 14 ms
7,836 KB
testcase_05 AC 14 ms
7,784 KB
testcase_06 AC 15 ms
7,912 KB
testcase_07 AC 14 ms
8,256 KB
testcase_08 AC 14 ms
7,828 KB
testcase_09 AC 15 ms
7,776 KB
testcase_10 AC 15 ms
7,808 KB
testcase_11 AC 17 ms
7,832 KB
testcase_12 AC 15 ms
8,328 KB
testcase_13 AC 14 ms
7,784 KB
testcase_14 AC 14 ms
7,828 KB
testcase_15 AC 120 ms
30,008 KB
testcase_16 AC 119 ms
29,996 KB
testcase_17 AC 121 ms
29,876 KB
testcase_18 AC 120 ms
30,048 KB
testcase_19 AC 120 ms
29,864 KB
testcase_20 AC 119 ms
30,072 KB
testcase_21 AC 121 ms
29,888 KB
testcase_22 AC 119 ms
30,040 KB
testcase_23 AC 122 ms
30,080 KB
testcase_24 AC 120 ms
29,916 KB
testcase_25 AC 122 ms
30,012 KB
testcase_26 AC 120 ms
29,984 KB
testcase_27 AC 124 ms
30,060 KB
testcase_28 AC 120 ms
30,072 KB
testcase_29 AC 112 ms
30,008 KB
testcase_30 AC 15 ms
7,876 KB
権限があれば一括ダウンロードができます

ソースコード

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 'YES' if (k-ct)%2 == 0 else 'NO'

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