結果
| 問題 |
No.1638 Robot Maze
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-11 22:31:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 130 ms / 2,000 ms |
| コード長 | 678 bytes |
| コンパイル時間 | 302 ms |
| コンパイル使用メモリ | 82,136 KB |
| 実行使用メモリ | 78,436 KB |
| 最終ジャッジ日時 | 2024-09-25 08:28:05 |
| 合計ジャッジ時間 | 5,565 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 49 |
ソースコード
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')