結果
問題 | No.323 yuki国 |
ユーザー |
![]() |
提出日時 | 2023-09-29 12:07:21 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,850 ms / 5,000 ms |
コード長 | 826 bytes |
コンパイル時間 | 258 ms |
コンパイル使用メモリ | 81,964 KB |
実行使用メモリ | 387,040 KB |
最終ジャッジ日時 | 2024-07-22 06:29:24 |
合計ジャッジ時間 | 36,748 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 32 |
ソースコード
from collections import * H, W = map(int, input().split()) A, sx, sy = map(int, input().split()) B, gx, gy = map(int, input().split()) G = [] for i in range(H): G.append(list(input())) Q = deque() Q.append((sx, sy, A)) dx = [1, 0, -1, 0] dy = [0, 1, 0, -1] M = 1200 S = set() S.add((sx, sy, A)) while Q: px, py, c = Q.popleft() for k in range(4): x = px + dx[k] y = py + dy[k] if x < 0 or x > H - 1 or y < 0 or y > W - 1: continue if G[x][y] == "*": nc = c + 1 else: nc = c - 1 if nc <= 0 or nc >= M: continue if (x, y, nc) in S: continue S.add((x, y, nc)) Q.append((x, y, nc)) if B == nc and x == gx and y == gy: print("Yes") exit() print("No")