結果

問題 No.1638 Robot Maze
ユーザー lloyzlloyz
提出日時 2023-08-06 21:38:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-04-24 16:08:05
合計ジャッジ時間 5,047 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,608 KB
testcase_01 AC 43 ms
52,736 KB
testcase_02 AC 41 ms
52,608 KB
testcase_03 AC 92 ms
76,544 KB
testcase_04 AC 41 ms
52,608 KB
testcase_05 AC 40 ms
52,608 KB
testcase_06 AC 41 ms
52,992 KB
testcase_07 AC 43 ms
52,864 KB
testcase_08 AC 41 ms
52,736 KB
testcase_09 AC 43 ms
52,992 KB
testcase_10 AC 43 ms
52,992 KB
testcase_11 AC 43 ms
52,736 KB
testcase_12 AC 43 ms
52,864 KB
testcase_13 AC 41 ms
52,864 KB
testcase_14 AC 85 ms
72,448 KB
testcase_15 AC 81 ms
71,808 KB
testcase_16 AC 79 ms
71,680 KB
testcase_17 AC 92 ms
76,928 KB
testcase_18 AC 48 ms
59,264 KB
testcase_19 AC 73 ms
69,248 KB
testcase_20 AC 74 ms
69,632 KB
testcase_21 AC 46 ms
58,880 KB
testcase_22 AC 59 ms
64,256 KB
testcase_23 AC 58 ms
64,512 KB
testcase_24 AC 57 ms
64,000 KB
testcase_25 AC 62 ms
64,128 KB
testcase_26 AC 69 ms
68,096 KB
testcase_27 AC 69 ms
67,200 KB
testcase_28 AC 70 ms
68,992 KB
testcase_29 AC 67 ms
68,224 KB
testcase_30 AC 42 ms
52,736 KB
testcase_31 AC 42 ms
52,352 KB
testcase_32 AC 103 ms
76,672 KB
testcase_33 AC 121 ms
77,056 KB
testcase_34 AC 109 ms
77,056 KB
testcase_35 AC 109 ms
76,928 KB
testcase_36 AC 112 ms
77,040 KB
testcase_37 AC 107 ms
76,928 KB
testcase_38 AC 49 ms
58,752 KB
testcase_39 AC 119 ms
76,800 KB
testcase_40 AC 125 ms
77,124 KB
testcase_41 AC 112 ms
77,312 KB
testcase_42 AC 50 ms
58,624 KB
testcase_43 AC 49 ms
59,008 KB
testcase_44 AC 48 ms
58,880 KB
testcase_45 AC 49 ms
59,008 KB
testcase_46 AC 49 ms
58,752 KB
testcase_47 AC 48 ms
58,624 KB
testcase_48 AC 50 ms
58,624 KB
testcase_49 AC 50 ms
59,520 KB
testcase_50 AC 49 ms
58,624 KB
testcase_51 AC 46 ms
58,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush

h, w = map(int, input().split())
u, d, r, l, k, p = map(int, input().split())
si, sj, ti, tj = map(int, input().split())
si -= 1
sj -= 1
ti -= 1
tj -= 1
S = [list(input()) for _ in range(h)]

DP = [[k + 1 for _ in range(w)] for _ in range(h)]
Directions = [(-1, 0), (1, 0), (0, 1), (0, -1)]
C = [u, d, r, l]
DP[si][sj] = 0
H = [(0, si, sj)]
while H:
    cc, ci, cj = heappop(H)
    for i in range(4):
        nc = cc
        di, dj = Directions[i]
        ni, nj = ci + di, cj + dj
        if 0 <= ni < h and 0 <= nj < w:
            if S[ni][nj] == '#':
                continue
            elif S[ni][nj] == '@':
                nc += p
            nc += C[i]
            if nc >= DP[ni][nj]:
                continue
            DP[ni][nj] = nc
            heappush(H, (nc, ni, nj))
if DP[ti][tj] == k + 1:
    print("No")
else:
    print("Yes")
0