結果

問題 No.1638 Robot Maze
ユーザー O2MTO2MT
提出日時 2021-08-11 22:31:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 78,172 KB
最終ジャッジ日時 2023-10-26 00:28:59
合計ジャッジ時間 6,716 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,712 KB
testcase_01 AC 41 ms
55,712 KB
testcase_02 AC 42 ms
55,712 KB
testcase_03 AC 62 ms
66,380 KB
testcase_04 AC 41 ms
55,712 KB
testcase_05 AC 41 ms
55,712 KB
testcase_06 AC 42 ms
55,712 KB
testcase_07 AC 41 ms
55,712 KB
testcase_08 AC 41 ms
55,712 KB
testcase_09 AC 42 ms
55,712 KB
testcase_10 AC 41 ms
55,712 KB
testcase_11 AC 41 ms
55,712 KB
testcase_12 AC 43 ms
55,712 KB
testcase_13 AC 41 ms
55,712 KB
testcase_14 AC 68 ms
72,588 KB
testcase_15 AC 57 ms
66,380 KB
testcase_16 AC 56 ms
66,380 KB
testcase_17 AC 66 ms
70,556 KB
testcase_18 AC 43 ms
55,712 KB
testcase_19 AC 58 ms
66,380 KB
testcase_20 AC 57 ms
66,380 KB
testcase_21 AC 55 ms
66,360 KB
testcase_22 AC 55 ms
66,360 KB
testcase_23 AC 55 ms
66,360 KB
testcase_24 AC 56 ms
66,360 KB
testcase_25 AC 55 ms
66,360 KB
testcase_26 AC 56 ms
66,360 KB
testcase_27 AC 55 ms
66,360 KB
testcase_28 AC 55 ms
66,360 KB
testcase_29 AC 56 ms
66,360 KB
testcase_30 AC 41 ms
55,712 KB
testcase_31 AC 41 ms
55,712 KB
testcase_32 AC 71 ms
72,592 KB
testcase_33 AC 116 ms
76,728 KB
testcase_34 AC 134 ms
78,116 KB
testcase_35 AC 98 ms
76,788 KB
testcase_36 AC 116 ms
76,788 KB
testcase_37 AC 71 ms
72,612 KB
testcase_38 AC 89 ms
76,492 KB
testcase_39 AC 127 ms
78,172 KB
testcase_40 AC 93 ms
76,728 KB
testcase_41 AC 113 ms
76,728 KB
testcase_42 AC 110 ms
76,728 KB
testcase_43 AC 97 ms
76,728 KB
testcase_44 AC 101 ms
76,788 KB
testcase_45 AC 102 ms
76,728 KB
testcase_46 AC 107 ms
76,788 KB
testcase_47 AC 70 ms
72,612 KB
testcase_48 AC 115 ms
76,728 KB
testcase_49 AC 78 ms
74,132 KB
testcase_50 AC 125 ms
78,068 KB
testcase_51 AC 119 ms
78,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

H,W = map(int,input().split())
U,D,R,L,K,P = map(int,input().split())
sx,sy,tx,ty = map(int,input().split())
sx -= 1
sy -= 1
tx -= 1
ty -= 1
C = [list(str(input())) for _ in range(H)]
move = [(-1,0,U),(1,0,D),(0,1,R),(0,-1,L)]
INF = 10**18
que = deque([(sx,sy,0)])
seem = [[INF]*W for _ in range(H)]
seem[sx][sy] = 0

while que:
  x,y,c = que.popleft()
  for i,j,n in move:
    h,w = x+i,y+j
    if 0 <= h < H and 0 <= w < W:
      if C[h][w] == '#':
        continue
      if C[h][w] == '@':
        n += P
      if seem[h][w] > c+n:
        seem[h][w] = c+n
        que.append((h,w,c+n))

if seem[tx][ty] <= K:
  print('Yes')
else:
  print('No')
0