結果
| 問題 | No.1638 Robot Maze |
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2021-08-06 21:34:27 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 52 ms / 2,000 ms |
| + 16µs | |
| コード長 | 790 bytes |
| 記録 | |
| コンパイル時間 | 389 ms |
| コンパイル使用メモリ | 15,104 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2026-10-14 22:28:48 |
| 合計ジャッジ時間 | 4,214 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
import sys
input = sys.stdin.readline
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())
MAP=[input().strip() for i in range(H)]
DP=[[1<<60]*W for i in range(H)]
xs-=1
xt-=1
ys-=1
yt-=1
Q=[(0,xs,ys)]
while Q:
cost,x,y=heapq.heappop(Q)
if cost>DP[x][y]:
continue
for z,w,cp in [(x+1,y,D),(x-1,y,U),(x,y+1,R),(x,y-1,L)]:
if 0<=z<H and 0<=w<W:
if MAP[z][w]=="." and DP[z][w]>cost+cp:
DP[z][w]=cost+cp
heapq.heappush(Q,(cost+cp,z,w))
elif MAP[z][w]=="@" and DP[z][w]>cost+cp+P:
DP[z][w]=cost+cp+P
heapq.heappush(Q,(cost+cp+P,z,w))
if DP[xt][yt]<=K:
print("Yes")
else:
print("No")
titia