結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-07-20 00:04:50 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 597 bytes |
| コンパイル時間 | 432 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 41,872 KB |
| 最終ジャッジ日時 | 2024-07-17 13:37:39 |
| 合計ジャッジ時間 | 6,653 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 1 |
| other | TLE * 1 -- * 30 |
コンパイルメッセージ
Syntax OK
ソースコード
N, M = gets.split.map(&:to_i)
def query(a, b)
STDOUT.puts("%d %d" % [a, b])
gets.chomp
end
G = Array.new(N) { Array.new(N, 0) }
visited = Array.new(N) { Array.new(N, false) }
DY = [-1, 0, 1, 0]
DX = [0, 1, 0, -1]
def dfs(y, x, visited)
visited[y][x] = true
if y == N - 1 && x == N - 1
puts 'Yes'
exit
end
4.times do |i|
ny = y + DY[i]
nx = x + DX[i]
next if ny < 0 || nx < 0 || N <= ny || N <= nx
next if visited[ny][nx]
res = query(ny + 1, nx + 1)
if res == 'Black'
dfs(ny, nx, visited)
end
end
end
dfs(0, 0, visited)
puts 'No'
siman