結果
問題 | No.1638 Robot Maze |
ユーザー |
|
提出日時 | 2023-11-05 09:41:53 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 212 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,392 KB |
最終ジャッジ日時 | 2024-09-25 22:23:21 |
合計ジャッジ時間 | 4,043 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
import heapqH, W = map(int, input().split())U, D, R, L, K, P = map(int, input().split())xs, ys, xt, yt = map(lambda x: int(x) - 1, input().split())C = tuple(input() for _ in range(H))INF = 10**18dist = [[INF] * W for _ in range(H)]dist[xs][ys] = 0que = [(0, xs, ys)]while que:c, x, y = heapq.heappop(que)if dist[x][y] < c:continuefor dx, dy, cost in ((0, 1, R), (0, -1, L), (1, 0, D), (-1, 0, U)):nx, ny = x + dx, y + dyif 0 <= nx < H and 0 <= ny < W:if C[nx][ny] == "#":continueelif C[nx][ny] == "@":cost += Pif dist[x][y] + cost < dist[nx][ny]:dist[nx][ny] = dist[x][y] + costheapq.heappush(que, (dist[nx][ny], nx, ny))print("Yes" if dist[xt][yt] <= K else "No")