結果
| 問題 |
No.323 yuki国
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-08 20:11:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 859 bytes |
| コンパイル時間 | 364 ms |
| コンパイル使用メモリ | 82,492 KB |
| 実行使用メモリ | 316,968 KB |
| 最終ジャッジ日時 | 2024-12-31 11:37:19 |
| 合計ジャッジ時間 | 95,607 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 18 TLE * 14 |
ソースコード
from collections import deque
def bfs():
q = deque([(Si, Sj, A)])
visited = [[[False]*(5000) 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>=5000:
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')