結果
| 問題 |
No.424 立体迷路
|
| コンテスト | |
| ユーザー |
t8m8⛄️
|
| 提出日時 | 2016-09-24 12:12:35 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,073 bytes |
| コンパイル時間 | 831 ms |
| コンパイル使用メモリ | 66,016 KB |
| 最終ジャッジ日時 | 2024-11-14 19:51:56 |
| 合計ジャッジ時間 | 1,179 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 28) Error: cannot open file: queues
ソースコード
import strutils, sequtils, queues
var
tmp = stdin.readline.split.map(parseint)
(h, w) = (tmp[0], tmp[1])
tmp2 = stdin.readline.split.map(parseint)
(sy, sx, gy, gx) = (tmp2[0]-1, tmp2[1]-1, tmp2[2]-1, tmp2[3]-1)
b : seq[string] = @[]
for i in 1..h:
b.add(stdin.readline)
const
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
var
q = initQueue[int]()
visited : seq[bool] = newSeqWith(h*w, false)
q.add(sy*w+sx)
while q.len > 0:
var
t = q.dequeue
(cy, cx) = (t div w, t mod w)
if cy == gy and cx == gx:
"YES".echo
quit()
for k in 0..3:
var (ny, nx) = (cy + dy[k], cx + dx[k])
if ny < 0 or nx < 0 or h <= ny or w <= nx: continue
if not visited[ny*w+nx] and abs(b[ny][nx].int - b[cy][cx].int) <= 1:
visited[ny*w+nx] = true
q.add(ny*w+nx)
for k in 0..3:
var (ny, nx) = (cy + 2*dy[k], cx + 2*dx[k])
if ny < 0 or nx < 0 or h <= ny or w <= nx: continue
if not visited[ny*w+nx] and b[ny][nx] == b[cy][cx] and b[ny][nx] > b[cy+dy[k]][cx+dx[k]]:
visited[ny*w+nx] = true
q.add(ny*w+nx)
"NO".echo
t8m8⛄️