結果

問題 No.1638 Robot Maze
ユーザー mkawa2mkawa2
提出日時 2021-08-06 21:51:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 77,964 KB
最終ジャッジ日時 2023-10-17 03:11:27
合計ジャッジ時間 6,627 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,380 KB
testcase_01 AC 39 ms
53,380 KB
testcase_02 AC 39 ms
53,380 KB
testcase_03 AC 129 ms
76,936 KB
testcase_04 AC 40 ms
53,388 KB
testcase_05 AC 40 ms
53,388 KB
testcase_06 AC 40 ms
53,388 KB
testcase_07 AC 40 ms
53,388 KB
testcase_08 AC 39 ms
53,388 KB
testcase_09 AC 40 ms
53,388 KB
testcase_10 AC 39 ms
53,388 KB
testcase_11 AC 39 ms
53,388 KB
testcase_12 AC 40 ms
53,388 KB
testcase_13 AC 39 ms
53,388 KB
testcase_14 AC 72 ms
73,244 KB
testcase_15 AC 104 ms
76,216 KB
testcase_16 AC 103 ms
76,224 KB
testcase_17 AC 106 ms
76,204 KB
testcase_18 AC 44 ms
61,400 KB
testcase_19 AC 99 ms
76,220 KB
testcase_20 AC 99 ms
76,216 KB
testcase_21 AC 65 ms
70,524 KB
testcase_22 AC 64 ms
70,520 KB
testcase_23 AC 63 ms
70,520 KB
testcase_24 AC 64 ms
70,524 KB
testcase_25 AC 64 ms
70,524 KB
testcase_26 AC 76 ms
75,904 KB
testcase_27 AC 76 ms
75,908 KB
testcase_28 AC 74 ms
75,916 KB
testcase_29 AC 75 ms
75,908 KB
testcase_30 AC 39 ms
53,388 KB
testcase_31 AC 40 ms
53,388 KB
testcase_32 AC 112 ms
76,256 KB
testcase_33 AC 125 ms
76,968 KB
testcase_34 AC 101 ms
76,144 KB
testcase_35 AC 153 ms
77,964 KB
testcase_36 AC 101 ms
76,228 KB
testcase_37 AC 142 ms
76,668 KB
testcase_38 AC 44 ms
61,400 KB
testcase_39 AC 126 ms
76,856 KB
testcase_40 AC 134 ms
76,892 KB
testcase_41 AC 146 ms
76,964 KB
testcase_42 AC 87 ms
76,368 KB
testcase_43 AC 185 ms
77,960 KB
testcase_44 AC 146 ms
77,052 KB
testcase_45 AC 90 ms
76,048 KB
testcase_46 AC 113 ms
76,176 KB
testcase_47 AC 140 ms
76,912 KB
testcase_48 AC 111 ms
76,172 KB
testcase_49 AC 155 ms
77,072 KB
testcase_50 AC 137 ms
77,196 KB
testcase_51 AC 132 ms
76,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

from heapq import *

t = ".@#"

h, w = LI()
u, d, r, l, k, p = LI()
si, sj, gi, gj = LI1()
sij = si*w+sj
gij = gi*w+gj
cc = [t.index(c) for _ in range(h) for c in SI()]

def push(ij, nc):
    if cc[ij] == 2: return
    if cc[ij] == 1: nc += p
    if nc >= dist[ij]: return
    dist[ij] = nc
    heappush(hp, (nc, ij))

dist = [inf]*h*w
dist[sij] = 0
hp = [(0, sij)]
while hp:
    c, ij = heappop(hp)
    if ij == gij: break
    if c > dist[ij]: continue
    i, j = divmod(ij, w)
    if i-1 >= 0: push(ij-w, c+u)
    if i+1 < h: push(ij+w, c+d)
    if j-1 >= 0: push(ij-1, c+l)
    if j+1 < w: push(ij+1, c+r)

print("Yes" if dist[gij] <= k else "No")
0