結果

問題 No.228 ゆきこちゃんの 15 パズル
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-21 19:55:54
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,068 bytes
コンパイル時間 2,335 ms
コンパイル使用メモリ 151,816 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-14 17:22:09
合計ジャッジ時間 3,572 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,356 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	; target
	var a: [][]int :: #[4, 4]int
	for i(0, 3)
		for j(0, 3)
			do a[i][j] :: cui@inputInt()
		end for
	end for
	
	; current
	var b: [][]int :: #[4, 4]int
	for i(0, 3)
		for j(0, 3)
			do b[i][j] :: (1 + i * 4 + j) % 16
		end for
	end for
	
	while(true)
		if(isEqual(a, b))
			do cui@print("Yes\n")
			ret
		end if
		var flag: bool :: false
		for i(0, 3)
			for j(0, 3)
				if(b[i][j] = 0)
					var dx: []int :: [0, 1, 0, -1]
					var dy: []int :: [1, 0, -1, 0]
					for k(0, 3)
						var x: int :: j + dx[k]
						var y: int :: i + dy[k]
						if(0 <= x & x <= 3 & 0 <= y & y <= 3)
							if(b[y][x] = a[i][j])
								do b[i][j] :: b[y][x]
								do b[y][x] :: 0
								do flag :: true
								break i
							end if
						end if
					end for
				end if
			end for
		end for
		if(!flag)
			do cui@print("No\n")
			ret
		end if
		
		func isEqual(a: [][]int, b: [][]int): bool
			for i(0, 3)
				for j(0, 3)
					if(a[i][j] <> b[i][j])
						ret false
					end if
				end for
			end for
			ret true
		end func
	end while
	var ans: int :: 0
end func
0