結果

問題 No.323 yuki国
ユーザー yn
提出日時 2016-06-11 16:53:05
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 987 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 82,212 KB
実行使用メモリ 252,952 KB
最終ジャッジ日時 2024-10-09 12:54:58
合計ジャッジ時間 33,311 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 29 TLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
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)]

visited = [[[False] * 1200 for i in range(w)] for j in range(h)]

q = []
visited[si][sj][a] = True
heapq.heappush(q, (si, sj, a))

dx = [0, 1, 0,-1]
dy = [1, 0,-1, 0]

while len(q):
    curi, curj, cursize = heapq.heappop(q)

    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 < 1200:
            pass
        else:
            continue

        if not visited[nexti][nextj][nextsize]:
            visited[nexti][nextj][nextsize] = True
            heapq.heappush(q,(nexti, nextj, nextsize))


if visited[gi][gj][b]:
    print("Yes")
else:
    print("No")
0