結果

問題 No.1638 Robot Maze
ユーザー U SU S
提出日時 2021-08-06 22:10:59
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 1,559 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 80,000 KB
最終ジャッジ日時 2023-10-17 03:34:03
合計ジャッジ時間 6,802 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
61,132 KB
testcase_01 AC 49 ms
61,132 KB
testcase_02 AC 50 ms
61,132 KB
testcase_03 AC 107 ms
79,020 KB
testcase_04 AC 49 ms
63,180 KB
testcase_05 AC 51 ms
63,180 KB
testcase_06 AC 49 ms
63,180 KB
testcase_07 AC 49 ms
61,132 KB
testcase_08 AC 49 ms
63,180 KB
testcase_09 AC 48 ms
61,132 KB
testcase_10 AC 49 ms
63,180 KB
testcase_11 AC 49 ms
63,180 KB
testcase_12 AC 51 ms
63,180 KB
testcase_13 AC 50 ms
63,180 KB
testcase_14 AC 115 ms
78,800 KB
testcase_15 AC 121 ms
78,728 KB
testcase_16 AC 125 ms
78,728 KB
testcase_17 AC 117 ms
78,804 KB
testcase_18 AC 73 ms
73,088 KB
testcase_19 AC 106 ms
77,972 KB
testcase_20 AC 106 ms
77,972 KB
testcase_21 AC 71 ms
73,488 KB
testcase_22 AC 72 ms
73,476 KB
testcase_23 AC 72 ms
73,464 KB
testcase_24 AC 72 ms
73,492 KB
testcase_25 AC 72 ms
73,488 KB
testcase_26 AC 84 ms
78,444 KB
testcase_27 AC 85 ms
78,444 KB
testcase_28 AC 84 ms
78,444 KB
testcase_29 AC 85 ms
78,444 KB
testcase_30 AC 48 ms
61,132 KB
testcase_31 AC 48 ms
61,132 KB
testcase_32 AC 118 ms
79,004 KB
testcase_33 AC 122 ms
79,556 KB
testcase_34 AC 117 ms
79,112 KB
testcase_35 AC 127 ms
79,560 KB
testcase_36 AC 125 ms
79,736 KB
testcase_37 AC 121 ms
78,948 KB
testcase_38 AC 136 ms
79,472 KB
testcase_39 AC 130 ms
79,472 KB
testcase_40 AC 134 ms
79,472 KB
testcase_41 AC 124 ms
79,260 KB
testcase_42 AC 131 ms
80,000 KB
testcase_43 AC 156 ms
79,472 KB
testcase_44 AC 144 ms
79,532 KB
testcase_45 AC 153 ms
79,504 KB
testcase_46 AC 136 ms
79,736 KB
testcase_47 AC 121 ms
78,964 KB
testcase_48 AC 124 ms
79,196 KB
testcase_49 AC 135 ms
79,472 KB
testcase_50 AC 127 ms
79,296 KB
testcase_51 AC 150 ms
79,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# #sys.setrecursionlimit(1000000)
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
import itertools
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e30)
mod = int(1e9+7)

import heapq
def dijkstra(start,edge):
    # edge[i] = [(distance, j), ...]
    dist = [inf]*len(edge)
    dist[start] = 0
    q = [(0, start)]
    while q:
        # u から v に辺を張る
        cost, u = heapq.heappop(q)
        if dist[u] < cost:continue
        for ncost, v in edge[u]:
            if (dist[u]+ncost) < dist[v]:
                dist[v] = dist[u]+ncost
                heapq.heappush(q, (dist[v], v))
    return dist

h,w = mp()
u,d,r,l,K,p = mp()
sx,sy,gx,gy = mp()
sx -= 1
sy -= 1
gx -= 1
gy -= 1
start = sx*h+sy
goal = gx*h+gy
grid = [input() for i in range(h)]
edge = [[] for i in range(h*w)]
mx = [1,0,-1,0]
my = [0,1,0,-1]
c = [d, r, u, l]
for i in range(h):
    for j in range(w):
        for k in range(4):
            nx,ny = i+mx[k], j+my[k]
            if 0 <= nx < h and 0 <= ny < w:
                if grid[nx][ny] == "#":continue
                if grid[nx][ny] == "@":
                    cost = c[k] + p
                else:
                    cost = c[k]
                edge[i*h+j].append((cost,nx*h+ny))
ans = dijkstra(start,edge)[goal]
if ans <= K:print("Yes")
else:print("No")


0