結果

問題 No.1638 Robot Maze
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-08-06 21:46:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 76,936 KB
最終ジャッジ日時 2023-10-17 03:05:39
合計ジャッジ時間 5,587 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,420 KB
testcase_01 AC 38 ms
53,420 KB
testcase_02 AC 38 ms
53,420 KB
testcase_03 AC 85 ms
75,760 KB
testcase_04 AC 40 ms
53,420 KB
testcase_05 AC 40 ms
53,420 KB
testcase_06 AC 38 ms
53,420 KB
testcase_07 AC 38 ms
53,420 KB
testcase_08 AC 39 ms
53,420 KB
testcase_09 AC 38 ms
53,420 KB
testcase_10 AC 40 ms
53,420 KB
testcase_11 AC 40 ms
53,420 KB
testcase_12 AC 39 ms
53,420 KB
testcase_13 AC 38 ms
53,420 KB
testcase_14 AC 89 ms
76,120 KB
testcase_15 AC 71 ms
72,604 KB
testcase_16 AC 70 ms
72,604 KB
testcase_17 AC 90 ms
75,952 KB
testcase_18 AC 39 ms
53,420 KB
testcase_19 AC 69 ms
72,600 KB
testcase_20 AC 70 ms
72,600 KB
testcase_21 AC 52 ms
66,244 KB
testcase_22 AC 52 ms
66,236 KB
testcase_23 AC 53 ms
66,296 KB
testcase_24 AC 53 ms
66,244 KB
testcase_25 AC 53 ms
66,244 KB
testcase_26 AC 58 ms
70,456 KB
testcase_27 AC 58 ms
70,456 KB
testcase_28 AC 59 ms
70,456 KB
testcase_29 AC 58 ms
70,456 KB
testcase_30 AC 38 ms
53,420 KB
testcase_31 AC 39 ms
53,420 KB
testcase_32 AC 99 ms
75,964 KB
testcase_33 AC 113 ms
76,116 KB
testcase_34 AC 103 ms
76,120 KB
testcase_35 AC 112 ms
76,116 KB
testcase_36 AC 113 ms
76,116 KB
testcase_37 AC 97 ms
75,856 KB
testcase_38 AC 110 ms
76,120 KB
testcase_39 AC 110 ms
76,120 KB
testcase_40 AC 114 ms
76,116 KB
testcase_41 AC 122 ms
76,232 KB
testcase_42 AC 116 ms
76,164 KB
testcase_43 AC 138 ms
76,936 KB
testcase_44 AC 144 ms
76,932 KB
testcase_45 AC 137 ms
76,540 KB
testcase_46 AC 111 ms
76,188 KB
testcase_47 AC 100 ms
75,956 KB
testcase_48 AC 112 ms
76,116 KB
testcase_49 AC 98 ms
75,856 KB
testcase_50 AC 121 ms
76,456 KB
testcase_51 AC 131 ms
76,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
import heapq

H,W = map(int,stdin.readline().split())

U,D,R,L,K,P = map(int,stdin.readline().split())

xs,ys,xg,yg = map(int,stdin.readline().split())
xs -= 1
ys -= 1
xg -= 1
yg -= 1

C = [stdin.readline()[:-1] for i in range(H)]

d = [[float("inf")] * W for i in range(H)]

q = [(0,xs,ys)]
d[xs][ys] = 0

while q:

    sc,x,y = heapq.heappop(q)

    if d[x][y] != sc:
        continue

    for nx,ny,cost in [(x-1,y,U),(x+1,y,D),(x,y-1,L),(x,y+1,R)]:

        if not (0 <= nx < H and 0 <= ny < W):
            continue

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

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

        if d[nx][ny] > sc + cost:
            d[nx][ny] = sc + cost
            heapq.heappush(q,(d[nx][ny],nx,ny))

if d[xg][yg] <= K:
    print ("Yes")
else:
    print ("No")
0