結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-06 22:00:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 112 ms / 2,000 ms |
| コード長 | 887 bytes |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 81,520 KB |
| 実行使用メモリ | 76,964 KB |
| 最終ジャッジ日時 | 2024-09-17 01:58:37 |
| 合計ジャッジ時間 | 4,933 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
import sys
input = sys.stdin.readline
from heapq import *
def dijkstra():
dist = [[10**18]*W for _ in range(H)]
dist[xs-1][ys-1] = 0
pq = [(0, (xs-1)*10000+ys-1)]
while pq:
d, xy = heappop(pq)
x, y = divmod(xy, 10000)
for nx, ny, c in [(x-1, y, U), (x+1, y, D), (x, y-1, L), (x, y+1, R)]:
if 0<=nx<H and 0<=ny<W and C[nx][ny]!='#':
if C[nx][ny]=='@':
c += P
if dist[nx][ny]>dist[x][y]+c:
dist[nx][ny] = dist[x][y]+c
heappush(pq, (dist[nx][ny], nx*10000+ny))
return dist[xt-1][yt-1]<=K
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()[:-1] for _ in range(H)]
if dijkstra():
print('Yes')
else:
print('No')