結果
| 問題 | No.323 yuki国 |
| コンテスト | |
| ユーザー |
yn
|
| 提出日時 | 2016-06-11 17:40:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 4,901 ms / 5,000 ms |
| コード長 | 1,188 bytes |
| 記録 | |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 82,140 KB |
| 実行使用メモリ | 150,728 KB |
| 最終ジャッジ日時 | 2024-10-09 12:58:24 |
| 合計ジャッジ時間 | 64,255 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 32 |
ソースコード
import queue
h, w = map(int,input().split())
a, si, sj = map(int,input().split())
b, gi, gj = map(int,input().split())
m = [list(input()) for i in range(h)]
maxsize = 1200
visited = [[[False] * maxsize for i in range(w)] for j in range(h)]
qi = queue.Queue(h*w*maxsize)
qj = queue.Queue(h*w*maxsize)
qsize = queue.Queue(h*w*maxsize)
visited[si][sj][a] = True
qi.put(si)
qj.put(sj)
qsize.put(a)
dx = [0, 1, 0,-1]
dy = [1, 0,-1, 0]
while not qsize.empty():
curi = qi.get()
curj = qj.get()
cursize = qsize.get()
#print(cursize,curi, curj)
for i in range(4):
nexti = curi + dx[i]
nextj = curj + dy[i]
if 0 <= nexti < h and 0 <= nextj < w:
pass
else:
continue
if m[nexti][nextj] == "*":
nextsize = cursize + 1
else:
nextsize = cursize - 1
if 0 < nextsize < maxsize:
pass
else:
continue
if not visited[nexti][nextj][nextsize]:
visited[nexti][nextj][nextsize] = True
qi.put(nexti)
qj.put(nextj)
qsize.put(nextsize)
if visited[gi][gj][b]:
print("Yes")
else:
print("No")
yn