結果
| 問題 | No.1638 Robot Maze |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-06 23:42:11 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 90 ms / 2,000 ms |
| コード長 | 709 bytes |
| 記録 | |
| コンパイル時間 | 709 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 81,792 KB |
| 最終ジャッジ日時 | 2026-04-06 02:39:54 |
| 合計ジャッジ時間 | 4,324 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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")