結果

問題 No.1638 Robot Maze
ユーザー kohei2019kohei2019
提出日時 2022-06-26 10:08:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 77,840 KB
最終ジャッジ日時 2024-04-28 02:18:29
合計ジャッジ時間 5,981 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,992 KB
testcase_01 AC 41 ms
53,120 KB
testcase_02 AC 41 ms
52,736 KB
testcase_03 AC 87 ms
76,672 KB
testcase_04 AC 41 ms
53,632 KB
testcase_05 AC 41 ms
53,248 KB
testcase_06 AC 42 ms
53,248 KB
testcase_07 AC 41 ms
52,992 KB
testcase_08 AC 41 ms
53,376 KB
testcase_09 AC 41 ms
53,120 KB
testcase_10 AC 42 ms
53,376 KB
testcase_11 AC 42 ms
53,248 KB
testcase_12 AC 42 ms
52,992 KB
testcase_13 AC 41 ms
52,992 KB
testcase_14 AC 104 ms
76,800 KB
testcase_15 AC 79 ms
75,520 KB
testcase_16 AC 82 ms
75,324 KB
testcase_17 AC 91 ms
77,028 KB
testcase_18 AC 43 ms
53,504 KB
testcase_19 AC 79 ms
74,596 KB
testcase_20 AC 79 ms
74,568 KB
testcase_21 AC 55 ms
64,640 KB
testcase_22 AC 55 ms
64,640 KB
testcase_23 AC 61 ms
64,384 KB
testcase_24 AC 55 ms
64,384 KB
testcase_25 AC 56 ms
64,640 KB
testcase_26 AC 62 ms
68,352 KB
testcase_27 AC 60 ms
68,224 KB
testcase_28 AC 62 ms
68,608 KB
testcase_29 AC 62 ms
68,992 KB
testcase_30 AC 41 ms
52,864 KB
testcase_31 AC 40 ms
53,120 KB
testcase_32 AC 108 ms
76,892 KB
testcase_33 AC 114 ms
76,768 KB
testcase_34 AC 117 ms
76,812 KB
testcase_35 AC 117 ms
76,604 KB
testcase_36 AC 116 ms
76,672 KB
testcase_37 AC 112 ms
76,756 KB
testcase_38 AC 110 ms
76,752 KB
testcase_39 AC 119 ms
76,916 KB
testcase_40 AC 123 ms
76,604 KB
testcase_41 AC 120 ms
76,564 KB
testcase_42 AC 118 ms
76,784 KB
testcase_43 AC 139 ms
77,816 KB
testcase_44 AC 134 ms
77,840 KB
testcase_45 AC 131 ms
76,784 KB
testcase_46 AC 119 ms
76,608 KB
testcase_47 AC 115 ms
76,652 KB
testcase_48 AC 116 ms
77,016 KB
testcase_49 AC 107 ms
76,672 KB
testcase_50 AC 127 ms
77,040 KB
testcase_51 AC 127 ms
76,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

H,W = map(int,input().split())
U,D,R,L,K,P = map(int,input().split())
move = [(-1,0,U),(1,0,D),(0,1,R),(0,-1,L)]
xs,ys,xt,yt = map(int,input().split())
xs,ys,xt,yt = xs-1,ys-1,xt-1,yt-1
lsHW = [input() for i in range(H)]

h = [(0,xs,ys)]
INF = float('INF')
lscost = [[INF]*(W) for i in range(H)]
lscost[xs][ys] = 0
while h:
    co,x,y = heapq.heappop(h)
    for dx,dy,c in move:
        if 0<= x+dx < H and 0<= y+dy < W:
            if lsHW[x+dx][y+dy] == '#':
                continue
            if lsHW[x+dx][y+dy] == '@':
                if lscost[x+dx][y+dy] > lscost[x][y] + c + P:
                    lscost[x+dx][y+dy] = lscost[x][y] + c + P
                    heapq.heappush(h,(lscost[x+dx][y+dy],x+dx,y+dy))
            else:
                if lscost[x+dx][y+dy] > lscost[x][y] + c:
                    lscost[x+dx][y+dy] = lscost[x][y] + c
                    heapq.heappush(h,(lscost[x+dx][y+dy],x+dx,y+dy))
if lscost[xt][yt] <= K:
    print('Yes')
else:
    print('No')
0