結果

問題 No.1638 Robot Maze
ユーザー tonyu0tonyu0
提出日時 2022-09-21 18:08:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 8,732 KB
最終ジャッジ日時 2023-08-23 20:06:43
合計ジャッジ時間 5,176 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,216 KB
testcase_01 AC 19 ms
8,272 KB
testcase_02 AC 17 ms
8,384 KB
testcase_03 AC 59 ms
8,628 KB
testcase_04 AC 17 ms
8,264 KB
testcase_05 AC 16 ms
8,332 KB
testcase_06 AC 17 ms
8,220 KB
testcase_07 AC 17 ms
8,392 KB
testcase_08 AC 17 ms
8,348 KB
testcase_09 AC 17 ms
8,336 KB
testcase_10 AC 17 ms
8,212 KB
testcase_11 AC 16 ms
8,224 KB
testcase_12 AC 17 ms
8,216 KB
testcase_13 AC 17 ms
8,276 KB
testcase_14 AC 40 ms
8,668 KB
testcase_15 AC 28 ms
8,516 KB
testcase_16 AC 29 ms
8,512 KB
testcase_17 AC 28 ms
8,556 KB
testcase_18 AC 17 ms
8,488 KB
testcase_19 AC 28 ms
8,548 KB
testcase_20 AC 29 ms
8,544 KB
testcase_21 AC 37 ms
8,652 KB
testcase_22 AC 36 ms
8,648 KB
testcase_23 AC 36 ms
8,524 KB
testcase_24 AC 37 ms
8,700 KB
testcase_25 AC 39 ms
8,528 KB
testcase_26 AC 36 ms
8,472 KB
testcase_27 AC 36 ms
8,608 KB
testcase_28 AC 36 ms
8,520 KB
testcase_29 AC 36 ms
8,612 KB
testcase_30 AC 17 ms
8,256 KB
testcase_31 AC 17 ms
8,384 KB
testcase_32 AC 48 ms
8,564 KB
testcase_33 AC 50 ms
8,564 KB
testcase_34 AC 56 ms
8,508 KB
testcase_35 AC 51 ms
8,636 KB
testcase_36 AC 56 ms
8,484 KB
testcase_37 AC 47 ms
8,504 KB
testcase_38 AC 47 ms
8,732 KB
testcase_39 AC 54 ms
8,648 KB
testcase_40 AC 49 ms
8,640 KB
testcase_41 AC 53 ms
8,684 KB
testcase_42 AC 50 ms
8,564 KB
testcase_43 AC 51 ms
8,544 KB
testcase_44 AC 52 ms
8,688 KB
testcase_45 AC 51 ms
8,556 KB
testcase_46 AC 53 ms
8,680 KB
testcase_47 AC 51 ms
8,540 KB
testcase_48 AC 56 ms
8,636 KB
testcase_49 AC 48 ms
8,560 KB
testcase_50 AC 52 ms
8,540 KB
testcase_51 AC 54 ms
8,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w=map(int,input().split())
u,d,r,l,k,p=map(int,input().split())
xs,ys,xt,yt=map(lambda x: int(x)-1,input().split())
s=[input() for _ in range(h)]

dx=[0, 1, 0, -1]
dy=[1, 0, -1, 0]
cs=[r, d,  l, u]

import heapq
pq=[]
heapq.heapify(pq)
n=h*w
cost=[1e18]*n
cost[xs*w+ys]=0
heapq.heappush(pq,[0,xs*w+ys])
while len(pq) > 0:
    c,v=heapq.heappop(pq)
    x,y=divmod(v, w)
    for i in range(4):
        nx=x+dx[i]
        ny=y+dy[i]
        if 0<=nx<h and 0<=ny<w and cost[nx*w+ny]==1e18 and s[nx][ny]!='#':
            cost[nx*w+ny]=c+cs[i]
            if s[nx][ny]=='@':
                cost[nx*w+ny] += p
            heapq.heappush(pq, [cost[nx*w+ny], nx*w+ny])
if cost[xt*w+yt] <= k:
    print('Yes')
else:print('No')
0