結果

問題 No.1638 Robot Maze
ユーザー 👑 KazunKazun
提出日時 2021-08-06 21:42:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 77,200 KB
最終ジャッジ日時 2023-10-17 02:59:24
合計ジャッジ時間 6,269 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,500 KB
testcase_01 AC 39 ms
53,500 KB
testcase_02 AC 38 ms
53,500 KB
testcase_03 AC 111 ms
76,276 KB
testcase_04 AC 40 ms
53,508 KB
testcase_05 AC 40 ms
53,508 KB
testcase_06 AC 40 ms
53,508 KB
testcase_07 AC 40 ms
53,508 KB
testcase_08 AC 38 ms
53,508 KB
testcase_09 AC 40 ms
53,508 KB
testcase_10 AC 39 ms
53,508 KB
testcase_11 AC 39 ms
53,508 KB
testcase_12 AC 40 ms
53,508 KB
testcase_13 AC 39 ms
53,508 KB
testcase_14 AC 76 ms
73,664 KB
testcase_15 AC 95 ms
76,300 KB
testcase_16 AC 96 ms
76,300 KB
testcase_17 AC 105 ms
76,200 KB
testcase_18 AC 42 ms
55,556 KB
testcase_19 AC 95 ms
76,300 KB
testcase_20 AC 93 ms
76,300 KB
testcase_21 AC 54 ms
64,220 KB
testcase_22 AC 54 ms
64,268 KB
testcase_23 AC 53 ms
64,268 KB
testcase_24 AC 53 ms
64,220 KB
testcase_25 AC 53 ms
64,220 KB
testcase_26 AC 57 ms
68,576 KB
testcase_27 AC 56 ms
68,576 KB
testcase_28 AC 57 ms
68,576 KB
testcase_29 AC 57 ms
68,576 KB
testcase_30 AC 39 ms
53,508 KB
testcase_31 AC 38 ms
53,508 KB
testcase_32 AC 101 ms
76,200 KB
testcase_33 AC 105 ms
76,348 KB
testcase_34 AC 95 ms
76,300 KB
testcase_35 AC 111 ms
76,372 KB
testcase_36 AC 99 ms
76,296 KB
testcase_37 AC 105 ms
76,300 KB
testcase_38 AC 40 ms
53,508 KB
testcase_39 AC 107 ms
76,300 KB
testcase_40 AC 115 ms
76,296 KB
testcase_41 AC 115 ms
76,296 KB
testcase_42 AC 88 ms
76,300 KB
testcase_43 AC 158 ms
77,200 KB
testcase_44 AC 134 ms
77,192 KB
testcase_45 AC 93 ms
76,036 KB
testcase_46 AC 101 ms
76,300 KB
testcase_47 AC 108 ms
76,408 KB
testcase_48 AC 101 ms
76,300 KB
testcase_49 AC 115 ms
76,460 KB
testcase_50 AC 113 ms
76,300 KB
testcase_51 AC 120 ms
76,424 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