結果

問題 No.1638 Robot Maze
ユーザー titiatitia
提出日時 2021-08-06 21:34:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 790 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,608 KB
最終ジャッジ日時 2023-10-17 02:51:49
合計ジャッジ時間 4,000 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,172 KB
testcase_01 AC 29 ms
10,172 KB
testcase_02 AC 29 ms
10,172 KB
testcase_03 AC 73 ms
10,560 KB
testcase_04 AC 30 ms
10,172 KB
testcase_05 AC 29 ms
10,172 KB
testcase_06 AC 29 ms
10,172 KB
testcase_07 AC 29 ms
10,172 KB
testcase_08 AC 30 ms
10,172 KB
testcase_09 AC 30 ms
10,172 KB
testcase_10 AC 30 ms
10,172 KB
testcase_11 AC 29 ms
10,172 KB
testcase_12 AC 31 ms
10,172 KB
testcase_13 AC 30 ms
10,172 KB
testcase_14 AC 53 ms
10,416 KB
testcase_15 AC 41 ms
10,324 KB
testcase_16 AC 42 ms
10,324 KB
testcase_17 AC 41 ms
10,324 KB
testcase_18 AC 30 ms
10,236 KB
testcase_19 AC 42 ms
10,344 KB
testcase_20 AC 42 ms
10,344 KB
testcase_21 AC 48 ms
10,448 KB
testcase_22 AC 47 ms
10,392 KB
testcase_23 AC 47 ms
10,392 KB
testcase_24 AC 49 ms
10,448 KB
testcase_25 AC 49 ms
10,448 KB
testcase_26 AC 47 ms
10,392 KB
testcase_27 AC 47 ms
10,392 KB
testcase_28 AC 47 ms
10,392 KB
testcase_29 AC 47 ms
10,392 KB
testcase_30 AC 30 ms
10,172 KB
testcase_31 AC 29 ms
10,172 KB
testcase_32 AC 58 ms
10,476 KB
testcase_33 AC 63 ms
10,548 KB
testcase_34 AC 68 ms
10,528 KB
testcase_35 AC 63 ms
10,560 KB
testcase_36 AC 71 ms
10,532 KB
testcase_37 AC 60 ms
10,476 KB
testcase_38 AC 60 ms
10,468 KB
testcase_39 AC 68 ms
10,520 KB
testcase_40 AC 60 ms
10,492 KB
testcase_41 AC 64 ms
10,544 KB
testcase_42 AC 65 ms
10,524 KB
testcase_43 AC 65 ms
10,496 KB
testcase_44 AC 67 ms
10,496 KB
testcase_45 AC 65 ms
10,492 KB
testcase_46 AC 69 ms
10,516 KB
testcase_47 AC 62 ms
10,488 KB
testcase_48 AC 69 ms
10,532 KB
testcase_49 AC 61 ms
10,472 KB
testcase_50 AC 67 ms
10,608 KB
testcase_51 AC 71 ms
10,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
import heapq

H,W=map(int,input().split())
U,D,R,L,K,P=map(int,input().split())
xs,ys,xt,yt=map(int,input().split())

MAP=[input().strip() for i in range(H)]
DP=[[1<<60]*W for i in range(H)]

xs-=1
xt-=1
ys-=1
yt-=1

Q=[(0,xs,ys)]

while Q:
    cost,x,y=heapq.heappop(Q)

    if cost>DP[x][y]:
        continue

    for z,w,cp in [(x+1,y,D),(x-1,y,U),(x,y+1,R),(x,y-1,L)]:
        if 0<=z<H and 0<=w<W:
            if MAP[z][w]=="." and DP[z][w]>cost+cp:
                DP[z][w]=cost+cp
                heapq.heappush(Q,(cost+cp,z,w))
            elif MAP[z][w]=="@" and DP[z][w]>cost+cp+P:
                DP[z][w]=cost+cp+P
                heapq.heappush(Q,(cost+cp+P,z,w))

if DP[xt][yt]<=K:
    print("Yes")
else:
    print("No")
                
0