結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2021-01-04 03:15:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,156 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 198,656 KB |
最終ジャッジ日時 | 2024-10-13 20:58:56 |
合計ジャッジ時間 | 32,206 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 29 WA * 3 |
ソースコード
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[nx][ny] == 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[nx][ny] == -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")