結果

問題 No.1638 Robot Maze
ユーザー MineMine
提出日時 2021-09-10 13:00:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 79,480 KB
最終ジャッジ日時 2023-08-31 00:02:37
合計ジャッジ時間 9,678 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,456 KB
testcase_01 AC 76 ms
70,948 KB
testcase_02 AC 76 ms
71,224 KB
testcase_03 AC 145 ms
77,464 KB
testcase_04 AC 77 ms
71,424 KB
testcase_05 AC 77 ms
71,224 KB
testcase_06 AC 76 ms
71,344 KB
testcase_07 AC 79 ms
71,480 KB
testcase_08 AC 78 ms
71,336 KB
testcase_09 AC 75 ms
71,092 KB
testcase_10 AC 76 ms
71,428 KB
testcase_11 AC 75 ms
71,492 KB
testcase_12 AC 76 ms
71,404 KB
testcase_13 AC 76 ms
71,424 KB
testcase_14 AC 119 ms
77,648 KB
testcase_15 AC 123 ms
77,496 KB
testcase_16 AC 125 ms
77,692 KB
testcase_17 AC 132 ms
77,752 KB
testcase_18 AC 79 ms
71,416 KB
testcase_19 AC 123 ms
77,488 KB
testcase_20 AC 126 ms
77,492 KB
testcase_21 AC 91 ms
76,004 KB
testcase_22 AC 90 ms
76,268 KB
testcase_23 AC 89 ms
76,112 KB
testcase_24 AC 90 ms
76,268 KB
testcase_25 AC 89 ms
76,392 KB
testcase_26 AC 93 ms
76,488 KB
testcase_27 AC 92 ms
76,284 KB
testcase_28 AC 93 ms
76,552 KB
testcase_29 AC 94 ms
76,376 KB
testcase_30 AC 75 ms
71,292 KB
testcase_31 AC 74 ms
71,168 KB
testcase_32 AC 155 ms
78,248 KB
testcase_33 AC 155 ms
78,688 KB
testcase_34 AC 138 ms
77,896 KB
testcase_35 AC 162 ms
78,836 KB
testcase_36 AC 142 ms
77,608 KB
testcase_37 AC 152 ms
78,104 KB
testcase_38 AC 75 ms
71,084 KB
testcase_39 AC 141 ms
77,472 KB
testcase_40 AC 144 ms
77,840 KB
testcase_41 AC 180 ms
79,480 KB
testcase_42 AC 128 ms
78,180 KB
testcase_43 AC 185 ms
78,608 KB
testcase_44 AC 142 ms
77,820 KB
testcase_45 AC 136 ms
78,044 KB
testcase_46 AC 151 ms
78,416 KB
testcase_47 AC 167 ms
78,456 KB
testcase_48 AC 146 ms
78,292 KB
testcase_49 AC 174 ms
78,500 KB
testcase_50 AC 175 ms
78,884 KB
testcase_51 AC 161 ms
78,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

def main():
    H, W = map(int, input().split())
    u,d,r,l,k,p = map(int, input().split())
    x1, x2, y1, y2 = [i-1 for i in list(map(int, input().split()))]
    c = [input() for i in range(H)]
    seen = [[False]*W for _ in range(H)]
    costs = [u, d, r, l]
    directions = [(-1, 0), (1, 0), (0, 1), (0, -1)]

    hq = []
    hq.append((0, x1, x2))
    while hq:
        cost, h, w = heapq.heappop(hq)
        if h == y1 and w == y2:
            if cost <= k:
                return True
            else:
                return False
        if not seen[h][w]:
            seen[h][w] = True
            for idx, (dh, dw) in enumerate(directions):
                if 0 <= h+dh < H and 0 <= w+dw < W and not seen[h+dh][w+dw]:
                    if c[h+dh][w+dw] == ".":
                        heapq.heappush(hq, (cost + costs[idx], h+dh, w+dw))
                    elif c[h+dh][w+dw] == "@":
                        heapq.heappush(hq, (cost + costs[idx] + p, h+dh, w+dw))
    return False

if main():
    print("Yes")
else:
    print("No")
0