結果

問題 No.1638 Robot Maze
コンテスト
ユーザー convexineq
提出日時 2021-08-06 22:48:47
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 740 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 321 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 82,024 KB
最終ジャッジ日時 2026-04-06 02:10:11
合計ジャッジ時間 4,726 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 47 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

h,w = map(int,input().split())
u,d,r,l,k,p = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
b = [input() for _ in range(h)]
sx -= 1
sy -= 1
gx -= 1
gy -= 1
C = [r,d,l,u]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
INF = 10**18
dist = [[INF]*w for _ in range(h)]
from heapq import *
q = [(0,sx,sy)]
while q:
    dv,x,y = heappop(q)
    if dist[x][y] < dv: continue
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if nx < 0 or nx >= h or ny < 0 or ny >= w or b[nx][ny] == "#": continue
        cost = dv + C[i]
        if b[nx][ny] == "@":
            cost += p
        if cost < dist[nx][ny]:
            heappush(q, (cost,nx,ny))
            dist[nx][ny] = cost
print("Yes" if dist[gx][gy] <= k else "No")
0