Problem:


Score : 400 points

Problem Statement

There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.

Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.
The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.
In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.

Snuke wants to maximize the number of squares lighted by the lamp.

You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.

Find the maximum possible number of squares lighted by the lamp.

Constraints

1 \leq H \leq 2,000

1 \leq W \leq 2,000

S_i is a string of length W consisting of # and ..

. occurs at least once in one of the strings S_i (1 \leq i \leq H).

Input

Input is given from Standard Input in the following format:

H W
S_1
:
S_H

Output

Print the maximum possible number of squares lighted by the lamp.

Sample Input 1

4 6
#..#..
.....#
....#.
#.#...

Sample Output 1

8

If Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.

Sample Input 2

8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#

Sample Output 2

13



Sample input:
4 6
#..#..
.....#
....#.
#.#...


Sample output:
8

Submission status: Wrong Answer

Solution code:
import subprocess
import gzip, base64, os
import stat

gz = b'H4sIACd4j10C/+19C3hTVbb/SdJHeDUB0VseSsEgRaS0UEqLoi0QOJEUKi2IjnhI05RW26STnEDxCbZVYqgyjtfxzp0H/5k7/udxr+Od/4yDjgMFlOIbURkeooyDemJFig+sOpC71t77pPucnFNg9Lvf9/++idKd9TtrP9baa6/9Otn7brd3gdViEdSPVbhaQMoytpzQ5Qzf7E+xAFYqDIK/44SxQhbQmRxfuVCuCftY0mpoZ3w2+JcB/0qtlC61lmvCsYxPDS1cmCnwn3JN6LpR0ISCkJeKh2U9sJK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3dKfbG7naOR3mLh3Xp18XCUkN0NOC8uhdwoZtDr0dG0J9i5ej6/0Wu4NYby3ay7310qVfi60XsTYS4SwidTN8WmWc03XR5eXcXcfpl1wbepG0G6/TE9HeCm6UCrYjsxSkFhAdxvnSrYF1zPOZ3m+vc73kSmitxv0G7vgb3P2ucweBUL3exFA8UndaqUj//o/dv67Lk/y8NM2szvn6c4OuehbfVRN9rTFzASZXyxvVMXc3vU4V5L1Bo0vl003pW7g83aCzNJCO9Xppzk9zYzk8Y1eHk8KVYFNoChh0ONzd8gajHno7vEEhwNYqJbC7W8GLwWTBwLxb1vXXfFFx+g3s+rFIY1Cgvu5/AFj8a6spjQAA'
bin = gzip.decompress(base64.b64decode(gz))
p = os.path.dirname(__file__)
pymain = os.path.join(p, "a.out")
with open(pymain, "wb") as f:
    f.write(bin)
os.chmod(pymain, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
if p == "":
    pymain = "./" + pymain
subprocess.call(pymain)


# compiled by pythran
'''
#pythran export main2()
h,w=map(int,input().split())
s=[]
l=[[0 for i in range(w)]for j in range(h)]
 
for i in range(h):
    a=input()
    s.append(a)

yoko=[[0 for j in range(w)] for j in range(h)]
tate=[[0 for j in range(w)] for j in range(h)]

for i in range(h):
    p=0
    for j in range(w):
        if s[i][j]=="#" or j==w-1:
            if s[i][j]==".":
                for k in range(p):
                    yoko[i][j-k-1]+=p+1
                yoko[i][j]+=p+1
            else:
                for k in range(p):
                    yoko[i][j-k-1]+=p
            p=0
        elif s[i][j]==".":
            p+=1
for i in range(w):
    p=0
    for j in range(h):
        if s[j][i]=="#" or j==h-1:
            if s[j][i]==".":
                for k in range(p):
                    tate[j-k-1][i]+=p+1
                yoko[j][i]+=p+1
            else:
                for k in range(p):
                    tate[j-k-1][i]+=p
            p=0
        elif s[j][i]==".":
            p+=1
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,yoko[i][j]+tate[i][j]-1)

print(ans)

'''

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
lists=[]
for i in range(h):
    s=input()
    lists.append(s)
ylists=[]
for some in lists:
    some=some+"#"
    cnt=0
    add=[]
    for i in range(w+1):
        if some[i]=="#":
            if cnt==0:
                add.append(0)
                cnt=0
            else:
                add.extend([cnt]*cnt)
                add.append(0)
                cnt=0
                
        elif some[i]!="#":
            cnt+=1
    del add[-1]
    ylists.append(add)

Submission status: Wrong Answer

Solution code:
h,w = map(int, input().split())
s = []
for i in range(h):
  s.append(input())

l = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if j == 0:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = 1
    else:
      if s[i][j] == '#':
        l[i][j] = 0
      else:
        l[i][j] = l[i][j-1] + 1

r = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w-1, 0, -1):
    if j == w-1:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = 1
    else:
      if s[i][j] == '#':
        r[i][j] = 0
      else:
        r[i][j] = r[i][j+1] + 1

u = [[0 for i in range(w)] for j in range(h)]
for j in range(w):
  for i in range(h):
    if i == 0:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = 1
    else:
      if s[i][j] == '#':
        u[i][j] = 0
      else:
        u[i][j] = u[i-1][j] + 1

d = [[0 for i in range(w)] for j in range(h)]
for j in range(w):
  for i in range(h-1, 0, -1):
    if i == h-1:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = 1
    else:
      if s[i][j] == '#':
        d[i][j] = 0
      else:
        d[i][j] = d[i+1][j] + 1

ans = 0
for i in range(h):
  for j in range(w):
    a = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3
    ans = max(ans, a)

print(ans)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
s=[input() for x in range(h)]
c=[[0 for i in range(w)] for j in range(h)]
d=[[0 for i in range(w)] for j in range(h)]

for i in range(h):
  for j in range(w):
    d[i][j] = 1 if s[i][j]=='.' else 0

for i in range(h):
  l=0
  for j in range(1,w):
    l = l + 1 if d[i][j-1]==d[i][j] else 0
    c[i][j] += l * d[i][j]

for i in range(h):
  l=0
  for j in range(w-1,0,-1):
    l = l + 1 if d[i][j-1]==d[i][j] else 0
    c[i][j-1] += l * d[i][j]

for i in range(w):
  l = 0
  for j in range(1,h):
    l = l + 1 if d[j-1][i]==d[j][i] else 0
    c[j][i] += l * d[j][i]

m=0
for i in range(w):
  l = 0
  for j in range(h-1,0,-1):
    l = l + 1 if d[j-1][i]==d[j][i] else 0
    c[j-1][i] += (l+1) * d[j-1][i]
    m = max(m,c[j-1][i])

print(m)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
s=[input() for x in range(h)]
c=[[0 for i in range(w)] for j in range(h)]

for i in range(h):
  for j in range(w):
    c[i][j] += 1 if s[i][j]=='.' else 0

for i in range(h):
  l=0
  for j in range(1,w):
    l = l + 1 if s[i][j-1]==s[i][j] else 0
    c[i][j] += l if c[i][j] else 0

for i in range(h):
  l=0
  for j in range(w-1,0,-1):
    l = l + 1 if s[i][j-1]==s[i][j] else 0
    c[i][j-1] += l if c[i][j-1] else 0

for i in range(w):
  l = 0
  for j in range(1,h):
    l = l + 1 if s[j-1][i]==s[j][i] else 0
    c[j][i] += l if c[j][i] else 0

m=0
for i in range(w):
  l = 0
  for j in range(h-1,0,-1):
    l = l + 1 if s[j-1][i]==s[j][i] else 0
    c[j-1][i] += l if c[j-1][i] else 0
    m = max(m,c[j-1][i])

print(m)

Submission status: Wrong Answer

Solution code:
h, w = [int(i) for i in input().split()]
a = []
he = {".": 0, "#": 1}
for _ in range(h):
    s = input()
    a.append([he[i] for i in s])
b = []
for i in range(w):
    s = []
    for j in a:
        s.append(j[i])
    b.append(s)


def c(s):
    m = 0
    n = 0
    for i in s:
        if i == 0:
            n += 1
        else:
            m = max(n, m)
            n = 0
    m = max(n, m)
    return m


print(c(max(a, key=c)) + c(max(b, key=c)) - 1)

Submission status: Wrong Answer

Solution code:
h, w = [int(i) for i in input().split()]
a = []
for _ in range(h):
    s = input()
    a.append(s)
b=[]
for i in range(w):
    s = ""
    for j in a:
        s += j[i]
    b.append(s)


def c(s):
    m = 0
    n = 0
    for i in s:
        if i == ".":
            n += 1
        else:
            m = max(n, m)
            n=0
    m = max(n, m)
    return m


print(c(max(a, key=c)) + c(max(b, key=c)) - 1)

Submission status: Wrong Answer

Solution code:
h, w = [int(i) for i in input().split()]
a = []
b = [""] * w
for _ in range(h):
    s = input()
    a.append(s)
    for i, j in enumerate(s):
        b[i] += j


def c(s):
    m = 0
    n = 0
    for i in s:
        if i == ".":
            n += 1
        else:
            n = 0
            m = max(n, m)
    m = max(n, m)
    return m


print(c(max(a, key=c)) + c(max(b, key=c)) - 1)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
s=[input() for x in range(h)]
c=[[0 for i in range(w)] for j in range(h)]

for i in range(h):
  for j in range(w):
    c[i][j] += 1 if s[i][j]=='.' else 0

for i in range(h):
  l=0
  for j in range(1,w):
    l = l + 1 if s[i][j-1]==s[i][j] else 0
    c[i][j] += l

for i in range(h):
  l=0
  for j in range(w-1,0,-1):
    l = l + 1 if s[i][j-1]==s[i][j] else 0
    c[i][j-1] += l

for i in range(w):
  l = 0
  for j in range(1,h):
    l = l + 1 if s[j-1][i]==s[j][i] else 0
    c[j][i] += l

m=0
for i in range(w):
  l = 0
  for j in range(h-1,0,-1):
    l = l + 1 if s[j-1][i]==s[j][i] else 0
    c[j-1][i] += l
    m = max(m,c[j-1][i])

print(m)

Submission status: Wrong Answer

Solution code:
H, W = map(int,input().split(' '))
S=[]
for i in range(H):
    S.append(input())

S2=[]
for i in range(H):
    wcnt=0
    ws=""
    for j in range(W):
        if S[i][j]=='#':
            ws=ws+str(wcnt)*wcnt+'0'
            #print(ws)
            wcnt=0
        elif j == W-1:
            wcnt+=1
            ws=ws+str(wcnt)*wcnt
        else:
            wcnt+=1
        #print(i,j,wcnt)
    S2.append(ws)

maxV=0
hcnt=0
wmax=0
for j in range(W):
    for i in range(H):
        wmax=max( int(S2[i][j]),wmax )
        if S2[i][j]=='0':
            maxV=max(wmax+hcnt,maxV)
            hcnt=0
            wmax=0
        elif i == H-1:
            hcnt+=1
            maxV=max(wmax+hcnt,maxV)
            hcnt=0
            wmax=0
        else:
            hcnt+=1
            wmax=max(wmax,int(S2[i][j]))
print(maxV-1)

#print(S2)

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
height, width_max, ans = [0] * (W+1), [0] * (W+1), 0
for i in range(H):
    s = list(input()) + [0]
    length = 0
    for j in range(W+1):
        if s[j] == '.':
            length += 1
            height[j] += 1
        else:
            if length > 0:
                for k in range(j-length, j):
                    if width_max[k] < length:
                        width_max[k] = length
                length = 0
            if height[j] > 0:
                temp = width_max[j] + height[j] - 1
                if ans < temp:
                    ans = temp
                height[j] = 0 

for j in range(W):
    if height[j] > 0:
        temp = width_max[j] + height[j] - 1
        if ans < temp:
            ans = temp
        height[j] = 0 

print(ans)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())

g = [[]]*h


for i in range(h):
    g[i] = list(input())

ans = 0

for i in range(h):
    for k in range(len(g[i])):
        if g[i][k] == '#':
            continue

        cnt = 0

        for a in range(i):
            if g[i - a][k] == '.':
                cnt += 1
            else:
                break

        for a in range(h - i):
            if g[a + i][k] == '.':
                cnt += 1
            else:
                break

        for a in range(len(g[i])):
            if g[i][k - a] == '.':
                cnt += 1
            else:
                break

        for a in range(len(g[i]) - k):
            if g[i][a + k] == '.':
                cnt += 1
            else:
                break

        cnt -= 2

        if ans < cnt:
            ans = cnt

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import groupby
import sys

input = sys.stdin.readline

def main(S):
  ans = -float('inf')
  max_col_ranges = sol(S)
  for max_col_range in max_col_ranges:
    tmp_grids = [col for col in zip(*S)][max_col_range[0]:max_col_range[1]]
    max_row_ranges = sol(tmp_grids)
    ans = max(ans,max_row_ranges[0][1]-max_row_ranges[0][0]+max_col_range[1]-max_col_range[0]-1)
  return ans

def sol(grids):
  max_ranges = []
  max_num = -float('inf')
  for j, row in enumerate(grids):

    i = 0
    for key, value in groupby(row):
      value_len = len(list(value))
      if key == 0:
        if max_num < value_len:
          max_ranges = [[i,i+value_len,j]]
          max_num = value_len
        elif max_num == value_len:
          max_ranges.append([i,i+value_len,j])
      i += value_len
  return max_ranges
      
H, W = map(int,input().split())
S = []
for j in range(H):
  row = [0 if s=='.' else 1 for s in input()]
  S.append(row)
  
print(main(S))

Submission status: Wrong Answer

Solution code:
from itertools import groupby
import sys

input = sys.stdin.readline

def main(S):
  ans = -float('inf')
  max_col_ranges = sol(S)
  for max_col_range in max_col_ranges:
    tmp_grids = [col for col in zip(*S)][max_col_range[0]:max_col_range[1]]
    max_row_ranges = sol(tmp_grids)
    ans = max(ans,max_row_ranges[0][1]-max_row_ranges[0][0]+max_col_range[1]-max_col_range[0]-1)
  return ans

def sol(grids):
  max_ranges = []
  max_num = -float('inf')
  for j, row in enumerate(grids):

    i = 0
    for key, value in groupby(row):
      value_len = len(list(value))
      if key == 0:
        if max_num < value_len:
          max_ranges = [[i,i+value_len,j]]
          max_num = value_len
        elif max_num == value_len:
          max_ranges.append([i,i+value_len,j])
      i += value_len
  return max_ranges
      
H, W = map(int,input().split())
S = []
for j in range(H):
  row = [0 if s=='.' else 1 for s in input()]
  S.append(row)
  
print(max(main(S),main([col for col in zip(*S)])))

Submission status: Wrong Answer

Solution code:
import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for i in range(H)])=="."

R = np.zeros((H,W), dtype=int)
L = np.zeros((H,W), dtype=int)
U = np.zeros((H,W), dtype=int)
D = np.zeros((H,W), dtype=int)
for i in range(W):
  L[:,i]= (L[:,i-1]+1)*S[:,i]
  R[:,-1-i]= (R[:,-i]+1)*S[:,-i-1]
for i in range(H):
  U[i] = (U[i-1]+1)*S[i]
  D[-i-1] = (D[-i]+1)*S[i-1]
print (np.max(L+R+U+D-3))

Submission status: Wrong Answer

Solution code:
import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for i in range(H)])=="."

R = np.zeros((H,W), dtype=int)
L = np.zeros((H,W), dtype=int)
U = np.zeros((H,W), dtype=int)
D = np.zeros((H,W), dtype=int)
for i in range(W):
  L[:,i]= (L[:,i-1]+1)*S[:,i]
  R[:,-1-i]= (R[:,-i]+1)*S[:,-i-1]
for i in range(H):
  U[i] = (U[i-1]+1)*S[i]
  D[-i-1] = (D[-i]+1)*S[i]
print (np.max(L+R+U+D-3))