結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
sasa8uyauya
|
| 提出日時 | 2024-06-30 18:37:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 111 ms / 2,000 ms |
| コード長 | 624 bytes |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 76,892 KB |
| 最終ジャッジ日時 | 2024-06-30 18:37:38 |
| 合計ジャッジ時間 | 4,710 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
h,w=map(int,input().split())
U,D,R,L,k,p=map(int,input().split())
c=[U,D,R,L]
d=[(-1,0),(1,0),(0,1),(0,-1)]
Sx,Sy,Gx,Gy=map(int,input().split())
Sx-=1
Sy-=1
Gx-=1
Gy-=1
s=[input() for i in range(h)]
v=[[k+1]*w for i in range(h)]
v[Sx][Sy]=0
q=[(v[Sx][Sy],Sx,Sy)]
from heapq import heappush,heappop
while len(q)>0:
sc,sx,sy=heappop(q)
if sc>v[sx][sy]:
continue
for i in range(4):
dx,dy=d[i]
tx,ty=sx+dx,sy+dy
if 0<=tx<h and 0<=ty<w and s[tx][ty]!="#":
tc=sc+c[i]+p*(s[tx][ty]=="@")
if v[tx][ty]>tc:
v[tx][ty]=tc
heappush(q,(v[tx][ty],tx,ty))
print(["No","Yes"][v[Gx][Gy]<=k])
sasa8uyauya