結果

問題 No.2657 Falling Block Game
ユーザー ゼットゼット
提出日時 2024-03-01 22:50:21
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,013 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 92,764 KB
最終ジャッジ日時 2024-03-01 22:51:08
合計ジャッジ時間 10,108 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 AC 40 ms
53,460 KB
testcase_02 AC 40 ms
53,460 KB
testcase_03 AC 40 ms
53,460 KB
testcase_04 AC 124 ms
79,976 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 1,713 ms
81,028 KB
testcase_09 AC 644 ms
81,332 KB
testcase_10 AC 1,490 ms
92,076 KB
testcase_11 AC 1,477 ms
92,136 KB
testcase_12 AC 1,609 ms
91,696 KB
testcase_13 AC 1,459 ms
92,052 KB
testcase_14 AC 1,493 ms
92,348 KB
testcase_15 AC 1,464 ms
92,268 KB
testcase_16 AC 1,443 ms
91,972 KB
testcase_17 AC 1,438 ms
92,168 KB
testcase_18 AC 1,510 ms
92,764 KB
testcase_19 AC 1,487 ms
92,636 KB
testcase_20 AC 1,287 ms
82,364 KB
testcase_21 AC 1,287 ms
82,104 KB
testcase_22 AC 1,362 ms
82,624 KB
testcase_23 AC 1,286 ms
82,516 KB
testcase_24 AC 1,230 ms
82,320 KB
testcase_25 AC 1,289 ms
82,168 KB
testcase_26 AC 1,295 ms
82,416 KB
testcase_27 AC 1,252 ms
82,252 KB
testcase_28 AC 1,285 ms
82,352 KB
testcase_29 AC 1,288 ms
81,984 KB
testcase_30 AC 796 ms
82,544 KB
testcase_31 AC 816 ms
82,268 KB
testcase_32 AC 780 ms
82,332 KB
testcase_33 AC 814 ms
82,776 KB
testcase_34 AC 774 ms
82,140 KB
testcase_35 AC 805 ms
82,492 KB
testcase_36 AC 798 ms
82,332 KB
testcase_37 AC 752 ms
82,080 KB
testcase_38 AC 769 ms
82,128 KB
testcase_39 AC 733 ms
82,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class segtreemin:
  def __init__(self,n):
    self.size=1
    while self.size<n:
      self.size*=2
    self.dat=[10**10]*(self.size*2)
  def update(self,x,a):
    x+=self.size
    self.dat[x]=a
    while x>1:
      x//=2
      self.dat[x]=min(self.dat[2*x],self.dat[2*x+1])
  def querry(self,u,v):
    u+=self.size
    v+=self.size
    score=10**10
    while u<v:
      if u&1:
        score=min(score,self.dat[u])
        u+=1
      if v&1:
        v-=1
        score=min(score,self.dat[v])
      u//=2
      v//=2
    return score
class segtreemax:
  def __init__(self,n):
    self.size=1
    while self.size<n:
      self.size*=2
    self.dat=[0]*(self.size*2)
  def update(self,x,a):
    x+=self.size
    self.dat[x]=a
    while x>1:
      x//=2
      self.dat[x]=max(self.dat[2*x],self.dat[2*x+1])
  def querry(self,u,v):
    u+=self.size
    v+=self.size
    score=0
    while u<v:
      if u&1:
        score=max(score,self.dat[u])
        u+=1
      if v&1:
        v-=1
        score=max(score,self.dat[v])
      u//=2
      v//=2
    return score
H,W=map(int,input().split())
A=[input() for i in range(H)]
dp=[0]*W
from bisect import bisect_left
Z=segtreemin(W)
for i in range(W):
  Z.update(i,0)
for i in range(H-2,-1,-1):
  dp2=[10**10]*W
  L=[-1]
  for j in range(W):
    if A[i][j]=='#':
      L.append(j)
  L.append(W)
  for j in range(W):
    if A[i][j]=='#':
      continue
    pos=bisect_left(L,j)
    a=L[pos-1]
    b=L[pos]
    ans=10**10
    l=0
    r=W-1
    while True:
      if l==r:
        break
      m=(l+r)//2
      y=j+m
      if y>=b:
        y=b-1
      score=Z.querry(j,y+1)
      if score<=m:
        r=m
      else:
        l=m+1
    ans=min(ans,l)
    l=0
    r=W-1
    while True:
      if l==r:
        break
      m=(l+r)//2
      y=j-m
      if y<=a:
        y=a+1
      score=Z.querry(y,j+1)
      if score<=m:
        r=m
      else:
        l=m+1
    ans=min(ans,l)
    dp2[j]=ans
  dp=dp2[:]
  for j in range(W):
    Z.update(j,dp[j])
for i in range(W):
  print(dp[i])
0