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

Solution (Python):
import sys

H,W = map(int,input().split())
grids = [[s for s in sys.stdin.readline()] for _ in range(H)]

col_cnt = [[0 for _ in range(W)]for _ in range(H)]
for i in range(W):
  tmp_cnt = 0
  prvjj = 0
  for j in range(H):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      col_cnt[j][i] = 0
      for jj in range(prvjj,j):
        col_cnt[jj][i] = tmp_cnt
      prvjj = j+1
      tmp_cnt = 0
  for jj in range(prvjj,H):
    col_cnt[jj][i] = tmp_cnt

ans = -float('inf')
for j in range(H):
  tmp_cnt = 0
  prvii = 0
  for i in range(W):
    if grids[j][i] == '.':
      tmp_cnt += 1
    else:
      for ii in range(prvii,i):
        ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)
      prvii = i+1
      tmp_cnt = 0

  for ii in range(prvii,W):
    ans = max(ans,col_cnt[j][ii]+tmp_cnt-1)

print(ans)

Solution (Python):




h, w = map(int, input().split())
grid = []
for _ in range(h):
    grid.append(list(input()))

toR, toL = (
    [[0 for _ in range(w + 1)] for _ in range(h)],
    [[0 for _ in range(w + 1)] for _ in range(h)],
)
toU, toD = (
    [[0 for _ in range(w)] for _ in range(h + 1)],
    [[0 for _ in range(w)] for _ in range(h + 1)],
)


for y in range(h):
    for x in range(w):
        if grid[y][x] == ".":
            toR[y][x + 1] += toR[y][x] + 1
            toD[y + 1][x] += toD[y][x] + 1
        else:
            toR[y][x + 1] = 0
            toD[y + 1][x] = 0

        if grid[y][w - x - 1] == ".":
            toL[y][w - x - 1] += toL[y][w - x] + 1
        else:
            toL[y][w - x - 1] = 0

        if grid[h - y - 1][x] == ".":
            toU[h - y - 1][x] += toU[h - y][x] + 1
        else:
            toU[h - y - 1][x] = 0

ans = 0
for y in range(h):
    for x in range(w):
        tmp = toR[y][x + 1] + toL[y][x] + toD[y + 1][x] + toU[y][x] - 3
        ans = max(ans, tmp)

print(ans)

Solution (Python):
import numpy as np
H,W=map(int, input().split())
S=np.array([list(input()) for i in range(H)]) == '.'
us=np.zeros((H,W), dtype=int)   
ds=np.zeros((H,W), dtype=int)   
ls=np.zeros((H,W), dtype=int)    
rs=np.zeros((H,W), dtype=int)  

for h in range(1,H):
    us[h, :]=(us[h-1, :]+1) * S[h-1, :]
for h in range(H-2, -1, -1):
    ds[h, :]=(ds[h+1, :]+1) * S[h+1, :]
for w in range(1,W):
    ls[:, w]=(ls[:, w-1]+1) * S[:, w-1]
for w in range(W-2, -1, -1):
    rs[:, w]=(rs[:, w+1]+1) * S[:, w+1]

ans = ((us+ds+ls+rs)*S).max()+1
print(ans)

Solution (Python):
def examC():
    N, M = LI()
    A = [I() for _ in range(M)]
    A.append(N+1)
    fib = [1]*(N+2)
    for i in range(1,N):
        fib[i+2] = fib[i+1] + fib[i]
    fib[0] = 0

    ans = fib[A[0]]%mod
    for i in range(M):
        ans *= fib[A[i+1]-A[i]-1]
        ans %=mod
    print(ans)
    return

def examD():
    H, W = LI()
    S = [SI() for _ in range(H)]
    width = [[0]*W for _ in range(H)]
    height = [[0]*W for _ in range(H)]
    for i in range(H):
        cur = 0; keep = []
        for j in range(W):
            if S[i][j]==".":
                cur +=1
                keep.append(j)
            else:
                for k in keep:
                    width[i][k] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                width[i][k] = cur
    for j in range(W):
        cur = 0; keep = []
        for i in range(H):
            if S[i][j]==".":
                cur +=1
                keep.append(i)
            else:
                for k in keep:
                    height[k][j] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                height[k][j] = cur
    ans = 0
    for i in range(H):
        for j in range(W):
            cur = width[i][j] + height[i][j]
            if ans<cur:
                ans = cur
    print(ans-1)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w = LI()
s = [list(input()) for _ in range(h)]
W = [[0]*w for _ in range(h)]
H = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '
            continue
        else:
            if j > 0:
                W[i][j] = W[i][j-1] + 1
            else:
                W[i][j] = 1
            if i > 0:
                H[i][j]  = H[i-1][j] + 1
            else:
                H[i][j] = 1
y = [[0]*w for _ in range(h)]
x = [[0]*w for _ in range(h)]
for i in range(h)[::-1]:
    for j in range(w)[::-1]:
        if j == w-1:
            x[i][j] = W[i][j]
        if j > 0:
            if s[i][j-1] != '
                if s[i][j] == '
                    x[i][j-1] = W[i][j-1]
                else:
                    x[i][j-1] = max(x[i][j],W[i][j])
        if i == h-1:
            y[i][j] = H[i][j]
        if i > 0:
            if s[i-1][j] != '
                if s[i][j] == '
                    y[i-1][j] = H[i-1][j]
                else:
                    y[i-1][j] = max(y[i][j],H[i][j])
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] != '
            ans = max(ans,x[i][j] + y[i][j]-1)
print(ans)

Solution (Python):
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	H, W = MAP()
	M = [input().rstrip() for _ in range(H)]

	DU = tuple([-1,1])
	LR = tuple([-1,1])
	memo = [[-1]*W for _ in range(H)]
	ans = 0
	for i in range(H):
		for j in range(W):
			if M[i][j] == '
			tmp = [0,0]
			
			skip = -1
			if memo[i-1][j] != -1:
				tmp[0] = memo[i-1][j][0]
				skip = 1
			if memo[i][j-1] != -1:
				tmp[1] = memo[i][j-1][1]
				skip = 5 if skip == 1 else 2
			
			if skip == 1 or skip == -1:
				lr = 0
				for move in LR:
					nw = j
					dw = move
					while True:
						nw += dw
						
						if nw>W-1 or nw<0 or M[i][nw] == '
						lr += 1
					tmp[1] = lr

			if skip == 2 or skip == -1:
				du = 0
				for move in DU:
					nh = i
					dh = move
					while True:
						nh += dh
						
						if nh>H-1 or nh<0 or M[nh][j] == '
						du += 1
					tmp[0] = du
			
			memo[i][j] = tuple(tmp)
			ans = max(ans, sum(tmp)+1)
		
	
	
	
	
	print(ans)

if __name__ == "__main__":
	main()

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

h = [[0] * (W+1) for _ in range(H+1)]
v = [[0] * (W+1) for _ in range(H+1)]

for y in range(1, H+2):
    l = 0
    r = 0
    for x in range(1, W+2):
        if S[y][x] == '.':
            if S[y][x-1] == '
                l = x
            r = x
        else:
            if S[y][x-1] == '.':
                for x1 in range(l,r+1):
                    h[y][x1] = r - l + 1

for x in range(1, W+2):
    t = 0
    b = 0
    for y in range(1, H+2):
        if S[y][x] == '.':
            if S[y-1][x] == '
                t = y
            b = y
        else:
            if S[y-1][x] == '.':
                for y1 in range(t,b+1):
                    v[y1][x] = b - t + 1

ans = 0
for x in range(1, W+1):
    for y in range(1, H+1):
        ans = max(ans, h[y][x]+v[y][x]-1)

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
F = []
for _ in range(H):
    a = list(input())[:-1]
    F.append(a)

L = [[0]*(W+2) for _ in range(H+2)]
R = [[0]*(W+2) for _ in range(H+2)]
U = [[0]*(W+2) for _ in range(H+2)]
D = [[0]*(W+2) for _ in range(H+2)]

for h in range(1, H+1):
    f = F[h-1]
    l = L[h]
    for w in range(1, W+1):
        l[w] = l[w-1] + 1 if f[w-1] == '.' else 0
        U[h][w] = U[h-1][w] + 1 if f[w-1] == '.' else 0

for h in range(H, 0, -1):
    f = F[h-1]
    r = R[h]
    for w in range(W, 0, -1):
        r[w] = r[w+1] + 1 if f[w-1] == '.' else 0
        D[h][w] = D[h+1][w] + 1 if f[w-1] == '.' else 0

ans = 0
for h in range(1, H+1):
    l, r, u, d = L[h], R[h], U[h], D[h]
    ans = max( ans, max( l[w]+r[w]+u[w]+d[w] for w in range(1, W+1) ))
print(ans-3)

Solution (Python):
def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]    
    T = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]

    for h in range(H):
        cnt = 1
        for w in range(W):
            if S[h][w] == '
                cnt = 1
            else:
                L[h][w] = cnt
                cnt += 1

    for h in range(H):
        cnt = 1
        for w in range(W-1,-1,-1):
            if S[h][w] == '
                cnt = 1
            else:
                R[h][w] = cnt
                cnt += 1

    for w in range(W):
        cnt = 1
        for h in range(H):
            if S[h][w] == '
                cnt = 1
            else:
                T[h][w] = cnt
                cnt += 1

    for w in range(W):
        cnt = 1
        for h in range(H-1,-1,-1):
            if S[h][w] == '
                cnt = 1
            else:
                D[h][w] = cnt
                cnt += 1

    ans = 0
    for h in range(H):
        for w in range(W):
            tmp = T[h][w] + D[h][w] + L[h][w] + R[h][w] - 3
            ans = max(ans, tmp)

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):








H,W = map(int,input().split())

S = [[0]*W for i in range(H)]

for i in range(H):
    T=list(input())
    for j in range(W):
        if T[j] == "
            S[i][j] = 0
        else:
            S[i][j] = 1
MAP=[[0]*(W+2) for i in range(H+2)]
MAPH=[[0]*(W+2) for i in range(H+2)]
MAPU=[[0]*(W+2) for i in range(H+2)]
MAPL=[[0]*(W+2) for i in range(H+2)]
MAPR=[[0]*(W+2) for i in range(H+2)]

MAX=0

for i in range(1,W+1):
    for j in range(1,H+1):
            MAPH[j][i]=(MAPH[j-1][i]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPH[j][i]
            MAPU[H-j+1][W-i+1]=(MAPU[H-j+2][W-i+1]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPU[H-j+1][W-i+1]
for j in range(1,H+1):
    for i in range(1,W+1):
            MAPL[j][i]=(MAPL[j][i-1]+1)*S[j-1][i-1]
            MAP[j][i]+=MAPL[j][i]
            MAPR[H-j+1][W-i+1]=(MAPR[H-j+1][W-i+2]+1)*S[H-j][W-i]
            MAP[H-j+1][W-i+1]+=MAPR[H-j+1][W-i+1]
            MAX=max(MAX,MAP[j][i]-3,MAP[H-j+1][W-i+1]-3)
print(MAX)

Solution (Python):
def solve():
    H, W = map(int, input().split())
    maze = [[] for _ in range(H)]
    for i in range(H):
        maze[i] = list(input())

    u = [[0 for _ in range(W)] for _ in range(H)]
    r = [[0 for _ in range(W)] for _ in range(H)]
    d = [[0 for _ in range(W)] for _ in range(H)]
    l = [[0 for _ in range(W)] for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if maze[i][j] == '
                continue
            if i == 0:
                u[i][j] = 1
            else:
                u[i][j] = u[i-1][j] + 1
            if j == 0:
                l[i][j] = 1
            else:
                l[i][j] = l[i][j-1] + 1
    for i in range(H-1, -1, -1):
        for j in range(W-1, -1, -1):
            if maze[i][j] == '
                continue
            if i == H - 1:
                d[i][j] = 1
            else:
                d[i][j] = d[i+1][j] + 1
            if j == W - 1:
                r[i][j] = 1
            else:
                r[i][j] = r[i][j+1] + 1

    ans = 0
    for i in range(H):
        for j in range(W):
            ans = max(ans, u[i][j] + r[i][j] + d[i][j] + l[i][j] - 3)
    print(ans)


if __name__ == '__main__':
    solve()

Solution (Python):
import sys
from itertools import product

input = sys.stdin.readline

H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]

for i, j in product(range(H), range(W)):
    if S[i][j] == '
        continue
    if j == 0:
        L[i][j] = 1
    else:
        L[i][j] = L[i][j - 1] + 1
    if i == 0:
        U[i][j] = 1
    else:
        U[i][j] = U[i - 1][j] + 1

for i, j in product(range(H), range(W - 1, -1, -1)):
    if S[i][j] == '
        continue
    if j == W - 1:
        R[i][j] = 1
    else:
        R[i][j] = R[i][j + 1] + 1

for i, j in product(range(H - 1, -1, -1), range(W)):
    if S[i][j] == '
        continue
    if i == H - 1:
        D[i][j] = 1
    else:
        D[i][j] = D[i + 1][j] + 1

ans = 0
for i, j in product(range(H), range(W)):
    if S[i][j] == '
        continue
    x = L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3
    ans = max(ans, x)
print(ans)

Solution (Python):
import numpy as np

def main():
    H, W = map(int, input().split())
    S = np.array([list(input()) for _ in range(H)]) == '.'

    L = np.zeros((H, W), dtype=int)
    R = np.zeros((H, W), dtype=int)
    U = np.zeros((H, W), dtype=int)
    D = np.zeros((H, W), dtype=int)

    for w in range(1, W):
        L[:, w] = (L[:, w-1] + 1) * S[:, w-1]
    for w in range(W-2, -1, -1):
        R[:, w] = (R[:, w+1] + 1) * S[:, w+1]
    for h in range(1, H):
        U[h, :] = (U[h-1, :] + 1) * S[h-1, :]
    for h in range(H-2, -1, -1):
        D[h, :] = (D[h+1, :] + 1) * S[h+1, :]

    print(((L+R+U+D)*S).max() + 1)

if __name__ == '__main__':
    main()

Solution (Python):
h, w = map(int, input().split())
ans = [[0]*w for _ in range(h)]
S = [["
for i in range(h):
    s = input().split('
    j = 0
    for c in s:
        for d in list(c):
            S[j][i] = d
            ans[i][j] += len(c)
            j += 1
        j += 1
for i in range(w):
    s = "".join(S[i]).split("
    j = 0
    for c in s:
        for d in list(c):
            ans[j][i] += len(c)
            j += 1
        j += 1

m = 0
for a in ans:
    if m < max(a):
        m = max(a)
print(m-1)

Solution (Python):
H, W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())
left = [[0 for i in range(W)] for j in range(H)]
right = [[0 for i in range(W)] for j in range(H)]
down = [[0 for i in range(W)] for j in range(H)]
up = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    cnt = 0
    for j in range(W):
        if S[i][j] == '
            cnt = 0
        else:
            cnt += 1
        left[i][j] = cnt

for i in range(H):
    cnt = 0
    for j in range(W)[::-1]:
        if S[i][j] == '
            cnt = 0
        else:
            cnt += 1
        right[i][j] = cnt

for j in range(W):
    cnt = 0
    for i in range(H):
        if S[i][j] == '
            cnt = 0
        else:
            cnt += 1
        down[i][j] = cnt
    
for j in range(W):
    cnt = 0
    for i in range(H)[::-1]:
        if S[i][j] == '
            cnt = 0
        else:
            cnt += 1
        up[i][j] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '
            continue
        ans = max(ans, left[i][j] + right[i][j] + down[i][j] + up[i][j] -3)

print(ans)

Solution (Python):
def main():
    H, W = map(int, input().split())
    S = []
    for _ in range(H):
        t = input()
        S.append(t)
    l = [[0] * W for _ in range(H)]
    r = [[0] * W for _ in range(H)]
    u = [[0] * W for _ in range(H)]
    d = [[0] * W for _ in range(H)]
    for i in range(H):
        t = -1
        for j in range(W):
            if S[i][j] == '
                t = j
                continue
            l[i][j] = t
    for i in range(H):
        t = W
        for j in range(W-1, -1, -1):
            if S[i][j] == '
                t = j
                continue
            r[i][j] = t
    for i in range(W):
        t = -1
        for j in range(H):
            if S[j][i] == '
                t = j
                continue
            u[j][i] = t
    for i in range(W):
        t = H
        for j in range(H-1, -1, -1):
            if S[j][i] == '
                t = j
                continue
            d[j][i] = t
    m = 0
    for i in range(H):
        for j in range(W):
            m = max(m, r[i][j] - l[i][j] + d[i][j] - u[i][j] - 3)
    return m
print(main())

Solution (Python):
import sys
from collections import deque
import numpy as np
input = sys.stdin.readline
H, W = [int(x) for x in input().strip().split()]
S = np.zeros((H + 2) * (W + 2)).reshape(H + 2, W + 2)
u = np.zeros((H + 2) * (W + 2)).reshape(H + 2, W + 2)
d = np.zeros((H + 2) * (W + 2)).reshape(H + 2, W + 2)
l = np.zeros((H + 2) * (W + 2)).reshape(H + 2, W + 2)
r = np.zeros((H + 2) * (W + 2)).reshape(H + 2, W + 2)

for h in range(H):
    s = [1 if i == '.' else 0 for i in input().strip()]
    S[h + 1] = np.array([0] + s + [0])

for h in range(1, H + 1):
    u[h] = (u[h-1] + 1) * S[h]
    d[H+1-h] = (d[H+2-h] + 1) * S[H+1-h]

for w in range(1, W + 1):
    l[:, w] = (l[:, w-1] + 1) * S[:, w]
    r[:, W+1-w] = (r[:, W+2-w] + 1) * S[:, W+1-w]

ans = u+d+l+r
print(int(ans.max()-3))

Solution (Python):
H,W=map(int,input().split())
grid=[None]*H
for i in range(H):
  grid[i]=input()

R=[[0 for i in range(W)] for j in range(H)]
L=[[0 for i in range(W)] for j in range(H)]
U=[[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):
    if grid[i][j]=="
      L[i][j]=0
    else:
      if j-1<0:
        L[i][j]=1
      else:
        L[i][j]=L[i][j-1]+1
        
for i in range(H):
  for j in range(W-1,-1,-1):
    if grid[i][j]=="
      R[i][j]=0
    else:
      if j+1>=W:
        R[i][j]=1
      else:
        R[i][j]=R[i][j+1]+1
        
for j in range(W):
  for i in range(H):
    if grid[i][j]=="
      U[i][j]=0
    else:
      if i-1<0:
        U[i][j]=1
      else:
        U[i][j]=U[i-1][j]+1
        
for j in range(W):
  for i in range(H-1,-1,-1):
    if grid[i][j]=="
      D[i][j]=0
    else:
      if i+1>=H:
        D[i][j]=1
      else:
        D[i][j]=D[i+1][j]+1

maxval=0
for i in range(H):
  for j in range(W):
    maxval=max(maxval,R[i][j]+L[i][j]+U[i][j]+D[i][j])
print(maxval-3)

Solution (Python):
import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
us = np.zeros((H,W), dtype=int)    
ds = np.zeros((H,W), dtype=int)    
ls = np.zeros((H,W), dtype=int)    
rs = np.zeros((H,W), dtype=int)    

for h in range(1,H):
    us[h, :] = (us[h-1, :] + 1) * S[h-1, :]
for h in range(H-2, -1, -1):
    ds[h, :] = (ds[h+1, :] + 1) * S[h+1, :]
for w in range(1,W):
    ls[:, w] = (ls[:, w-1] + 1) * S[:, w-1]
for w in range(W-2, -1, -1):
    rs[:, w] = (rs[:, w+1] + 1) * S[:, w+1]

ans = ((us + ds + ls + rs)*S).max() + 1
print(ans)

Solution (Python):
import numpy as np

H, W = map(int, input().split())

maze01 = np.array([[int(x=='.') for x in input()] for _ in range(H)]) 

u = np.zeros((H, W), dtype=np.int32)
d = np.zeros((H, W), dtype=np.int32)
r = np.zeros((H, W), dtype=np.int32)
l= np.zeros((H, W), dtype=np.int32)


u[0] = maze01[0]
d[H - 1] = maze01[H - 1]
for hh in range(1,H):
    u[hh] = u[hh-1] + maze01[hh]
    u[hh] *= maze01[hh]
    d[H - hh - 1] = d[H - hh] + maze01[H - hh - 1]
    d[H - hh - 1] *= maze01[H - hh - 1]

l[:, 0] = maze01[:, 0]
r[:, W - 1] = maze01[:, W - 1]
for ww in range(1, W):
    l[:, ww] = l[:, ww -1] + maze01[:, ww]
    l[:, ww] *= maze01[:, ww]
    r[:, W - ww -1] = r[:, W - ww] + maze01[:, W - ww - 1]
    r[:, W - ww -1] *= maze01[:, W - ww - 1]

cnt = r + l + u + d - 3

print(max([max(cnt[i]) for i in range(H)]))

Solution (Python):
import numpy as np
import sys
input = sys.stdin.readline

H,W = map(int,input().split())
S=np.array([list(input().rstrip("\n")) for _ in range(H)]) == '.'

D = np.zeros((H,W),dtype=int)
U = np.zeros((H,W),dtype=int)
L = np.zeros((H,W),dtype=int)
R = np.zeros((H,W),dtype=int)


for i in range(H):
  U[i] = (U[i-1] + 1) * S[i]
  D[-i-1] = (D[-i] + 1) * S[-i-1]


for i in range(W):
  L[:,i] = (L[:,i-1] + 1) * S[:,i]
  R[:,-i-1] = (R[:,-i] + 1) * S[:,-i-1]

print(np.max(U+D+L+R)-3)