結果

問題 No.1638 Robot Maze
ユーザー 👑 KazunKazun
提出日時 2021-08-06 21:35:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 818 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 77,220 KB
最終ジャッジ日時 2023-10-17 02:53:35
合計ジャッジ時間 5,834 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,412 KB
testcase_01 AC 38 ms
53,412 KB
testcase_02 AC 39 ms
53,412 KB
testcase_03 AC 106 ms
76,232 KB
testcase_04 AC 40 ms
53,412 KB
testcase_05 WA -
testcase_06 AC 39 ms
53,412 KB
testcase_07 AC 39 ms
53,412 KB
testcase_08 AC 39 ms
53,412 KB
testcase_09 AC 39 ms
53,412 KB
testcase_10 AC 39 ms
53,412 KB
testcase_11 AC 39 ms
53,412 KB
testcase_12 AC 39 ms
53,412 KB
testcase_13 AC 38 ms
53,412 KB
testcase_14 WA -
testcase_15 AC 99 ms
76,100 KB
testcase_16 AC 97 ms
76,096 KB
testcase_17 AC 107 ms
76,296 KB
testcase_18 AC 41 ms
55,460 KB
testcase_19 AC 95 ms
76,240 KB
testcase_20 AC 96 ms
76,240 KB
testcase_21 AC 53 ms
64,164 KB
testcase_22 AC 53 ms
64,212 KB
testcase_23 AC 53 ms
64,212 KB
testcase_24 AC 52 ms
64,164 KB
testcase_25 AC 54 ms
64,164 KB
testcase_26 AC 55 ms
66,468 KB
testcase_27 AC 55 ms
66,468 KB
testcase_28 AC 56 ms
68,516 KB
testcase_29 WA -
testcase_30 AC 39 ms
53,412 KB
testcase_31 AC 38 ms
53,412 KB
testcase_32 AC 101 ms
76,240 KB
testcase_33 AC 103 ms
76,240 KB
testcase_34 AC 94 ms
76,240 KB
testcase_35 AC 115 ms
76,220 KB
testcase_36 AC 103 ms
76,236 KB
testcase_37 AC 101 ms
76,256 KB
testcase_38 AC 40 ms
53,412 KB
testcase_39 AC 93 ms
76,240 KB
testcase_40 AC 119 ms
76,268 KB
testcase_41 AC 111 ms
76,240 KB
testcase_42 AC 89 ms
76,236 KB
testcase_43 AC 150 ms
77,220 KB
testcase_44 AC 117 ms
76,228 KB
testcase_45 AC 117 ms
76,904 KB
testcase_46 AC 110 ms
76,216 KB
testcase_47 AC 106 ms
76,240 KB
testcase_48 AC 101 ms
76,140 KB
testcase_49 AC 115 ms
76,392 KB
testcase_50 AC 96 ms
76,240 KB
testcase_51 AC 122 ms
76,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify,heappop,heappush

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=["*"*(W+2)]
for _ in range(H):
    C.append("*"+input()+"*")
C.append("*"*(W+2))

inf=float("inf")
DP=[[inf]*(W+2) for _ in range(H+2)]; DP[xs][ys]=0
Q=[(0,(xs,ys))]

V=[((1,0),U),((-1,0),D),((0,1),R),((0,-1),L)]

while Q:
    d,(x,y)=heappop(Q)

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

    if x==xt and y==yt:
        break

    for (a,b),c in V:
        if 1<=x+a<=H and 1<=y+b<=W and C[x+a][y+b]!="#":
            if C[x+a][y+b]==".":
                m=d+c
            else:
                m=d+c+P
        else:
            continue

        if DP[x+a][y+b]>m:
            DP[x+a][y+b]=m
            heappush(Q,(m,(x+a,y+b)))

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