結果

問題 No.1588 Connection
ユーザー 👑 tatt61880tatt61880
提出日時 2021-07-08 23:21:10
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,094 bytes
コンパイル時間 2,396 ms
使用メモリ 22,608 KB
平均クエリ数 367.41
最終ジャッジ日時 2023-03-01 14:15:45
合計ジャッジ時間 6,581 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 23 ms
22,552 KB
testcase_01 AC 22 ms
22,576 KB
testcase_02 AC 26 ms
22,576 KB
testcase_03 AC 27 ms
21,880 KB
testcase_04 AC 27 ms
21,892 KB
testcase_05 AC 27 ms
21,796 KB
testcase_06 AC 29 ms
21,916 KB
testcase_07 AC 27 ms
22,192 KB
testcase_08 AC 31 ms
21,880 KB
testcase_09 AC 23 ms
21,868 KB
testcase_10 AC 24 ms
21,880 KB
testcase_11 AC 23 ms
21,892 KB
testcase_12 AC 25 ms
21,880 KB
testcase_13 AC 27 ms
22,420 KB
testcase_14 AC 27 ms
22,552 KB
testcase_15 AC 29 ms
22,600 KB
testcase_16 AC 27 ms
22,252 KB
testcase_17 AC 29 ms
22,252 KB
testcase_18 AC 27 ms
22,204 KB
testcase_19 AC 28 ms
22,228 KB
testcase_20 AC 30 ms
21,928 KB
testcase_21 AC 83 ms
22,252 KB
testcase_22 AC 82 ms
22,492 KB
testcase_23 AC 47 ms
21,868 KB
testcase_24 AC 36 ms
22,608 KB
testcase_25 AC 76 ms
22,264 KB
testcase_26 AC 72 ms
22,552 KB
testcase_27 AC 47 ms
22,608 KB
testcase_28 AC 42 ms
21,756 KB
testcase_29 AC 80 ms
21,892 KB
testcase_30 AC 78 ms
22,264 KB
testcase_31 AC 24 ms
21,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var m: int :: cui@inputInt() - 2
	var stage: [][]char :: #[n, n]char
	for i(0, n - 1)
		do stage[i] :: ['?'].repeat(n)
	end for
	do stage[0][0] :: 'B'
	do stage[n - 1][n - 1] :: 'B'
	var x: int :: 0
	var y: int :: 0
	var dir: int :: 3
	var dx: []int :: [1, 0, -1, 0]
	var dy: []int :: [0, 1, 0, -1]
	var cnt: int :: 0
	while loop(true)
		do cnt :+ 1
		if(cnt = 1000000)
			do cui@print("No\n")
			ret
		end if
		var nx: int :: x + dx[dir]
		var ny: int :: y + dy[dir]
		if(nx < 0 | n <= nx | ny < 0 | n <= ny)
			do dir :: (dir + 1) % 4
			skip loop
		end if
		switch(stage[ny][nx])
		case '?'
			do cui@print("\{nx + 1} \{ny + 1}\n")
			do cui@flush()
			var c: char :: cui@input()[0]
			if(c = '-')
				ret
			end if
			do stage[ny][nx] :: c
			if(c = 'B')
				do m :- 1
				if(nx + ny = 2 * n - 3)
					do cui@print("Yes\n")
					ret
				end if
			end if
			if(m = 0)
				do cui@print("No\n")
				ret
			end if
		case 'W'
			do dir :: (dir + 1) % 4
		case 'B'
			do x :: nx
			do y :: ny
			do dir :: (dir + 3) % 4
		end switch
	end while
end func
0