結果

問題 No.482 あなたの名は
ユーザー 6soukiti29
提出日時 2017-03-21 00:43:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 371 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 36,380 KB
最終ジャッジ日時 2024-07-05 04:42:17
合計ジャッジ時間 4,436 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
L = list(map(int,input().split()))
def min_gokan(A):
	B = [[]]
	i = 0
	A2 = A[:]
	while A2:
		a = A2[0]
		while a not in B[i]:
			B[i].append(a)
			A2.remove(a)
			a = A[a - 1]
		i = i + 1
		B.append([])
	B.pop()
	r = len(A) - len(B)
	return r
m = min_gokan(L)
if m > K:
	print("NO")
elif (K - m) % 2 == 0:
	print("YES")
else:
	print("NO")
0