結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-17 06:28:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,375 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 82,272 KB |
| 実行使用メモリ | 710,848 KB |
| 最終ジャッジ日時 | 2024-09-17 19:37:38 |
| 合計ジャッジ時間 | 4,262 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | MLE * 1 -- * 48 |
ソースコード
#!/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 = """3 3
# 1 1 1 1 8 16
# 1 1 3 1
# ..@
# ##@
# ..@
# """
# sys.stdin = io.StringIO(_INPUT)
INF = 10**20
YES = 'Yes'
NO = 'No'
def solve():
dist = [[[INF] * W for _ in range(H)] for _ in range(H*W+1)]
hq = []
dist[0][StartH][StartW] = 0
heapq.heappush(hq, (0, 0, StartH, StartW))
while hq:
d, n, i, j = heapq.heappop(hq)
for i1, j1, d1 in [(i-1, j, d+U), (i+1, j, d+D), (i, j-1, d+L), (i, j+1, d+R)]:
n1 = n
if not(0 <= i1 < H and 0 <= j1 < W) or C[i1][j1] == '#':
continue
elif C[i1][j1] == '@':
n1 += 1
if H*W < n1:
continue
if d1 < dist[n1][i1][j1]:
dist[n1][i1][j1] = d1
heapq.heappush(hq, (d1, n1, i1, j1))
return min(dist[n][GoalH][GoalW] + n*P for n in range(H*W+1))
H, W = map(int, input().split())
U, D, R, L, K, P = map(int, input().split())
StartH, StartW, GoalH, GoalW = map(lambda x: int(x)-1, input().split())
C = [input() for _ in range(H)]
cost = solve()
if cost <= K:
print('Yes')
else:
print('No')