結果

問題 No.2657 Falling Block Game
ユーザー ShirotsumeShirotsume
提出日時 2024-03-01 22:30:56
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,658 bytes
コンパイル時間 431 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 273,876 KB
最終ジャッジ日時 2024-03-01 22:31:01
合計ジャッジ時間 4,527 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
56,272 KB
testcase_01 AC 43 ms
56,272 KB
testcase_02 AC 45 ms
56,272 KB
testcase_03 AC 44 ms
56,272 KB
testcase_04 AC 130 ms
97,484 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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(j + 1, min(w, wall[0], j + l + 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)
0