結果

問題 No.1638 Robot Maze
ユーザー puznekopuzneko
提出日時 2021-12-02 23:38:48
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 2,228 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 86,260 KB
実行使用メモリ 80,392 KB
最終ジャッジ日時 2023-09-18 11:07:15
合計ジャッジ時間 10,806 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,304 KB
testcase_01 AC 75 ms
71,232 KB
testcase_02 AC 75 ms
71,084 KB
testcase_03 WA -
testcase_04 AC 75 ms
71,088 KB
testcase_05 AC 75 ms
71,084 KB
testcase_06 AC 76 ms
71,140 KB
testcase_07 AC 77 ms
71,084 KB
testcase_08 AC 77 ms
71,080 KB
testcase_09 AC 77 ms
71,260 KB
testcase_10 AC 76 ms
70,892 KB
testcase_11 AC 75 ms
71,196 KB
testcase_12 AC 77 ms
71,176 KB
testcase_13 AC 76 ms
71,204 KB
testcase_14 AC 119 ms
78,712 KB
testcase_15 WA -
testcase_16 AC 167 ms
79,844 KB
testcase_17 AC 91 ms
76,252 KB
testcase_18 AC 136 ms
78,804 KB
testcase_19 AC 81 ms
75,988 KB
testcase_20 AC 84 ms
75,568 KB
testcase_21 AC 84 ms
75,796 KB
testcase_22 AC 166 ms
79,168 KB
testcase_23 AC 200 ms
80,180 KB
testcase_24 AC 84 ms
76,172 KB
testcase_25 AC 83 ms
76,184 KB
testcase_26 AC 169 ms
79,524 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 183 ms
78,760 KB
testcase_30 AC 77 ms
71,120 KB
testcase_31 AC 77 ms
71,204 KB
testcase_32 AC 166 ms
78,564 KB
testcase_33 AC 170 ms
78,728 KB
testcase_34 WA -
testcase_35 AC 203 ms
79,796 KB
testcase_36 AC 87 ms
75,568 KB
testcase_37 AC 193 ms
80,128 KB
testcase_38 AC 83 ms
75,988 KB
testcase_39 WA -
testcase_40 AC 175 ms
78,792 KB
testcase_41 AC 188 ms
80,220 KB
testcase_42 AC 146 ms
78,728 KB
testcase_43 AC 198 ms
80,392 KB
testcase_44 AC 157 ms
78,208 KB
testcase_45 AC 111 ms
78,360 KB
testcase_46 AC 85 ms
75,912 KB
testcase_47 AC 176 ms
79,648 KB
testcase_48 AC 84 ms
75,644 KB
testcase_49 AC 132 ms
78,756 KB
testcase_50 AC 163 ms
79,152 KB
testcase_51 AC 83 ms
75,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
from heapq import heappush, heappop

h, w = [int(x) for x in stdin.readline().rstrip().split()]
u, d, r, l, k, p = [int(x) for x in stdin.readline().rstrip().split()]
xs, ys, xt, yt = [int(x) for x in stdin.readline().rstrip().split()]
c = [stdin.readline().rstrip() for _ in range(h)]

kabe = ["@" for i in range(w+2)]
data = [kabe]
for i in range(h):
    kari = ["@"]
    for j in range(w):
        kari.append(c[i][j])
    kari.append("@")
    data.append(kari)
data.append(kabe)

hq = [(0,xs,ys)]
infty = 10**18
dist = [[infty for i in range(w+2)] for j in range(h+2)]
done = [[False for i in range(w+2)] for j in range(h+2)]
dist[xs][ys] = 0
while hq:
    cost, nowx, nowy = heappop(hq)
    if not done[nowx][nowy]:
        if (nowx == xt) & (nowy == yt):
            if cost <= k:
                print("Yes")
            else:
                print("No")
            exit()
        done[nowx][nowy] = True
        if (data[nowx-1][nowy] != "@") & (not done[nowx-1][nowy]):
            nextcost = cost + u
            if data[nowx-1][nowy] == "#":
                nextcost += p
            if (dist[nowx-1][nowy] > nextcost):
                dist[nowx-1][nowy] = nextcost
                heappush(hq, (nextcost, nowx-1, nowy))
        if (data[nowx+1][nowy] != "@") & (not done[nowx+1][nowy]):
            nextcost = cost + d
            if data[nowx+1][nowy] == "#":
                nextcost += p
            if (dist[nowx+1][nowy] > nextcost):
                dist[nowx+1][nowy] = nextcost
                heappush(hq, (nextcost, nowx+1, nowy))
        if (data[nowx][nowy-1] != "@") & (not done[nowx][nowy-1]):
            nextcost = cost + l
            if data[nowx][nowy-1] == "#":
                nextcost += p
            if (dist[nowx][nowy-1] > nextcost):
                dist[nowx][nowy-1] = nextcost
                heappush(hq, (nextcost, nowx, nowy-1))
        if (data[nowx][nowy+1] != "@") & (not done[nowx][nowy+1]):
            nextcost = cost + r
            if data[nowx][nowy+1] == "#":
                nextcost += p
            if (dist[nowx][nowy+1] > nextcost):
                dist[nowx][nowy+1] = nextcost
                heappush(hq, (nextcost, nowx, nowy+1))

print("No")
0