結果
問題 |
No.1638 Robot Maze
|
ユーザー |
👑 ![]() |
提出日時 | 2021-08-06 21:35:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 812 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 77,136 KB |
最終ジャッジ日時 | 2024-09-17 01:26:33 |
合計ジャッジ時間 | 6,079 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 WA * 3 |
ソースコード
from heapq import heapify,heappop,heappush H,W=map(int,input().split()) U,D,R,L,K,P=map(int,input().split()) xs,ys,xt,yt=map(int,input().split()) C=["*"*(W+2)] for _ in range(H): C.append("*"+input()+"*") C.append("*"*(W+2)) inf=10**15 DP=[[inf]*(W+2) for _ in range(H+2)]; DP[xs][ys]=0 Q=[(0,(xs,ys))] V=[((1,0),U),((-1,0),D),((0,1),R),((0,-1),L)] while Q: d,(x,y)=heappop(Q) if DP[x][y]>d: continue if x==xt and y==yt: break for (a,b),c in V: if 1<=x+a<=H and 1<=y+b<=W and C[x+a][y+b]!="#": if C[x+a][y+b]==".": m=d+c else: m=d+c+P else: continue if DP[x+a][y+b]>m: DP[x+a][y+b]=m heappush(Q,(m,(x+a,y+b))) print("Yes" if DP[xt][yt]<=K else "No")