結果

問題 No.482 あなたの名は
ユーザー Daisuke MiyakawaDaisuke Miyakawa
提出日時 2022-03-22 21:16:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,412 KB
実行使用メモリ 140,152 KB
最終ジャッジ日時 2024-04-18 22:04:38
合計ジャッジ時間 5,686 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
66,944 KB
testcase_01 AC 59 ms
66,560 KB
testcase_02 AC 56 ms
66,944 KB
testcase_03 AC 59 ms
66,560 KB
testcase_04 AC 60 ms
66,560 KB
testcase_05 AC 60 ms
66,560 KB
testcase_06 AC 57 ms
66,560 KB
testcase_07 AC 61 ms
67,968 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 56 ms
67,712 KB
testcase_13 AC 58 ms
67,452 KB
testcase_14 AC 60 ms
67,456 KB
testcase_15 AC 160 ms
140,020 KB
testcase_16 AC 162 ms
139,884 KB
testcase_17 AC 163 ms
139,896 KB
testcase_18 AC 161 ms
139,636 KB
testcase_19 AC 166 ms
139,724 KB
testcase_20 AC 170 ms
139,828 KB
testcase_21 AC 162 ms
139,624 KB
testcase_22 AC 162 ms
139,956 KB
testcase_23 AC 173 ms
139,960 KB
testcase_24 AC 167 ms
139,724 KB
testcase_25 AC 158 ms
139,888 KB
testcase_26 AC 164 ms
139,844 KB
testcase_27 AC 162 ms
139,644 KB
testcase_28 AC 167 ms
140,152 KB
testcase_29 AC 148 ms
139,764 KB
testcase_30 AC 61 ms
66,944 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