結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,876 KB
testcase_01 AC 17 ms
7,968 KB
testcase_02 AC 17 ms
7,776 KB
testcase_03 AC 17 ms
7,852 KB
testcase_04 AC 16 ms
7,780 KB
testcase_05 AC 17 ms
7,968 KB
testcase_06 AC 19 ms
7,812 KB
testcase_07 AC 18 ms
8,296 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 18 ms
7,896 KB
testcase_11 AC 17 ms
8,248 KB
testcase_12 AC 18 ms
8,284 KB
testcase_13 AC 18 ms
7,968 KB
testcase_14 AC 17 ms
7,812 KB
testcase_15 AC 287 ms
40,196 KB
testcase_16 AC 289 ms
40,096 KB
testcase_17 AC 278 ms
40,020 KB
testcase_18 AC 286 ms
40,112 KB
testcase_19 AC 284 ms
40,008 KB
testcase_20 AC 289 ms
40,104 KB
testcase_21 AC 292 ms
40,024 KB
testcase_22 AC 285 ms
40,152 KB
testcase_23 AC 283 ms
40,204 KB
testcase_24 AC 281 ms
40,108 KB
testcase_25 AC 289 ms
40,132 KB
testcase_26 AC 280 ms
40,140 KB
testcase_27 AC 287 ms
40,020 KB
testcase_28 AC 291 ms
40,036 KB
testcase_29 AC 259 ms
39,228 KB
testcase_30 AC 16 ms
7,912 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:
    print('YES')
else:
    print('NO')
0