結果

問題 No.1638 Robot Maze
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-08-06 23:42:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 709 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 76,952 KB
最終ジャッジ日時 2023-10-17 05:37:21
合計ジャッジ時間 4,661 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
55,520 KB
testcase_01 AC 32 ms
55,520 KB
testcase_02 AC 33 ms
55,520 KB
testcase_03 AC 56 ms
73,000 KB
testcase_04 AC 36 ms
55,520 KB
testcase_05 AC 34 ms
55,520 KB
testcase_06 AC 37 ms
55,520 KB
testcase_07 AC 38 ms
55,520 KB
testcase_08 AC 38 ms
55,520 KB
testcase_09 AC 39 ms
55,520 KB
testcase_10 AC 37 ms
55,520 KB
testcase_11 AC 37 ms
55,520 KB
testcase_12 AC 37 ms
55,520 KB
testcase_13 AC 35 ms
55,520 KB
testcase_14 AC 66 ms
76,164 KB
testcase_15 AC 51 ms
68,516 KB
testcase_16 AC 51 ms
68,516 KB
testcase_17 AC 52 ms
68,516 KB
testcase_18 AC 37 ms
55,520 KB
testcase_19 AC 52 ms
68,516 KB
testcase_20 AC 51 ms
68,516 KB
testcase_21 AC 56 ms
70,556 KB
testcase_22 AC 56 ms
70,552 KB
testcase_23 AC 55 ms
70,552 KB
testcase_24 AC 56 ms
70,556 KB
testcase_25 AC 56 ms
70,556 KB
testcase_26 AC 62 ms
72,676 KB
testcase_27 AC 59 ms
72,676 KB
testcase_28 AC 56 ms
72,676 KB
testcase_29 AC 53 ms
72,676 KB
testcase_30 AC 34 ms
55,520 KB
testcase_31 AC 33 ms
55,520 KB
testcase_32 AC 66 ms
76,164 KB
testcase_33 AC 111 ms
76,952 KB
testcase_34 AC 93 ms
76,496 KB
testcase_35 AC 94 ms
76,616 KB
testcase_36 AC 99 ms
76,576 KB
testcase_37 AC 77 ms
76,172 KB
testcase_38 AC 87 ms
76,212 KB
testcase_39 AC 100 ms
76,620 KB
testcase_40 AC 83 ms
76,344 KB
testcase_41 AC 99 ms
76,516 KB
testcase_42 AC 93 ms
76,604 KB
testcase_43 AC 79 ms
76,232 KB
testcase_44 AC 71 ms
76,196 KB
testcase_45 AC 71 ms
76,312 KB
testcase_46 AC 80 ms
76,232 KB
testcase_47 AC 67 ms
76,192 KB
testcase_48 AC 86 ms
76,224 KB
testcase_49 AC 71 ms
76,188 KB
testcase_50 AC 94 ms
76,588 KB
testcase_51 AC 71 ms
76,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
h,w = map(int,input().split())
u,d,r,l,k,p = map(int,input().split())
sx,sy,gx,gy = [int(x)-1 for x in input().split()]
need = [u,d,r,l]
dx = [-1,1,0,0]
dy = [0,0,1,-1]
C = [input() for i in range(h)]
inf = 10**20
cost = [[10**20]*w for i in range(h)]
cost[sx][sy] = 0
q = deque([[sx,sy]])
while q:
    x,y = q.popleft()
    for i,j,c in zip(dx,dy,need):
        nx = x+i
        ny = y+j
        if 0 <= nx < h and 0 <= ny < w and C[nx][ny] != "#":
            base = cost[x][y]+c+p*(C[nx][ny]=="@")
            if base < cost[nx][ny]:
                cost[nx][ny] = base
                q.append([nx,ny])

ans = cost[gx][gy]
if ans <= k:
    print("Yes")
else:
    print("No")
0