結果
問題 | No.1638 Robot Maze |
ユーザー |
|
提出日時 | 2022-01-20 15:00:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 861 bytes |
コンパイル時間 | 104 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-11-23 19:30:10 |
合計ジャッジ時間 | 4,850 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
import heapqh,w=map(int,input().split())u,d,r,l,k,p=map(int,input().split())sy,sx,gy,gx=map(int,input().split())sy-=1;sx-=1;gy-=1;gx-=1g=[input() for _ in range(h)]inf=float('inf')dst=[[inf]*w for _ in range(h)]confirmed=[[False]*w for _ in range(h)]q=[]heapq.heappush(q,(0,sy,sx))while q:cost,y,x=heapq.heappop(q)if confirmed[y][x]:continueconfirmed[y][x]=Truedst[y][x]=costdy=[-1,1,0,0]dx=[0,0,1,-1]move_cost=[u,d,r,l]for i in range(4):ny=y+dy[i]nx=x+dx[i]if not(0<=ny<h and 0<=nx<w):continueif confirmed[ny][nx]:continueif g[ny][nx]=='#':continueto_cost=cost+move_cost[i]if g[ny][nx]=='@':to_cost+=pheapq.heappush(q,(to_cost,ny,nx))print('Yes' if dst[gy][gx]<=k else 'No')