結果

問題 No.1638 Robot Maze
ユーザー tcltktcltk
提出日時 2021-10-17 06:13:43
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,245 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 89,396 KB
最終ジャッジ日時 2023-10-17 22:23:52
合計ジャッジ時間 11,234 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
85,864 KB
testcase_01 AC 128 ms
85,864 KB
testcase_02 AC 131 ms
85,856 KB
testcase_03 AC 220 ms
88,848 KB
testcase_04 AC 131 ms
85,868 KB
testcase_05 AC 134 ms
85,864 KB
testcase_06 AC 129 ms
85,860 KB
testcase_07 AC 130 ms
85,860 KB
testcase_08 WA -
testcase_09 AC 131 ms
85,860 KB
testcase_10 AC 131 ms
85,872 KB
testcase_11 AC 132 ms
85,868 KB
testcase_12 WA -
testcase_13 AC 132 ms
85,868 KB
testcase_14 WA -
testcase_15 AC 184 ms
88,740 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 129 ms
85,860 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 161 ms
88,668 KB
testcase_22 AC 163 ms
88,660 KB
testcase_23 WA -
testcase_24 AC 164 ms
88,668 KB
testcase_25 AC 163 ms
88,668 KB
testcase_26 WA -
testcase_27 AC 173 ms
88,692 KB
testcase_28 AC 170 ms
88,700 KB
testcase_29 WA -
testcase_30 AC 131 ms
85,860 KB
testcase_31 AC 130 ms
85,864 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 213 ms
89,092 KB
testcase_35 AC 177 ms
88,664 KB
testcase_36 WA -
testcase_37 AC 185 ms
88,688 KB
testcase_38 WA -
testcase_39 AC 219 ms
89,260 KB
testcase_40 AC 225 ms
89,052 KB
testcase_41 AC 240 ms
89,380 KB
testcase_42 AC 235 ms
89,292 KB
testcase_43 AC 225 ms
89,136 KB
testcase_44 AC 207 ms
89,032 KB
testcase_45 AC 259 ms
89,396 KB
testcase_46 AC 243 ms
89,384 KB
testcase_47 AC 250 ms
89,312 KB
testcase_48 AC 219 ms
89,184 KB
testcase_49 AC 232 ms
89,104 KB
testcase_50 AC 210 ms
88,996 KB
testcase_51 AC 216 ms
89,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """2 2
# 0 0 0 0 1 1
# 1 1 2 2
# .@
# #.
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**20

YES = 'Yes'
NO = 'No'

def solve():
    dist = [[INF] * W for _ in range(H)]

    hq = []
    dist[StartY][StartX] = 0
    heapq.heappush(hq, (0, StartX, StartY))
    while hq:
        d, x, y = heapq.heappop(hq)
        if (x, y) == (GoalX, GoalY):
            return d
        for x1, y1, d1 in [(x-1, y, d+L), (x+1, y, d+R), (x, y-1, U), (x, y+1, D)]:
            if not(0 <= x1 < W and 0 <= y1 < H) or C[y1][x1] == '#':
                continue
            elif C[y1][x1] == '@':
                d1 += P
            if d1 < dist[y1][x1]:
                dist[y1][x1] = d1
                heapq.heappush(hq, (d1, x1, y1))
    return INF

H, W = map(int, input().split())
U, D, R, L, K, P = map(int, input().split())
StartX, StartY, GoalX, GoalY = map(lambda x: int(x)-1, input().split())
C = [input() for _ in range(H)]

cost = solve()
if cost <= K:
    print('Yes')
else:
    print('No')
0