結果

問題 No.1638 Robot Maze
ユーザー yudai1102jpyudai1102jp
提出日時 2021-08-06 22:57:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,607 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 81,620 KB
実行使用メモリ 80,748 KB
最終ジャッジ日時 2023-10-17 04:26:24
合計ジャッジ時間 8,906 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
60,376 KB
testcase_01 AC 36 ms
53,408 KB
testcase_02 AC 36 ms
53,408 KB
testcase_03 AC 1,858 ms
76,136 KB
testcase_04 AC 47 ms
62,128 KB
testcase_05 AC 47 ms
62,152 KB
testcase_06 AC 47 ms
62,148 KB
testcase_07 AC 47 ms
62,156 KB
testcase_08 AC 49 ms
64,208 KB
testcase_09 AC 47 ms
62,148 KB
testcase_10 AC 49 ms
62,160 KB
testcase_11 AC 49 ms
64,228 KB
testcase_12 AC 50 ms
64,228 KB
testcase_13 AC 47 ms
62,156 KB
testcase_14 AC 768 ms
75,744 KB
testcase_15 AC 132 ms
75,640 KB
testcase_16 AC 131 ms
75,640 KB
testcase_17 AC 122 ms
75,612 KB
testcase_18 AC 49 ms
64,212 KB
testcase_19 AC 133 ms
75,628 KB
testcase_20 AC 134 ms
75,628 KB
testcase_21 AC 50 ms
64,200 KB
testcase_22 AC 49 ms
64,208 KB
testcase_23 AC 49 ms
64,208 KB
testcase_24 AC 49 ms
64,200 KB
testcase_25 AC 51 ms
64,200 KB
testcase_26 AC 54 ms
64,228 KB
testcase_27 AC 55 ms
64,228 KB
testcase_28 AC 52 ms
64,228 KB
testcase_29 AC 53 ms
64,228 KB
testcase_30 AC 37 ms
53,408 KB
testcase_31 AC 37 ms
53,408 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)  # 再帰関数使う時有効


H, W = map(int, input().split())
U, D, R, L, K, P = map(int, input().split())
x, y, xt, yt = map(int, input().split())
start = [x-1, y-1]
goal = [xt-1, yt-1]
allow = [[1, 0], [0, 1], [-1, 0], [0, -1]]
allow_cost = [D, R, U, L]
C = [input() for i in range(H)]


# def fps(now, cost):

#     if now == goal:
#         return cost
#     ans = 10**13+8
#     for i in range(4):
#         nextx = now[0]+allow[i][0]
#         nexty = now[1]+allow[i][1]
#         if not (0 <= nextx < H and 0 <= nexty < W):
#             continue

#         if C[nextx][nexty] == '.':
#             new_cost = cost+allow_cost[i]
#         elif C[nextx][nexty] == '@':
#             new_cost = cost+allow_cost[i]+P
#         else:
#             continue
#         ans = min(ans, fps([nextx, nexty], new_cost))
#     return ans
dp = [[-1]*W for i in range(H)]
dp[start[0]][start[1]] = 0
q = [start]
while q:
    now = q.pop()
    for i in range(4):
        nextx = now[0]+allow[i][0]
        nexty = now[1]+allow[i][1]
        if not (0 <= nextx < H and 0 <= nexty < W):
            continue

        if C[nextx][nexty] == '.':
            new_cost = dp[now[0]][now[1]]+allow_cost[i]
        elif C[nextx][nexty] == '@':
            new_cost = dp[now[0]][now[1]]+allow_cost[i]+P
        else:
            continue
        if dp[nextx][nexty] == -1 or dp[nextx][nexty] > new_cost:
            dp[nextx][nexty] = new_cost
            q.append([nextx, nexty])

if dp[goal[0]][goal[1]] <= K and dp[goal[0]][goal[1]] != -1:
    print('Yes')
else:
    print('No')
0