結果

問題 No.482 あなたの名は
ユーザー hedwig100hedwig100
提出日時 2020-07-04 16:44:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 11,732 KB
実行使用メモリ 31,800 KB
最終ジャッジ日時 2023-10-19 08:12:47
合計ジャッジ時間 4,368 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,056 KB
testcase_01 AC 30 ms
10,056 KB
testcase_02 AC 30 ms
10,056 KB
testcase_03 AC 30 ms
10,056 KB
testcase_04 AC 30 ms
10,056 KB
testcase_05 AC 30 ms
10,056 KB
testcase_06 AC 31 ms
10,056 KB
testcase_07 AC 30 ms
10,152 KB
testcase_08 AC 30 ms
10,100 KB
testcase_09 AC 30 ms
10,060 KB
testcase_10 AC 30 ms
10,096 KB
testcase_11 AC 29 ms
10,132 KB
testcase_12 AC 30 ms
10,152 KB
testcase_13 AC 30 ms
10,096 KB
testcase_14 AC 30 ms
10,092 KB
testcase_15 AC 155 ms
31,800 KB
testcase_16 AC 158 ms
31,800 KB
testcase_17 AC 161 ms
31,800 KB
testcase_18 AC 161 ms
31,800 KB
testcase_19 AC 158 ms
31,800 KB
testcase_20 AC 158 ms
31,800 KB
testcase_21 AC 158 ms
31,800 KB
testcase_22 AC 161 ms
31,800 KB
testcase_23 AC 159 ms
31,800 KB
testcase_24 AC 159 ms
31,800 KB
testcase_25 AC 158 ms
31,800 KB
testcase_26 AC 158 ms
31,800 KB
testcase_27 AC 157 ms
31,800 KB
testcase_28 AC 160 ms
31,800 KB
testcase_29 AC 129 ms
31,800 KB
testcase_30 AC 30 ms
10,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    N,K = map(int,input().split())
    D = list(map(int,input().split()))
    D = [d - 1 for d in D]
    idx = [-1] * N
    for i,d in enumerate(D):
        idx[d] = i
    
    min_cnt = 0
    for i in range(N):
        if idx[i] == i:
            continue
        idx[D[i]] = idx[i]
        D[idx[i]] = D[i]
        D[i] = i
        idx[i] = i
        min_cnt += 1
    print('YES' if (K - min_cnt)%2 == 0 and K - min_cnt >= 0 else 'NO')
if __name__ == '__main__':
    main()
0