結果

問題 No.1638 Robot Maze
ユーザー momoyuumomoyuu
提出日時 2022-08-03 01:14:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 978 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 79,192 KB
最終ジャッジ日時 2023-10-01 01:55:03
合計ジャッジ時間 8,802 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,368 KB
testcase_01 AC 73 ms
71,312 KB
testcase_02 AC 70 ms
71,364 KB
testcase_03 AC 111 ms
78,124 KB
testcase_04 AC 74 ms
71,152 KB
testcase_05 AC 73 ms
71,116 KB
testcase_06 AC 74 ms
71,028 KB
testcase_07 AC 73 ms
71,292 KB
testcase_08 AC 75 ms
71,008 KB
testcase_09 AC 73 ms
71,168 KB
testcase_10 AC 74 ms
71,452 KB
testcase_11 AC 73 ms
71,136 KB
testcase_12 AC 74 ms
71,032 KB
testcase_13 AC 73 ms
71,352 KB
testcase_14 AC 112 ms
78,400 KB
testcase_15 AC 109 ms
78,236 KB
testcase_16 AC 107 ms
78,108 KB
testcase_17 AC 113 ms
78,592 KB
testcase_18 AC 79 ms
75,140 KB
testcase_19 AC 105 ms
78,248 KB
testcase_20 AC 108 ms
78,048 KB
testcase_21 AC 87 ms
76,748 KB
testcase_22 AC 87 ms
76,624 KB
testcase_23 AC 89 ms
76,484 KB
testcase_24 AC 88 ms
76,608 KB
testcase_25 AC 90 ms
76,572 KB
testcase_26 AC 92 ms
76,804 KB
testcase_27 AC 92 ms
76,884 KB
testcase_28 AC 90 ms
76,876 KB
testcase_29 AC 94 ms
76,884 KB
testcase_30 AC 73 ms
71,284 KB
testcase_31 AC 73 ms
71,308 KB
testcase_32 AC 120 ms
78,784 KB
testcase_33 AC 140 ms
78,368 KB
testcase_34 AC 121 ms
78,356 KB
testcase_35 AC 141 ms
78,584 KB
testcase_36 AC 131 ms
78,564 KB
testcase_37 AC 124 ms
78,416 KB
testcase_38 AC 77 ms
75,008 KB
testcase_39 AC 132 ms
78,548 KB
testcase_40 AC 137 ms
78,396 KB
testcase_41 AC 137 ms
78,156 KB
testcase_42 AC 118 ms
78,408 KB
testcase_43 AC 165 ms
79,172 KB
testcase_44 AC 156 ms
79,192 KB
testcase_45 AC 126 ms
78,424 KB
testcase_46 AC 125 ms
78,596 KB
testcase_47 AC 131 ms
78,448 KB
testcase_48 AC 137 ms
78,728 KB
testcase_49 AC 131 ms
78,444 KB
testcase_50 AC 147 ms
78,928 KB
testcase_51 AC 151 ms
78,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W = map(int,input().split())
U,D,R,L,K,P = map(int,input().split())
cost = [U,D,R,L]
move = ((-1,0),(1,0),(0,1),(0,-1))
def f(n):
    return int(n)-1
    
xs,ys,xt,yt = map(f,input().split())
C = [list(input()) for _ in range(H)]

import heapq
que = []
que.append((0,xs,ys))
inf = float("inf")
d = [[inf for _ in range(W)] for _ in range(H)]
d[xs][ys] = 0
need = inf
while len(que) != 0:
    n,i,j = heapq.heappop(que)
    if d[i][j] < n:
        continue
    if i == xt and j == yt:
        need = d[i][j]
        break
    for k in range(4):
        a,b = move[k]
        ni,nj = i + a , j + b
        if ni < 0 or ni >= H or nj < 0 or nj >= W:
            continue
        if C[ni][nj] == "#":
            continue
        next = d[i][j] + cost[k]
        if C[ni][nj] == "@":
            next += P
        if d[ni][nj] <= next:
            continue
        d[ni][nj] = next
        heapq.heappush(que,(next,ni,nj))

if need <= K:
    print("Yes")
else:
    print("No")



0