結果

問題 No.482 あなたの名は
ユーザー k-matsk-mats
提出日時 2017-02-11 00:53:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 560 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 40,208 KB
最終ジャッジ日時 2023-08-28 12:38:03
合計ジャッジ時間 5,866 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,916 KB
testcase_02 AC 17 ms
7,912 KB
testcase_03 AC 15 ms
7,808 KB
testcase_04 AC 16 ms
7,768 KB
testcase_05 AC 16 ms
7,808 KB
testcase_06 AC 15 ms
7,976 KB
testcase_07 AC 17 ms
8,452 KB
testcase_08 AC 17 ms
7,952 KB
testcase_09 AC 16 ms
7,800 KB
testcase_10 AC 17 ms
7,900 KB
testcase_11 AC 17 ms
8,232 KB
testcase_12 AC 16 ms
8,316 KB
testcase_13 AC 17 ms
7,936 KB
testcase_14 AC 17 ms
7,892 KB
testcase_15 AC 281 ms
40,128 KB
testcase_16 AC 270 ms
40,140 KB
testcase_17 AC 269 ms
40,176 KB
testcase_18 AC 269 ms
40,076 KB
testcase_19 AC 266 ms
40,208 KB
testcase_20 AC 265 ms
40,008 KB
testcase_21 AC 269 ms
40,004 KB
testcase_22 AC 272 ms
40,000 KB
testcase_23 AC 272 ms
40,048 KB
testcase_24 AC 267 ms
40,144 KB
testcase_25 AC 266 ms
39,996 KB
testcase_26 AC 271 ms
40,032 KB
testcase_27 AC 267 ms
40,000 KB
testcase_28 AC 267 ms
40,076 KB
testcase_29 AC 244 ms
39,216 KB
testcase_30 AC 18 ms
7,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = [int(i) for i in input().split()]
d = [int(i) - 1 for i in input().split()]

e = [0 for i in range(n)]
for i, d_i in enumerate(d):
    e[d_i] = i

used_indices = set()
swap_times = list()

for i in range(n):
    index = i
    swap_time = -1

    while index not in used_indices:
        used_indices.add(index)
        index = e[index]
        swap_time += 1

    if swap_time > 0:
        swap_times.append(swap_time)

total_swap_time = sum(swap_times)

if (k - total_swap_time) % 2 == 0 and k > total_swap_time:
    print('YES')
else:
    print('NO')
0