結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 17 ms
7,952 KB
testcase_03 AC 17 ms
7,904 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,836 KB
testcase_06 WA -
testcase_07 AC 18 ms
8,432 KB
testcase_08 AC 17 ms
7,900 KB
testcase_09 AC 16 ms
7,812 KB
testcase_10 AC 18 ms
7,792 KB
testcase_11 WA -
testcase_12 AC 18 ms
8,308 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 272 ms
42,340 KB
testcase_17 AC 270 ms
42,204 KB
testcase_18 AC 275 ms
42,220 KB
testcase_19 WA -
testcase_20 AC 272 ms
42,264 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 280 ms
42,180 KB
testcase_27 AC 280 ms
42,228 KB
testcase_28 WA -
testcase_29 AC 250 ms
42,232 KB
testcase_30 AC 17 ms
7,792 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, dd in enumerate(d):
    e[dd] = i

used_indices = set()
hoge = list()

for i in range(n):
    x = i
    y = 0

    if x not in used_indices:
        used_indices.add(x)
        x = e[x]
        y += 1
    if y > 0:
        hoge.append(y)

x = sum(a - 1 for a in hoge)

if x % 2 == k % 2 and x <= k:
    print('YES')
else:
    print('NO')
0