結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-06 23:42:11 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 118 ms / 2,000 ms |
| コード長 | 709 bytes |
| コンパイル時間 | 144 ms |
| コンパイル使用メモリ | 82,832 KB |
| 実行使用メモリ | 77,264 KB |
| 最終ジャッジ日時 | 2024-09-17 04:17:42 |
| 合計ジャッジ時間 | 5,013 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
from collections import deque
h,w = map(int,input().split())
u,d,r,l,k,p = map(int,input().split())
sx,sy,gx,gy = [int(x)-1 for x in input().split()]
need = [u,d,r,l]
dx = [-1,1,0,0]
dy = [0,0,1,-1]
C = [input() for i in range(h)]
inf = 10**20
cost = [[10**20]*w for i in range(h)]
cost[sx][sy] = 0
q = deque([[sx,sy]])
while q:
x,y = q.popleft()
for i,j,c in zip(dx,dy,need):
nx = x+i
ny = y+j
if 0 <= nx < h and 0 <= ny < w and C[nx][ny] != "#":
base = cost[x][y]+c+p*(C[nx][ny]=="@")
if base < cost[nx][ny]:
cost[nx][ny] = base
q.append([nx,ny])
ans = cost[gx][gy]
if ans <= k:
print("Yes")
else:
print("No")