結果

問題 No.1638 Robot Maze
ユーザー 👑 rin204rin204
提出日時 2022-01-26 16:05:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 78,896 KB
最終ジャッジ日時 2023-08-24 21:00:12
合計ジャッジ時間 9,649 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,252 KB
testcase_01 AC 77 ms
71,104 KB
testcase_02 AC 77 ms
71,408 KB
testcase_03 AC 122 ms
77,788 KB
testcase_04 AC 79 ms
71,276 KB
testcase_05 AC 78 ms
71,436 KB
testcase_06 AC 77 ms
71,144 KB
testcase_07 AC 78 ms
71,380 KB
testcase_08 AC 79 ms
71,232 KB
testcase_09 AC 78 ms
71,296 KB
testcase_10 AC 78 ms
71,536 KB
testcase_11 AC 76 ms
71,508 KB
testcase_12 AC 78 ms
71,544 KB
testcase_13 AC 78 ms
71,260 KB
testcase_14 AC 129 ms
77,784 KB
testcase_15 AC 114 ms
77,524 KB
testcase_16 AC 113 ms
77,608 KB
testcase_17 AC 116 ms
77,708 KB
testcase_18 AC 78 ms
71,412 KB
testcase_19 AC 110 ms
77,412 KB
testcase_20 AC 113 ms
77,664 KB
testcase_21 AC 87 ms
76,208 KB
testcase_22 AC 88 ms
76,068 KB
testcase_23 AC 87 ms
76,320 KB
testcase_24 AC 89 ms
76,332 KB
testcase_25 AC 87 ms
76,056 KB
testcase_26 AC 94 ms
76,172 KB
testcase_27 AC 94 ms
76,244 KB
testcase_28 AC 95 ms
76,492 KB
testcase_29 AC 94 ms
76,360 KB
testcase_30 AC 76 ms
71,416 KB
testcase_31 AC 76 ms
71,232 KB
testcase_32 AC 136 ms
78,092 KB
testcase_33 AC 140 ms
77,604 KB
testcase_34 AC 143 ms
77,960 KB
testcase_35 AC 141 ms
77,680 KB
testcase_36 AC 140 ms
77,972 KB
testcase_37 AC 132 ms
77,700 KB
testcase_38 AC 136 ms
77,676 KB
testcase_39 AC 143 ms
77,972 KB
testcase_40 AC 151 ms
78,112 KB
testcase_41 AC 146 ms
77,880 KB
testcase_42 AC 144 ms
78,196 KB
testcase_43 AC 164 ms
78,896 KB
testcase_44 AC 148 ms
77,960 KB
testcase_45 AC 161 ms
78,588 KB
testcase_46 AC 145 ms
77,992 KB
testcase_47 AC 137 ms
77,908 KB
testcase_48 AC 142 ms
77,736 KB
testcase_49 AC 138 ms
77,688 KB
testcase_50 AC 143 ms
77,804 KB
testcase_51 AC 156 ms
78,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import *

h, w = map(int, input().split())
u, d, r, l, k, p = map(int, input().split())
xs, ys, xt, yt = map(int, input().split())
C = [input() for _ in range(h)]

xs -= 1
ys -= 1
xt -= 1
yt -= 1
directions = [(-1, 0, u), (1, 0, d), (0, 1, r), (0, -1, l)]

inf = 1 << 60
dist = [[inf] * w for _ in range(h)]
hq = [(0, xs, ys)]
dist[xs][ys] = 0
while hq:
    d, x, y = heappop(hq)
    if d > dist[x][y]:
        continue
    for dx, dy, dd in directions:
        nx = x + dx
        ny = y + dy
        nd = d + dd
        if nx == -1 or ny == -1 or nx == h or ny == w:
            continue
        if C[nx][ny] == "#":
            continue
        if C[nx][ny] == "@":
            nd += p
        if dist[nx][ny] > nd:
            dist[nx][ny] = nd
            heappush(hq, (nd, nx, ny))
        
if dist[xt][yt] <= k:
    print("Yes")
else:
    print("No")
0