結果

問題 No.1638 Robot Maze
ユーザー qibqib
提出日時 2022-12-07 19:43:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,000 KB
実行使用メモリ 78,896 KB
最終ジャッジ日時 2024-04-22 01:42:08
合計ジャッジ時間 6,726 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,348 KB
testcase_01 AC 42 ms
53,260 KB
testcase_02 AC 40 ms
53,692 KB
testcase_03 AC 97 ms
76,996 KB
testcase_04 AC 43 ms
54,744 KB
testcase_05 AC 42 ms
53,492 KB
testcase_06 AC 41 ms
54,460 KB
testcase_07 AC 41 ms
53,064 KB
testcase_08 AC 42 ms
54,428 KB
testcase_09 AC 42 ms
53,624 KB
testcase_10 AC 42 ms
53,928 KB
testcase_11 AC 42 ms
53,288 KB
testcase_12 AC 42 ms
54,196 KB
testcase_13 AC 43 ms
53,960 KB
testcase_14 AC 99 ms
77,360 KB
testcase_15 AC 108 ms
78,360 KB
testcase_16 AC 111 ms
77,892 KB
testcase_17 AC 115 ms
77,884 KB
testcase_18 AC 53 ms
68,360 KB
testcase_19 AC 92 ms
77,320 KB
testcase_20 AC 92 ms
77,300 KB
testcase_21 AC 64 ms
73,664 KB
testcase_22 AC 64 ms
73,292 KB
testcase_23 AC 64 ms
73,424 KB
testcase_24 AC 66 ms
73,284 KB
testcase_25 AC 64 ms
74,216 KB
testcase_26 AC 97 ms
77,728 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 93 ms
77,288 KB
testcase_30 AC 42 ms
54,708 KB
testcase_31 AC 41 ms
53,700 KB
testcase_32 AC 109 ms
77,244 KB
testcase_33 AC 149 ms
78,448 KB
testcase_34 AC 122 ms
78,412 KB
testcase_35 AC 170 ms
78,896 KB
testcase_36 AC 131 ms
78,356 KB
testcase_37 AC 110 ms
77,496 KB
testcase_38 AC 114 ms
77,184 KB
testcase_39 AC 117 ms
78,092 KB
testcase_40 AC 159 ms
78,656 KB
testcase_41 AC 123 ms
78,004 KB
testcase_42 AC 135 ms
78,340 KB
testcase_43 AC 155 ms
78,284 KB
testcase_44 AC 154 ms
78,488 KB
testcase_45 AC 141 ms
78,268 KB
testcase_46 AC 123 ms
77,932 KB
testcase_47 AC 110 ms
77,732 KB
testcase_48 AC 130 ms
78,012 KB
testcase_49 AC 139 ms
78,748 KB
testcase_50 AC 134 ms
77,984 KB
testcase_51 AC 140 ms
78,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

INF = 1 << 60

h, w = map(int, input().split())
u, d, r, l, k, p = map(int, input().split())
xs, ys, xt, yt = map(int, input().split())
xs -= 1
ys -= 1
xt -= 1
yt -= 1

c = [input() for _ in range(h)]
dist = [[[INF for _ in range(2)] for _ in range(w)] for _ in range(h)]
dist[xs][ys][0] = 0

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
cost = [[r, r + p], [u, u + p], [l, l + p], [r, r + p]]

hp = [(0, xs, ys, 0)]
while len(hp) > 0:
  cd, cx, cy, ci = heapq.heappop(hp)
  if dist[cx][cy][ci] < cd:
    continue
  for d in range(4):
    nx = cx + dx[d]
    if nx < 0 or nx >= h:
      continue
    ny = cy + dy[d]
    if ny < 0 or ny >= w:
      continue
    if c[nx][ny] == '#':
      continue
    ni = 1 if c[nx][ny] == '@' else 0

    if dist[nx][ny][ni] > dist[cx][cy][ci] + cost[d][ni]:
      dist[nx][ny][ni] = dist[cx][cy][ci] + cost[d][ni]
      heapq.heappush(hp, (dist[nx][ny][ni], nx, ny, ni))

ans = "Yes" if dist[xt][yt][0] <= k else "No"
print(ans)
0