結果

問題 No.1638 Robot Maze
ユーザー irumo8202irumo8202
提出日時 2022-02-07 12:14:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 9,136 KB
最終ジャッジ日時 2023-09-02 21:35:16
合計ジャッジ時間 5,162 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,576 KB
testcase_01 AC 19 ms
8,572 KB
testcase_02 AC 20 ms
8,620 KB
testcase_03 AC 54 ms
8,960 KB
testcase_04 AC 19 ms
8,584 KB
testcase_05 AC 19 ms
8,760 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 19 ms
8,492 KB
testcase_10 AC 18 ms
8,696 KB
testcase_11 AC 19 ms
8,560 KB
testcase_12 WA -
testcase_13 AC 19 ms
8,568 KB
testcase_14 WA -
testcase_15 AC 28 ms
8,776 KB
testcase_16 AC 28 ms
8,712 KB
testcase_17 WA -
testcase_18 AC 19 ms
8,808 KB
testcase_19 AC 29 ms
8,680 KB
testcase_20 AC 29 ms
8,760 KB
testcase_21 AC 38 ms
8,888 KB
testcase_22 AC 38 ms
8,908 KB
testcase_23 WA -
testcase_24 AC 38 ms
8,956 KB
testcase_25 AC 39 ms
8,784 KB
testcase_26 WA -
testcase_27 AC 38 ms
8,720 KB
testcase_28 AC 40 ms
8,792 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 19 ms
8,592 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 50 ms
8,828 KB
testcase_35 WA -
testcase_36 AC 52 ms
8,968 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 48 ms
8,860 KB
testcase_43 AC 47 ms
8,812 KB
testcase_44 AC 48 ms
9,000 KB
testcase_45 AC 47 ms
8,992 KB
testcase_46 AC 49 ms
8,952 KB
testcase_47 AC 48 ms
8,972 KB
testcase_48 AC 51 ms
9,028 KB
testcase_49 AC 45 ms
8,844 KB
testcase_50 AC 48 ms
9,012 KB
testcase_51 AC 51 ms
8,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 cost[ny][nx] != INF:
            continue

        if C[ny][nx] == "#":
            continue

        if C[ny][nx] == "@":
            ct += P

        cost[ny][nx] = min(cost[ny][nx], cost[y][x] + ct)
        que.append((ny, nx))

print("Yes" if cost[ty][tx] <= K else "No")
0