結果

問題 No.482 あなたの名は
ユーザー Konton7Konton7
提出日時 2019-05-25 01:36:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 259 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 11,852 KB
実行使用メモリ 31,836 KB
最終ジャッジ日時 2023-10-17 17:39:51
合計ジャッジ時間 6,297 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,088 KB
testcase_01 AC 30 ms
10,088 KB
testcase_02 AC 29 ms
10,088 KB
testcase_03 AC 29 ms
10,088 KB
testcase_04 AC 29 ms
10,088 KB
testcase_05 AC 29 ms
10,088 KB
testcase_06 AC 29 ms
10,088 KB
testcase_07 AC 29 ms
10,184 KB
testcase_08 AC 29 ms
10,132 KB
testcase_09 AC 29 ms
10,092 KB
testcase_10 AC 29 ms
10,128 KB
testcase_11 AC 29 ms
10,152 KB
testcase_12 AC 29 ms
10,168 KB
testcase_13 AC 29 ms
10,128 KB
testcase_14 AC 29 ms
10,116 KB
testcase_15 AC 191 ms
31,836 KB
testcase_16 AC 195 ms
31,836 KB
testcase_17 AC 192 ms
31,836 KB
testcase_18 AC 192 ms
31,836 KB
testcase_19 AC 191 ms
31,836 KB
testcase_20 AC 195 ms
31,836 KB
testcase_21 AC 195 ms
31,836 KB
testcase_22 AC 194 ms
31,836 KB
testcase_23 AC 190 ms
31,836 KB
testcase_24 AC 191 ms
31,836 KB
testcase_25 AC 192 ms
31,836 KB
testcase_26 AC 196 ms
31,836 KB
testcase_27 AC 196 ms
31,836 KB
testcase_28 AC 199 ms
31,836 KB
testcase_29 AC 259 ms
31,836 KB
testcase_30 AC 29 ms
10,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = [ int(v) for v in input().split() ]

number_list = [ (int(v)-1) for v in input().split() ]
change_list= []


for i in range(n):
	if number_list[i] == i:
		 number_list[i] = -1
	elif number_list[i] == -1:
		 pass
	else:
		temp_list = [number_list[i]]
		
		next_i = number_list[i]
		number_list[i] = -1
		while next_i not in [i,-1] :
			temp_list.append(number_list[next_i])
			now_i = next_i
			next_i = number_list[next_i]
			number_list[now_i] = -1
		change_list.append(temp_list)


change_list = [len(change_list[i])-1 for i in range(len(change_list))]


if k >= sum(change_list) and (k - sum(change_list)) % 2 == 0:
	print("YES")
else:
	print("NO")
0