結果

問題 No.482 あなたの名は
ユーザー kichirb3kichirb3
提出日時 2018-03-28 19:26:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 860 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 39,380 KB
最終ジャッジ日時 2023-09-07 19:28:22
合計ジャッジ時間 4,304 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,856 KB
testcase_01 AC 16 ms
7,792 KB
testcase_02 AC 16 ms
7,812 KB
testcase_03 AC 15 ms
7,904 KB
testcase_04 AC 16 ms
7,800 KB
testcase_05 WA -
testcase_06 AC 16 ms
7,832 KB
testcase_07 AC 16 ms
8,264 KB
testcase_08 AC 16 ms
7,868 KB
testcase_09 AC 16 ms
7,780 KB
testcase_10 AC 16 ms
7,828 KB
testcase_11 AC 16 ms
8,232 KB
testcase_12 AC 17 ms
8,252 KB
testcase_13 AC 16 ms
7,808 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 161 ms
39,192 KB
testcase_17 AC 161 ms
39,232 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 161 ms
39,140 KB
testcase_25 AC 159 ms
39,292 KB
testcase_26 WA -
testcase_27 AC 158 ms
39,272 KB
testcase_28 AC 159 ms
39,148 KB
testcase_29 AC 128 ms
39,144 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.482 あなたの名は
https://yukicoder.me/problems/no/482

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, K, D):
    num2pos = dict()            # 数字がリストのどこにあるか検索するための辞書
    D.insert(0, 0)
    for i, d in enumerate(D):
        num2pos[d] = i

    for i in range(1, N+1):
        if D[i] != i:
            K -= 1              # 能力を1回使って魂を入れ替え
            t = num2pos[i]
            num2pos[t] = D[i]
            D[t] = D[i]
            # D[i] = i
            # num2pos[i] = i

    if K < 0 or K % 2 != 0:
        return 'NO'
    return 'YES'


def main(args):
    N, K = map(int, input().split())
    D = [int(x) for x in input().split()]
    ans = solve(N, K, D)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
0