結果

問題 No.482 あなたの名は
ユーザー compass19compass19
提出日時 2017-02-15 00:46:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 473 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 36,456 KB
最終ジャッジ日時 2023-08-28 17:05:42
合計ジャッジ時間 5,074 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 15 ms
7,888 KB
testcase_03 AC 15 ms
7,892 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 17 ms
8,344 KB
testcase_08 AC 16 ms
7,928 KB
testcase_09 AC 15 ms
7,788 KB
testcase_10 AC 16 ms
7,880 KB
testcase_11 AC 16 ms
8,292 KB
testcase_12 AC 16 ms
8,304 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 204 ms
36,388 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 205 ms
36,188 KB
testcase_20 WA -
testcase_21 AC 217 ms
36,256 KB
testcase_22 WA -
testcase_23 AC 196 ms
36,288 KB
testcase_24 WA -
testcase_25 AC 206 ms
36,344 KB
testcase_26 WA -
testcase_27 AC 204 ms
36,336 KB
testcase_28 WA -
testcase_29 AC 204 ms
36,456 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
D = ['dummy'] + list(map(int, input().split()))

# 巡回置換の検出
peo = {i: False for i in D[1:]}
ans = 0
for ix, i in enumerate(D):
    if ix == 0 or peo[i] or i == ix:
        peo[i] = True
        continue 
    key = i
    peo[i] = True
    ans += 1
    _next = D[i]
    while _next != key:
        peo[_next] = True
        ans += 1
        _next = D[_next]


if K >= ans and K%2 == ans%2:
    print('YES')
else:
    print('NO')
0