結果
| 問題 | No.1638 Robot Maze |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-22 19:18:10 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,881 bytes |
| 記録 | |
| コンパイル時間 | 90 ms |
| コンパイル使用メモリ | 64,604 KB |
| 実行使用メモリ | 63,668 KB |
| 最終ジャッジ日時 | 2026-10-22 19:18:17 |
| 合計ジャッジ時間 | 7,072 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 WA * 9 |
ソースコード
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())
C = ["#"+input().strip() for _ in range(H)]
C = ["#"*(W+1)]+C
INFTY = 10**7
dist = [[INFTY for _ in range(W+1)] for _ in range(H+1)]
visited = [[False for _ in range(W+1)] for _ in range(H+1)]
dist[xs][ys] = 0
heap = [(0,xs,ys)]
while heap:
d,i,j = heapq.heappop(heap)
if dist[i][j]<d:continue
visited[i][j] = True
if 1<=i-1<=H and C[i-1][j]=="." and visited[i-1][j]==False:
if dist[i-1][j]>d+U:
dist[i-1][j] = d+U
heapq.heappush(heap,(d+U,i-1,j))
elif 1<=i-1<=H and C[i-1][j]=="@" and visited[i-1][j]==False:
if dist[i-1][j]>d+U+P:
dist[i-1][j] = d+U+P
heapq.heappush(heap,(d+U,i-1,j))
if 1<=i+1<=H and C[i+1][j]=="." and visited[i+1][j]==False:
if dist[i+1][j]>d+D:
dist[i+1][j] = d+D
heapq.heappush(heap,(d+D,i+1,j))
elif 1<=i+1<=H and C[i+1][j]=="@" and visited[i+1][j]==False:
if dist[i+1][j]>d+D+P:
dist[i+1][j] = d+D+P
heapq.heappush(heap,(d+D+P,i+1,j))
if 1<=j-1<=W and C[i][j-1]=="." and visited[i][j-1]==False:
if dist[i][j-1]>d+L:
dist[i][j-1]=d+L
heapq.heappush(heap,(d+L,i,j-1))
elif 1<=j-1<=W and C[i][j-1]=="@" and visited[i][j-1]==False:
if dist[i][j-1]>d+L+P:
dist[i][j-1]=d+L+P
heapq.heappush(heap,(d+L+P,i,j-1))
if 1<=j+1<=W and C[i][j+1]=="." and visited[i][j+1]==False:
if dist[i][j+1]>d+R:
dist[i][j+1]=d+R
heapq.heappush(heap,(d+R,i,j+1))
elif 1<=j+1<=W and C[i][j+1]=="@" and visited[i][j+1]==False:
if dist[i][j+1]>d+R+P:
dist[i][j+1]=d+R+P
heapq.heappush(heap,(d+R+P,i,j+1))
if dist[xt][yt]<=K:
print("Yes")
else:
print("No")