結果

問題 No.1638 Robot Maze
ユーザー lloyzlloyz
提出日時 2023-08-06 20:58:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 78,720 KB
最終ジャッジ日時 2024-04-24 15:31:51
合計ジャッジ時間 4,534 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,352 KB
testcase_01 AC 39 ms
52,736 KB
testcase_02 AC 37 ms
52,352 KB
testcase_03 AC 95 ms
78,080 KB
testcase_04 AC 40 ms
52,864 KB
testcase_05 AC 39 ms
52,736 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 43 ms
53,120 KB
testcase_09 AC 38 ms
52,992 KB
testcase_10 AC 39 ms
53,248 KB
testcase_11 AC 39 ms
52,864 KB
testcase_12 AC 40 ms
52,736 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 98 ms
77,696 KB
testcase_16 AC 110 ms
77,696 KB
testcase_17 WA -
testcase_18 AC 53 ms
68,864 KB
testcase_19 AC 83 ms
77,440 KB
testcase_20 AC 85 ms
77,568 KB
testcase_21 AC 51 ms
67,840 KB
testcase_22 AC 52 ms
68,224 KB
testcase_23 WA -
testcase_24 AC 53 ms
68,096 KB
testcase_25 AC 54 ms
68,352 KB
testcase_26 AC 60 ms
70,656 KB
testcase_27 AC 56 ms
68,608 KB
testcase_28 AC 54 ms
68,608 KB
testcase_29 AC 60 ms
68,480 KB
testcase_30 WA -
testcase_31 AC 38 ms
52,608 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 93 ms
77,696 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 53 ms
67,840 KB
testcase_43 AC 55 ms
67,840 KB
testcase_44 AC 53 ms
67,968 KB
testcase_45 AC 54 ms
67,840 KB
testcase_46 AC 54 ms
67,968 KB
testcase_47 AC 55 ms
67,840 KB
testcase_48 AC 53 ms
68,224 KB
testcase_49 AC 53 ms
68,224 KB
testcase_50 AC 52 ms
67,840 KB
testcase_51 AC 53 ms
67,968 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(2)] for _ in range(w)] for _ in range(h)]
Directions = [(-1, 0), (1, 0), (0, 1), (-1, 0)]
C = [u, d, r, l]
DP[si][sj][0] = 0
H = [(0, si, sj, 0)]
while H:
    cc, ci, cj, ck = heappop(H)
    if cc > DP[ci][cj][ck]:
        continue
    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
                nk = 1
            else:
                nk = 0
            nc += C[i]
            if nc >= DP[ni][nj][nk]:
                continue
            DP[ni][nj][nk] = nc
            heappush(H, (nc, ni, nj, nk))
if DP[ti][tj][0] == k + 1:
    print("No")
else:
    print("Yes")
0