結果

問題 No.482 あなたの名は
ユーザー Daisuke MiyakawaDaisuke Miyakawa
提出日時 2022-03-22 21:23:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 45,736 KB
最終ジャッジ日時 2024-04-18 22:11:11
合計ジャッジ時間 6,622 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
11,136 KB
testcase_01 AC 35 ms
11,136 KB
testcase_02 AC 34 ms
11,136 KB
testcase_03 AC 36 ms
11,264 KB
testcase_04 AC 36 ms
11,136 KB
testcase_05 AC 32 ms
11,136 KB
testcase_06 AC 32 ms
11,264 KB
testcase_07 AC 33 ms
11,520 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 36 ms
11,392 KB
testcase_13 AC 33 ms
11,392 KB
testcase_14 AC 37 ms
11,264 KB
testcase_15 AC 296 ms
45,652 KB
testcase_16 AC 289 ms
45,736 KB
testcase_17 AC 290 ms
45,568 KB
testcase_18 AC 300 ms
45,724 KB
testcase_19 AC 302 ms
45,652 KB
testcase_20 AC 312 ms
45,612 KB
testcase_21 AC 318 ms
45,736 KB
testcase_22 AC 298 ms
45,656 KB
testcase_23 AC 292 ms
45,512 KB
testcase_24 AC 301 ms
45,652 KB
testcase_25 AC 275 ms
45,724 KB
testcase_26 AC 274 ms
45,680 KB
testcase_27 AC 284 ms
45,576 KB
testcase_28 AC 282 ms
45,640 KB
testcase_29 AC 251 ms
45,720 KB
testcase_30 AC 32 ms
11,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List

N, K = [int(e) for e in input().split()]
D: List[int] = []

remaining = set()
for i, e in enumerate(input().split()):
    remaining.add(i)
    D.append(int(e) - 1)

count = 0
while remaining:
    node_i = remaining.pop()
    linked = set()
    while True:
        linked.add(node_i)
        node_i = D[node_i]
        if node_i in linked:
            break
        remaining.remove(node_i)
        count += 1

k = K - count
print("YES" if k < 0 or k % 2 == 0 else "NO", end="")
0