結果

問題 No.482 あなたの名は
ユーザー 👑 tatt61880tatt61880
提出日時 2020-04-17 00:26:38
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 2,449 ms
コンパイル使用メモリ 155,280 KB
実行使用メモリ 34,364 KB
最終ジャッジ日時 2023-10-14 16:09:35
合計ジャッジ時間 5,662 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,356 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 129 ms
34,292 KB
testcase_16 AC 128 ms
34,104 KB
testcase_17 AC 128 ms
34,160 KB
testcase_18 AC 129 ms
34,228 KB
testcase_19 AC 127 ms
34,236 KB
testcase_20 AC 129 ms
34,364 KB
testcase_21 AC 127 ms
34,256 KB
testcase_22 AC 129 ms
34,112 KB
testcase_23 AC 127 ms
34,164 KB
testcase_24 AC 129 ms
34,100 KB
testcase_25 AC 130 ms
34,268 KB
testcase_26 AC 130 ms
34,272 KB
testcase_27 AC 129 ms
34,164 KB
testcase_28 AC 129 ms
34,124 KB
testcase_29 AC 125 ms
34,248 KB
testcase_30 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var ss: [][]char :: cui@input().split(" ")
	var n: int :: ss[0].toInt(&)
	var k: int :: ss[1].toInt(&)
	
	do ss :: cui@input().split(" ")
	var a: []int :: #[n]int
	for i(0, n - 1)
		do a[i] :: ss[i].toInt(&) - 1
	end for
	
	var cnt: int :: 0
	for i(0, n - 1)
		if(a[i] <> i)
			var p: int :: a[i]
			while(p <> i)
				do cnt :+ 1
				var tmp: int :: a[p]
				do a[p] :: p
				do p :: tmp
			end while
		end if
	end for
	var ans: bool :: cnt <= k & cnt % 2 = k % 2
	do cui@print(ans ?("YES\n", "NO\n"))
end func
0