結果

問題 No.1638 Robot Maze
ユーザー convexineqconvexineq
提出日時 2021-08-06 22:50:44
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 78,640 KB
最終ジャッジ日時 2023-08-09 01:37:08
合計ジャッジ時間 9,431 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,324 KB
testcase_01 AC 69 ms
71,128 KB
testcase_02 AC 70 ms
71,352 KB
testcase_03 AC 109 ms
77,920 KB
testcase_04 AC 71 ms
71,356 KB
testcase_05 AC 70 ms
71,164 KB
testcase_06 AC 70 ms
71,124 KB
testcase_07 AC 72 ms
71,156 KB
testcase_08 AC 72 ms
71,352 KB
testcase_09 AC 71 ms
71,216 KB
testcase_10 AC 72 ms
71,156 KB
testcase_11 AC 69 ms
71,356 KB
testcase_12 AC 70 ms
71,288 KB
testcase_13 AC 72 ms
71,432 KB
testcase_14 AC 115 ms
77,808 KB
testcase_15 AC 110 ms
77,712 KB
testcase_16 AC 109 ms
77,380 KB
testcase_17 AC 112 ms
77,928 KB
testcase_18 AC 71 ms
71,080 KB
testcase_19 AC 105 ms
77,484 KB
testcase_20 AC 107 ms
77,428 KB
testcase_21 AC 83 ms
76,216 KB
testcase_22 AC 83 ms
76,596 KB
testcase_23 AC 82 ms
76,192 KB
testcase_24 AC 83 ms
76,440 KB
testcase_25 AC 83 ms
76,364 KB
testcase_26 AC 88 ms
76,580 KB
testcase_27 AC 87 ms
76,568 KB
testcase_28 AC 87 ms
76,536 KB
testcase_29 AC 87 ms
76,464 KB
testcase_30 AC 69 ms
71,288 KB
testcase_31 AC 72 ms
71,228 KB
testcase_32 AC 118 ms
77,828 KB
testcase_33 AC 139 ms
78,312 KB
testcase_34 AC 128 ms
78,032 KB
testcase_35 AC 142 ms
77,932 KB
testcase_36 AC 140 ms
78,604 KB
testcase_37 AC 118 ms
77,520 KB
testcase_38 AC 128 ms
77,932 KB
testcase_39 AC 126 ms
77,968 KB
testcase_40 AC 135 ms
77,960 KB
testcase_41 AC 141 ms
78,640 KB
testcase_42 AC 143 ms
77,948 KB
testcase_43 AC 149 ms
78,248 KB
testcase_44 AC 159 ms
78,488 KB
testcase_45 AC 164 ms
78,316 KB
testcase_46 AC 125 ms
78,012 KB
testcase_47 AC 116 ms
77,536 KB
testcase_48 AC 134 ms
77,792 KB
testcase_49 AC 123 ms
77,704 KB
testcase_50 AC 139 ms
77,936 KB
testcase_51 AC 148 ms
77,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

h,w = map(int,input().split())
u,d,r,l,k,p = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
b = [input() for _ in range(h)]
sx -= 1
sy -= 1
gx -= 1
gy -= 1
C = [d,r,u,l]
dx = [1,0,-1,0]
dy = [0,1,0,-1]
INF = 10**18
dist = [[INF]*w for _ in range(h)]
from heapq import *
q = [(0,sx,sy)]
while q:
    dv,x,y = heappop(q)
    if dist[x][y] < dv: continue
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if nx < 0 or nx >= h or ny < 0 or ny >= w or b[nx][ny] == "#": continue
        cost = dv + C[i]
        if b[nx][ny] == "@":
            cost += p
        if cost < dist[nx][ny]:
            heappush(q, (cost,nx,ny))
            dist[nx][ny] = cost
print("Yes" if dist[gx][gy] <= k else "No")

0