結果

問題 No.1638 Robot Maze
ユーザー roarisroaris
提出日時 2021-08-06 22:00:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 887 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 76,748 KB
最終ジャッジ日時 2023-10-17 03:22:25
合計ジャッジ時間 5,658 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,504 KB
testcase_01 AC 38 ms
53,504 KB
testcase_02 AC 38 ms
53,504 KB
testcase_03 AC 92 ms
75,888 KB
testcase_04 AC 40 ms
53,504 KB
testcase_05 AC 39 ms
53,504 KB
testcase_06 AC 40 ms
53,504 KB
testcase_07 AC 40 ms
53,504 KB
testcase_08 AC 40 ms
53,504 KB
testcase_09 AC 40 ms
53,504 KB
testcase_10 AC 39 ms
53,504 KB
testcase_11 AC 40 ms
53,504 KB
testcase_12 AC 39 ms
53,504 KB
testcase_13 AC 39 ms
53,504 KB
testcase_14 AC 95 ms
76,092 KB
testcase_15 AC 87 ms
75,828 KB
testcase_16 AC 86 ms
75,828 KB
testcase_17 AC 89 ms
75,920 KB
testcase_18 AC 40 ms
53,504 KB
testcase_19 AC 84 ms
75,828 KB
testcase_20 AC 84 ms
75,828 KB
testcase_21 AC 51 ms
66,216 KB
testcase_22 AC 52 ms
66,208 KB
testcase_23 AC 51 ms
66,208 KB
testcase_24 AC 51 ms
66,216 KB
testcase_25 AC 52 ms
66,216 KB
testcase_26 AC 57 ms
70,412 KB
testcase_27 AC 57 ms
70,412 KB
testcase_28 AC 57 ms
70,412 KB
testcase_29 AC 59 ms
70,412 KB
testcase_30 AC 39 ms
53,504 KB
testcase_31 AC 38 ms
53,504 KB
testcase_32 AC 104 ms
76,088 KB
testcase_33 AC 109 ms
76,100 KB
testcase_34 AC 94 ms
75,828 KB
testcase_35 AC 107 ms
75,932 KB
testcase_36 AC 110 ms
76,080 KB
testcase_37 AC 98 ms
76,088 KB
testcase_38 AC 107 ms
76,148 KB
testcase_39 AC 105 ms
76,028 KB
testcase_40 AC 117 ms
76,128 KB
testcase_41 AC 119 ms
76,744 KB
testcase_42 AC 120 ms
76,092 KB
testcase_43 AC 132 ms
76,748 KB
testcase_44 AC 109 ms
76,088 KB
testcase_45 AC 112 ms
75,988 KB
testcase_46 AC 109 ms
75,980 KB
testcase_47 AC 102 ms
75,920 KB
testcase_48 AC 108 ms
76,088 KB
testcase_49 AC 104 ms
75,940 KB
testcase_50 AC 113 ms
76,176 KB
testcase_51 AC 125 ms
76,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from heapq import *

def dijkstra():
    dist = [[10**18]*W for _ in range(H)]
    dist[xs-1][ys-1] = 0
    pq = [(0, (xs-1)*10000+ys-1)]
    
    while pq:
        d, xy = heappop(pq)
        x, y = divmod(xy, 10000)
        
        for nx, ny, c in [(x-1, y, U), (x+1, y, D), (x, y-1, L), (x, y+1, R)]:
            if 0<=nx<H and 0<=ny<W and C[nx][ny]!='#':
                if C[nx][ny]=='@':
                    c += P
                    
                if dist[nx][ny]>dist[x][y]+c:
                    dist[nx][ny] = dist[x][y]+c
                    heappush(pq, (dist[nx][ny], nx*10000+ny))
    
    return dist[xt-1][yt-1]<=K

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 = [input()[:-1] for _ in range(H)]

if dijkstra():
    print('Yes')
else:
    print('No')
0