結果

問題 No.1638 Robot Maze
ユーザー SidewaysOwl
提出日時 2021-08-07 08:05:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 77,912 KB
最終ジャッジ日時 2024-09-17 11:51:03
合計ジャッジ時間 6,879 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
h,w = map(int,input().split())
u,d,r,l,k,p = map(int,input().split())
xs,ys,xt,yt = map(int,input().split())
c = [list(input()) for _ in range(h)]
q = ([(0,xs-1,ys-1)])
vecs = [(1,0,d),(-1,0,u),(0,1,r),(0,-1,l)]
vis = [[10 ** 15] * w for _ in range(h)]
while q:
    cost,x,y = heapq.heappop(q)
    if cost < vis[x][y]:
        vis[x][y] =  cost
        for vx,vy,vc in vecs:
            nx,ny = x + vx,y + vy
            if nx >= 0 and nx <= h-1 and ny >= 0 and ny <= w-1:
                if c[nx][ny] != "#":
                    if c[nx][ny] == "@":
                        vc += p
                    heapq.heappush(q,(cost+vc,nx,ny))
if vis[xt-1][yt-1] <= k:
    print("Yes")
else:
    print("No")
0