結果

問題 No.1638 Robot Maze
ユーザー titiatitia
提出日時 2021-08-06 21:34:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 76,960 KB
最終ジャッジ日時 2023-10-17 02:52:16
合計ジャッジ時間 5,498 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,532 KB
testcase_01 AC 37 ms
53,532 KB
testcase_02 AC 37 ms
53,532 KB
testcase_03 AC 80 ms
75,896 KB
testcase_04 AC 38 ms
53,532 KB
testcase_05 AC 38 ms
53,532 KB
testcase_06 AC 39 ms
53,532 KB
testcase_07 AC 39 ms
53,532 KB
testcase_08 AC 39 ms
53,532 KB
testcase_09 AC 39 ms
53,532 KB
testcase_10 AC 39 ms
53,532 KB
testcase_11 AC 39 ms
53,532 KB
testcase_12 AC 39 ms
53,532 KB
testcase_13 AC 38 ms
53,532 KB
testcase_14 AC 89 ms
75,980 KB
testcase_15 AC 83 ms
75,984 KB
testcase_16 AC 83 ms
75,984 KB
testcase_17 AC 84 ms
76,244 KB
testcase_18 AC 39 ms
53,532 KB
testcase_19 AC 82 ms
75,984 KB
testcase_20 AC 82 ms
75,984 KB
testcase_21 AC 52 ms
66,272 KB
testcase_22 AC 52 ms
66,272 KB
testcase_23 AC 53 ms
66,272 KB
testcase_24 AC 52 ms
66,272 KB
testcase_25 AC 52 ms
66,272 KB
testcase_26 AC 58 ms
70,648 KB
testcase_27 AC 58 ms
70,648 KB
testcase_28 AC 58 ms
70,648 KB
testcase_29 AC 59 ms
70,648 KB
testcase_30 AC 38 ms
53,532 KB
testcase_31 AC 38 ms
53,532 KB
testcase_32 AC 94 ms
75,980 KB
testcase_33 AC 112 ms
76,244 KB
testcase_34 AC 103 ms
76,244 KB
testcase_35 AC 109 ms
76,148 KB
testcase_36 AC 108 ms
76,244 KB
testcase_37 AC 95 ms
76,244 KB
testcase_38 AC 102 ms
76,264 KB
testcase_39 AC 101 ms
76,244 KB
testcase_40 AC 113 ms
76,356 KB
testcase_41 AC 114 ms
76,252 KB
testcase_42 AC 111 ms
76,244 KB
testcase_43 AC 118 ms
76,372 KB
testcase_44 AC 132 ms
76,960 KB
testcase_45 AC 119 ms
76,264 KB
testcase_46 AC 105 ms
76,132 KB
testcase_47 AC 90 ms
75,988 KB
testcase_48 AC 108 ms
76,248 KB
testcase_49 AC 99 ms
76,244 KB
testcase_50 AC 108 ms
76,248 KB
testcase_51 AC 126 ms
76,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
import heapq

H,W=map(int,input().split())
U,D,R,L,K,P=map(int,input().split())
xs,ys,xt,yt=map(int,input().split())

MAP=[input().strip() for i in range(H)]
DP=[[1<<60]*W for i in range(H)]

xs-=1
xt-=1
ys-=1
yt-=1

Q=[(0,xs,ys)]

while Q:
    cost,x,y=heapq.heappop(Q)

    if cost>DP[x][y]:
        continue

    for z,w,cp in [(x+1,y,D),(x-1,y,U),(x,y+1,R),(x,y-1,L)]:
        if 0<=z<H and 0<=w<W:
            if MAP[z][w]=="." and DP[z][w]>cost+cp:
                DP[z][w]=cost+cp
                heapq.heappush(Q,(cost+cp,z,w))
            elif MAP[z][w]=="@" and DP[z][w]>cost+cp+P:
                DP[z][w]=cost+cp+P
                heapq.heappush(Q,(cost+cp+P,z,w))

if DP[xt][yt]<=K:
    print("Yes")
else:
    print("No")
                
0