結果

問題 No.1638 Robot Maze
コンテスト
ユーザー O2MT
提出日時 2021-08-11 22:31:21
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 678 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 190 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 83,640 KB
最終ジャッジ日時 2026-04-12 13:03:22
合計ジャッジ時間 4,731 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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