結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2020-03-21 12:19:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,123 ms / 5,000 ms |
コード長 | 996 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 256,996 KB |
最終ジャッジ日時 | 2024-12-21 13:22:33 |
合計ジャッジ時間 | 18,660 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines H, W = map(int, readline().split()) A, Sx, Sy = map(int, readline().split()) B, Gx, Gy = map(int, readline().split()) M = ''.join(read().decode().split()) S = Sx * W + Sy G = Gx * W + Gy N = H * W start = A * N + S goal = B * N + G stack = [start] visited = set([start]) while stack: v = stack.pop() size, xy = divmod(v, N) x, y = divmod(xy, W) for dx, dy in ((1, 0), (0, 1), (-1, 0), (0, -1)): x1 = x + dx y1 = y + dy if not ((0 <= x1 < H) and (0 <= y1 < W)): continue xy1 = x1 * W + y1 size1 = size - 1 + 2 * (M[xy1] == '*') if not size1: continue if size1 > 1500: continue v1 = size1 * N + xy1 if v1 in visited: continue visited.add(v1) stack.append(v1) print('Yes' if goal in visited else 'No')