結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-07 12:19:58 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 879 bytes |
| コンパイル時間 | 86 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-06-12 03:58:30 |
| 合計ジャッジ時間 | 5,680 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 WA * 12 |
ソースコード
from collections import deque
INF = 1 << 60
H, W = map(int, input().split())
U, D, R, L, K, P = map(int, input().split())
sx, sy, tx, ty = map(lambda x: int(x) - 1, input().split())
C = [input() for _ in range(H)]
cost = [[INF for _ in range(W)] for _ in range(H)]
cost[sy][sx] = 0
que = deque([(sy, sx)])
direction = [(-1, 0, U), (0, 1, R), (1, 0, D), (0, -1, L)]
def valid(y, x):
return 0 <= x < W and 0 <= y < H
while que:
y, x = que.popleft()
for dy, dx, ct in direction:
ny, nx = y + dy, x + dx
if not valid(ny, nx):
continue
if C[ny][nx] == "#":
continue
if C[ny][nx] == "@":
ct += P
if cost[ny][nx] <= cost[y][x] + ct:
continue
cost[ny][nx] = min(cost[ny][nx], cost[y][x] + ct)
que.append((ny, nx))
print("Yes" if cost[ty][tx] <= K else "No")