結果
問題 | No.1638 Robot Maze |
ユーザー |
![]() |
提出日時 | 2021-08-06 21:51:34 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 192 ms / 2,000 ms |
コード長 | 1,267 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 82,116 KB |
実行使用メモリ | 77,924 KB |
最終ジャッジ日時 | 2024-09-17 01:46:14 |
合計ジャッジ時間 | 6,487 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 from heapq import * t = ".@#" h, w = LI() u, d, r, l, k, p = LI() si, sj, gi, gj = LI1() sij = si*w+sj gij = gi*w+gj cc = [t.index(c) for _ in range(h) for c in SI()] def push(ij, nc): if cc[ij] == 2: return if cc[ij] == 1: nc += p if nc >= dist[ij]: return dist[ij] = nc heappush(hp, (nc, ij)) dist = [inf]*h*w dist[sij] = 0 hp = [(0, sij)] while hp: c, ij = heappop(hp) if ij == gij: break if c > dist[ij]: continue i, j = divmod(ij, w) if i-1 >= 0: push(ij-w, c+u) if i+1 < h: push(ij+w, c+d) if j-1 >= 0: push(ij-1, c+l) if j+1 < w: push(ij+1, c+r) print("Yes" if dist[gij] <= k else "No")