結果

問題 No.1638 Robot Maze
ユーザー irumo8202irumo8202
提出日時 2022-02-07 12:19:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 879 bytes
コンパイル時間 126 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2023-09-02 21:43:27
合計ジャッジ時間 5,793 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,692 KB
testcase_01 AC 20 ms
8,568 KB
testcase_02 AC 19 ms
8,560 KB
testcase_03 AC 66 ms
9,088 KB
testcase_04 AC 20 ms
8,540 KB
testcase_05 AC 20 ms
8,572 KB
testcase_06 AC 20 ms
8,736 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 20 ms
8,744 KB
testcase_10 AC 20 ms
8,556 KB
testcase_11 AC 20 ms
8,716 KB
testcase_12 WA -
testcase_13 AC 20 ms
8,688 KB
testcase_14 WA -
testcase_15 AC 33 ms
8,776 KB
testcase_16 AC 32 ms
8,852 KB
testcase_17 WA -
testcase_18 AC 20 ms
8,628 KB
testcase_19 AC 33 ms
8,752 KB
testcase_20 AC 34 ms
8,900 KB
testcase_21 AC 41 ms
8,916 KB
testcase_22 AC 40 ms
8,944 KB
testcase_23 WA -
testcase_24 AC 40 ms
8,848 KB
testcase_25 AC 41 ms
9,000 KB
testcase_26 WA -
testcase_27 AC 47 ms
8,924 KB
testcase_28 AC 49 ms
8,932 KB
testcase_29 WA -
testcase_30 AC 19 ms
8,612 KB
testcase_31 AC 19 ms
8,612 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 156 ms
8,940 KB
testcase_35 AC 182 ms
8,940 KB
testcase_36 WA -
testcase_37 AC 54 ms
9,004 KB
testcase_38 WA -
testcase_39 AC 235 ms
8,952 KB
testcase_40 AC 162 ms
9,032 KB
testcase_41 AC 246 ms
8,936 KB
testcase_42 AC 255 ms
9,052 KB
testcase_43 AC 64 ms
8,932 KB
testcase_44 AC 69 ms
9,004 KB
testcase_45 AC 66 ms
8,984 KB
testcase_46 AC 125 ms
8,984 KB
testcase_47 AC 54 ms
8,888 KB
testcase_48 AC 152 ms
9,040 KB
testcase_49 AC 78 ms
8,888 KB
testcase_50 AC 228 ms
8,996 KB
testcase_51 AC 72 ms
8,972 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 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")
0