結果
| 問題 | No.323 yuki国 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-08 20:14:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 4,928 ms / 5,000 ms |
| コード長 | 857 bytes |
| コンパイル時間 | 378 ms |
| コンパイル使用メモリ | 82,368 KB |
| 実行使用メモリ | 218,224 KB |
| 最終ジャッジ日時 | 2024-12-31 11:45:37 |
| 合計ジャッジ時間 | 72,915 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 32 |
ソースコード
from collections import deque
def bfs():
q = deque([(Si, Sj, A)])
visited = [[[False]*4000 for _ in range(W)] for _ in range(H)]
visited[Si][Sj][A] = True
while q:
cx, cy, s = q.popleft()
for nx, ny in [(cx-1, cy), (cx+1, cy), (cx, cy-1), (cx, cy+1)]:
if not (0<=nx<H and 0<=ny<W):
continue
ns = s+(1 if M[nx][ny]=='*' else -1)
if ns==0 or ns>=4000:
continue
if not visited[nx][ny][ns]:
visited[nx][ny][ns] = True
q.append((nx, ny, ns))
return visited[Gi][Gj][B]
H, W = map(int, input().split())
A, Si, Sj = map(int, input().split())
B, Gi, Gj = map(int, input().split())
M = [input() for _ in range(H)]
if bfs():
print('Yes')
else:
print('No')