結果
問題 |
No.2657 Falling Block Game
|
ユーザー |
|
提出日時 | 2024-03-01 22:31:57 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,662 bytes |
コンパイル時間 | 339 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 272,400 KB |
最終ジャッジ日時 | 2024-09-29 14:32:48 |
合計ジャッジ時間 | 4,360 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 1 -- * 34 |
ソースコード
import sys, time, random from collections import deque, Counter, defaultdict input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 h, w = mi() s = [input() for _ in range(h)] def check(start, l): reachable = [[False] * w for _ in range(h)] visit = [[False] * w for _ in range(h)] reachable[0][start] = True visit[0][start] = True for i in range(h - 1): wall = deque() bwall = -1 for j in range(w): if s[i][j] == '#': wall.append(j) wall.append(w) for j in range(w): if s[i][j] == '#': bwall = j wall.popleft() if not reachable[i][j]: continue if s[i + 1][j] == '.': reachable[i + 1][j] = True for k in range(max(0, bwall + 1, j - l), j + 1): if visit[i][k]: break visit[i][k] = True if s[i + 1][k] == '.': reachable[i + 1][k] = True for k in range(min(w, wall[0], j + l + 1) - 1, j, -1): if visit[i][k]: break visit[i][k] = True if s[i + 1][k] == '.': reachable[i + 1][k] = True if any(reachable[-1]): return True return False for i in range(w): ok = w + 1 ng = -1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if check(i, mid): ok = mid else: ng = mid print(ok)