結果

問題 No.2456 Stamp Art
ユーザー ゼットゼット
提出日時 2023-09-01 23:54:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,331 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 82,240 KB
実行使用メモリ 113,808 KB
最終ジャッジ日時 2024-06-11 06:13:25
合計ジャッジ時間 12,313 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,480 KB
testcase_01 AC 35 ms
52,480 KB
testcase_02 AC 33 ms
52,992 KB
testcase_03 AC 545 ms
112,152 KB
testcase_04 AC 38 ms
52,140 KB
testcase_05 WA -
testcase_06 AC 560 ms
112,428 KB
testcase_07 AC 317 ms
112,480 KB
testcase_08 AC 2,361 ms
113,808 KB
testcase_09 AC 544 ms
112,652 KB
testcase_10 AC 555 ms
112,280 KB
testcase_11 AC 563 ms
112,412 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 560 ms
112,672 KB
testcase_15 AC 547 ms
112,148 KB
testcase_16 AC 329 ms
94,920 KB
testcase_17 AC 65 ms
72,192 KB
testcase_18 AC 46 ms
63,104 KB
testcase_19 AC 408 ms
100,728 KB
testcase_20 WA -
testcase_21 AC 479 ms
109,596 KB
testcase_22 AC 489 ms
112,600 KB
testcase_23 AC 107 ms
78,712 KB
testcase_24 AC 125 ms
79,264 KB
testcase_25 AC 36 ms
52,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
S=[input() for i in range(H)]
v=[[0]*W for i in range(H)]
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      v[i][j]+=1
for i in range(H):
  for j in range(1,W):
    v[i][j]=v[i][j-1]+v[i][j]
for i in range(1,H):
  for j in range(W):
    v[i][j]=v[i-1][j]+v[i][j]
result=10**10
DX=[1,1,-1,-1]
DY=[1,-1,1,-1]
for i in range(H):
  for j in range(W):
    if S[i][j]=='.':
      continue
    for dx,dy in zip(DX,DY):
      x=i-dx
      y=j-dy
      t=0
      if x<0 or x>=H:
        t+=1
      else:
        if S[x][j]=='.':
          t+=1
      if y<0 or y>=W:
        t+=1
      else:
        if S[i][y]=='.':
          t+=1
      if t==2:
        l=1
        r=2000
        while True:
          m=(l+r+1)//2
          i2,j2=i+dx*(m-1),j+dy*(m-1)
          if i2<0 or i2>=H or j2<0 or j2>=W:
            r=m-1
          else:
            j3=max(j,j2)
            j4=min(j,j2)
            i3=max(i,i2)
            i4=min(i,i2)
            ans=v[i3][j3]
            if j4>0:
              ans-=v[i3][j4-1]
            if i4>0:
              ans-=v[i4-1][j3]
            if i4>0 and j4>0:
              ans+=v[i4-1][j4-1]
            if ans==m**2:
              l=m
            else:
              r=m-1
          if l==r:
            break
        result=min(result,l)
print(result)
      
0