結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,404 KB
testcase_01 AC 38 ms
53,404 KB
testcase_02 AC 38 ms
53,404 KB
testcase_03 AC 103 ms
76,192 KB
testcase_04 AC 40 ms
53,404 KB
testcase_05 WA -
testcase_06 AC 39 ms
53,404 KB
testcase_07 AC 39 ms
53,404 KB
testcase_08 AC 39 ms
53,404 KB
testcase_09 AC 39 ms
53,404 KB
testcase_10 AC 39 ms
53,404 KB
testcase_11 AC 38 ms
53,404 KB
testcase_12 AC 39 ms
53,404 KB
testcase_13 AC 38 ms
53,404 KB
testcase_14 WA -
testcase_15 AC 98 ms
76,048 KB
testcase_16 AC 99 ms
76,048 KB
testcase_17 AC 106 ms
76,240 KB
testcase_18 AC 42 ms
55,452 KB
testcase_19 AC 94 ms
76,192 KB
testcase_20 AC 94 ms
76,192 KB
testcase_21 AC 53 ms
64,116 KB
testcase_22 AC 53 ms
64,164 KB
testcase_23 AC 54 ms
64,164 KB
testcase_24 AC 53 ms
64,116 KB
testcase_25 AC 53 ms
64,116 KB
testcase_26 AC 55 ms
66,420 KB
testcase_27 AC 56 ms
66,420 KB
testcase_28 AC 57 ms
68,468 KB
testcase_29 WA -
testcase_30 AC 39 ms
53,404 KB
testcase_31 AC 38 ms
53,404 KB
testcase_32 AC 101 ms
76,260 KB
testcase_33 AC 105 ms
76,200 KB
testcase_34 AC 94 ms
76,192 KB
testcase_35 AC 119 ms
76,168 KB
testcase_36 AC 128 ms
76,188 KB
testcase_37 AC 106 ms
76,228 KB
testcase_38 AC 41 ms
53,404 KB
testcase_39 AC 96 ms
76,192 KB
testcase_40 AC 118 ms
76,268 KB
testcase_41 AC 111 ms
76,192 KB
testcase_42 AC 91 ms
76,188 KB
testcase_43 AC 145 ms
76,996 KB
testcase_44 AC 146 ms
77,168 KB
testcase_45 AC 129 ms
76,888 KB
testcase_46 AC 114 ms
76,284 KB
testcase_47 AC 107 ms
76,212 KB
testcase_48 AC 100 ms
76,096 KB
testcase_49 AC 115 ms
76,316 KB
testcase_50 AC 104 ms
76,188 KB
testcase_51 AC 141 ms
77,080 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