結果

問題 No.1638 Robot Maze
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-08-07 08:05:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 81,600 KB
実行使用メモリ 77,376 KB
最終ジャッジ日時 2023-10-17 14:02:14
合計ジャッジ時間 7,287 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,340 KB
testcase_01 AC 39 ms
53,340 KB
testcase_02 AC 40 ms
53,340 KB
testcase_03 AC 171 ms
76,284 KB
testcase_04 AC 41 ms
53,340 KB
testcase_05 AC 42 ms
53,340 KB
testcase_06 AC 40 ms
53,340 KB
testcase_07 AC 41 ms
53,340 KB
testcase_08 AC 41 ms
53,340 KB
testcase_09 AC 40 ms
53,340 KB
testcase_10 AC 40 ms
53,340 KB
testcase_11 AC 41 ms
53,340 KB
testcase_12 AC 41 ms
53,340 KB
testcase_13 AC 40 ms
53,340 KB
testcase_14 AC 114 ms
76,288 KB
testcase_15 AC 103 ms
76,292 KB
testcase_16 AC 105 ms
76,292 KB
testcase_17 AC 127 ms
76,944 KB
testcase_18 AC 44 ms
55,388 KB
testcase_19 AC 96 ms
76,292 KB
testcase_20 AC 100 ms
76,292 KB
testcase_21 AC 85 ms
76,104 KB
testcase_22 AC 83 ms
76,236 KB
testcase_23 AC 91 ms
76,348 KB
testcase_24 AC 83 ms
76,104 KB
testcase_25 AC 84 ms
76,112 KB
testcase_26 AC 107 ms
76,348 KB
testcase_27 AC 107 ms
76,348 KB
testcase_28 AC 111 ms
76,392 KB
testcase_29 AC 111 ms
76,388 KB
testcase_30 AC 39 ms
53,340 KB
testcase_31 AC 39 ms
53,340 KB
testcase_32 AC 130 ms
76,580 KB
testcase_33 AC 137 ms
76,648 KB
testcase_34 AC 140 ms
76,592 KB
testcase_35 AC 132 ms
76,692 KB
testcase_36 AC 155 ms
76,792 KB
testcase_37 AC 134 ms
76,460 KB
testcase_38 AC 155 ms
77,376 KB
testcase_39 AC 144 ms
76,508 KB
testcase_40 AC 135 ms
76,620 KB
testcase_41 AC 144 ms
76,820 KB
testcase_42 AC 141 ms
76,744 KB
testcase_43 AC 145 ms
76,736 KB
testcase_44 AC 141 ms
76,720 KB
testcase_45 AC 138 ms
76,696 KB
testcase_46 AC 138 ms
76,588 KB
testcase_47 AC 134 ms
76,412 KB
testcase_48 AC 152 ms
76,560 KB
testcase_49 AC 120 ms
76,364 KB
testcase_50 AC 138 ms
76,600 KB
testcase_51 AC 138 ms
76,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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())
c = [list(input()) for _ in range(h)]
q = ([(0,xs-1,ys-1)])
vecs = [(1,0,d),(-1,0,u),(0,1,r),(0,-1,l)]
vis = [[10 ** 15] * w for _ in range(h)]
while q:
    cost,x,y = heapq.heappop(q)
    if cost < vis[x][y]:
        vis[x][y] =  cost
        for vx,vy,vc in vecs:
            nx,ny = x + vx,y + vy
            if nx >= 0 and nx <= h-1 and ny >= 0 and ny <= w-1:
                if c[nx][ny] != "#":
                    if c[nx][ny] == "@":
                        vc += p
                    heapq.heappush(q,(cost+vc,nx,ny))
if vis[xt-1][yt-1] <= k:
    print("Yes")
else:
    print("No")
0