結果

問題 No.482 あなたの名は
ユーザー はむ吉🐹はむ吉🐹
提出日時 2017-02-11 13:56:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 30,120 KB
最終ジャッジ日時 2023-08-28 12:53:08
合計ジャッジ時間 3,814 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,864 KB
testcase_01 AC 17 ms
7,820 KB
testcase_02 AC 16 ms
7,836 KB
testcase_03 AC 15 ms
7,868 KB
testcase_04 AC 16 ms
7,820 KB
testcase_05 AC 15 ms
7,960 KB
testcase_06 AC 16 ms
7,884 KB
testcase_07 AC 16 ms
8,440 KB
testcase_08 AC 16 ms
7,820 KB
testcase_09 AC 16 ms
7,844 KB
testcase_10 AC 15 ms
7,968 KB
testcase_11 AC 15 ms
7,840 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 121 ms
30,052 KB
testcase_17 AC 123 ms
29,920 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 125 ms
29,876 KB
testcase_21 AC 127 ms
30,108 KB
testcase_22 AC 135 ms
30,060 KB
testcase_23 AC 126 ms
29,952 KB
testcase_24 WA -
testcase_25 AC 126 ms
30,028 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 126 ms
29,908 KB
testcase_29 AC 112 ms
29,964 KB
testcase_30 AC 16 ms
7,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3


def judge(n, k, ds):
    ps = [ds[i] for i in range(n)]
    c = 0
    for i in range(n):
        if ds[i] != i:
            j = ps[i]
            ds[i], ds[j] = ds[j], ds[i]
            ps[ds[i]] = i
            ps[ds[j]] = j
            c += 1
    return c <= k and (c + k) % 2 == 0


def main():
    n, k = (int(x) for x in input().split())
    ds = [int(x) - 1 for x in input().split()]
    print("YES" if judge(n, k, ds) else "NO")


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