結果
問題 | 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 dequeH,W = map(int,input().split())U,D,R,L,K,P = map(int,input().split())sx,sy,tx,ty = map(int,input().split())sx -= 1sy -= 1tx -= 1ty -= 1C = [list(str(input())) for _ in range(H)]move = [(-1,0,U),(1,0,D),(0,1,R),(0,-1,L)]INF = 10**18que = deque([(sx,sy,0)])seem = [[INF]*W for _ in range(H)]seem[sx][sy] = 0while que:x,y,c = que.popleft()for i,j,n in move:h,w = x+i,y+jif 0 <= h < H and 0 <= w < W:if C[h][w] == '#':continueif C[h][w] == '@':n += Pif seem[h][w] > c+n:seem[h][w] = c+nque.append((h,w,c+n))if seem[tx][ty] <= K:print('Yes')else:print('No')