結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2021-01-04 03:12:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,152 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 82,404 KB |
実行使用メモリ | 202,692 KB |
最終ジャッジ日時 | 2024-10-13 20:57:35 |
合計ジャッジ時間 | 33,393 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 27 WA * 5 |
ソースコード
from collections import dequeimport sysinput = sys.stdin.readlinesys.setrecursionlimit(10 ** 7)DX = (-1, 0, 1, 0, -1, -1, 1, 1)DY = (0, 1, 0, -1, -1, 1, -1, 1)DX = DX[:4]DY = DY[:4]H, W = map(int, input().split())A, sx, sy = map(int, input().split())B, gx, gy = map(int, input().split())sx += 1sy += 1gx += 1gy += 1G = [[0] * (W + 2) for _ in range(H + 2)]for i in range(1, H + 1):for j, x in enumerate(input().rstrip(), 1):if x == "*":G[i][j] = 1else:G[i][j] = -1U = 1000 + 50 * 50dist = [[[-1] * (U + 1) for _ in range(W + 2)] for _ in range(H + 2)]dist[sx][sy][A] = 0que = deque([(sx, sy, A)])while que:x, y, a = que.popleft()d = dist[x][y][a]for dx, dy in zip(DX, DY):nx = x + dxny = y + dyif G[x][y] == 1 and a < U and dist[nx][ny][a + 1] == -1:dist[nx][ny][a + 1] = d + 1que.append((nx, ny, a + 1))if G[x][y] == -1 and a and dist[nx][ny][a - 1] == -1:dist[nx][ny][a - 1] = d + 1que.append((nx, ny, a - 1))if dist[gx][gy][B] == -1:print("No")else:print("Yes")