結果
| 問題 |
No.424 立体迷路
|
| コンテスト | |
| ユーザー |
tokizo
|
| 提出日時 | 2019-02-01 18:14:40 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,125 bytes |
| コンパイル時間 | 242 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 195,584 KB |
| 最終ジャッジ日時 | 2024-11-23 15:10:58 |
| 合計ジャッジ時間 | 8,354 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 15 WA * 4 TLE * 2 |
ソースコード
import pprint
from collections import deque
def main():
h, w = map(int, input().split())
sx, sy, gx, gy = map(int, input().split())
sx -= 1
sy -= 1
gx -= 1
gy -= 1
B = []
for i in range(h):
B.append(list(map(int, list(input()))))
seen = [[False for _ in range(w)] for _ in range(h)]
dx = [-1, 1, 0, 0, -2, 2, 0, 0]
dy = [0, 0, -1, 1, 0, 0, -2, 2]
q = deque()
q.append((sx, sy))
while q:
x, y = q.popleft()
seen[x][y] = True
for i in range(8):
nx = x + dx[i]
ny = y + dy[i]
if nx < 0 or nx >= h or ny < 0 or ny >= w:
continue
if seen[nx][ny]:
continue
if i < 4:
if abs(B[x][y] - B[nx][ny]) > 1:
continue
else:
if B[x][y] != B[nx][ny]:
continue
if nx == gx and ny == gy:
#pprint.pprint(seen)
print("YES")
exit()
q.append((nx, ny))
print("NO")
if __name__ == "__main__":
main()
tokizo