結果

問題 No.1588 Connection
ユーザー 👑 tatt61880tatt61880
提出日時 2021-07-08 23:21:10
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 1,094 bytes
コンパイル時間 2,645 ms
コンパイル使用メモリ 156,768 KB
実行使用メモリ 24,372 KB
平均クエリ数 367.41
最終ジャッジ日時 2023-10-14 18:36:51
合計ジャッジ時間 6,336 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,376 KB
testcase_01 AC 22 ms
23,448 KB
testcase_02 AC 27 ms
23,412 KB
testcase_03 AC 28 ms
24,372 KB
testcase_04 AC 27 ms
23,976 KB
testcase_05 AC 26 ms
24,288 KB
testcase_06 AC 26 ms
23,556 KB
testcase_07 AC 25 ms
23,988 KB
testcase_08 AC 27 ms
23,448 KB
testcase_09 AC 24 ms
24,300 KB
testcase_10 AC 24 ms
23,592 KB
testcase_11 AC 22 ms
23,640 KB
testcase_12 AC 24 ms
23,412 KB
testcase_13 AC 25 ms
23,664 KB
testcase_14 AC 25 ms
23,796 KB
testcase_15 AC 27 ms
23,772 KB
testcase_16 AC 26 ms
23,496 KB
testcase_17 AC 25 ms
23,208 KB
testcase_18 AC 25 ms
23,652 KB
testcase_19 AC 26 ms
23,928 KB
testcase_20 AC 27 ms
23,688 KB
testcase_21 AC 76 ms
23,772 KB
testcase_22 AC 77 ms
23,988 KB
testcase_23 AC 46 ms
23,868 KB
testcase_24 AC 33 ms
24,084 KB
testcase_25 AC 71 ms
24,324 KB
testcase_26 AC 68 ms
23,340 KB
testcase_27 AC 47 ms
23,784 KB
testcase_28 AC 43 ms
24,264 KB
testcase_29 AC 78 ms
24,300 KB
testcase_30 AC 76 ms
23,448 KB
testcase_31 AC 22 ms
23,436 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