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: Runtime Error

Solution code:
H,W = map(int,input().split())
List=[input() for i in range(H)]
A =[[[1]*(W) for i in range(H)]
B =[[] for i in range(W)]
for i in range(H):
    k = 0
    a = 0
    while k < W:
        if List[i][k]==".":
            a += 1
            k = k+1
        else:
            for j in range(a):
                A[i][k-j-1]=a
            A[i][k]=a
            a = 0
            k = k+1
    for j in range(a):
                A[i][k-j-1]=a
for i in range(W):
    k = 0
    a = 0
    while k < H:
        if List[k][i]==".":
            a += 1
            k = k+1
        else:
            for j in range(a):
                B[i][k-j-1]=a
            B[i][k] = 0
            a = 0
            k = k+1
    for j in range(a):
                B[i][k-j-1]= a
max = 0
for i in range(H):
    for j in range(W):
        if max < A[i][j] + B[j][i]:
            max = A[i][j] + B[j][i]
print(max-1)

Submission status: Runtime Error

Solution code:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint

WARU = 1000000007

H, W = [ int(x) for x in input().split() ]
S = []
for _i in range(H):
    S.append(input())

def key(h,w):
    return "{}:{}".format(h,w)

ans = [ [] for x in range(H)] # right,under
for h in range(H):
    ans[h] = [ [0,0] for x in range(W) ]

for h in range(H):
    for w in range(W):
        if S[h][w] == "#":
            continue
        right = 0
        under = 0
        if w == 0:
            right = 1
        else:
            right = ans[h][w-1][0] + 1
        if h == 0:
            under = 1
        else:
            under = ans[h-1][w][1] + 1
        ans[h][w] = [right,under]

ans2 = [ [] for x in range(H)] # right,under
for h in range(H):
    ans2[h] = [ [0,0] for x in range(W) ]


for h in range(H-1,-1,-1):
    for w in range(W-1,-1,-1):
        if S[h][w] == "#":
            continue
        right = 0
        under = 0
        if w == W - 1:
            right = 1
        else:
            right = ans2[h][w+1][0] + 1
        if h == H - 1:
            under = 1
        else:
            under = ans2[h+1][w][1] + 1
        ans2[h][w] = [right,under]

max_mass = 0
max_count = 0

ans3 = [ [] for x in range(H)] # right,under
for h in range(H):
    ans3[h] = [ 0 for x in range(W) ]


for h in range(H):
    for w in range(W):
        ans3[h][w] = ans[h][w][0] + ans[h][w][1] + ans2[h][w][0] + ans2[h][w][1]


max = 0
for h in range(H):
    for w in range(W):
        if max < ans3[h][w]:
            max = ans3[h][w]
print (max - 3)

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
m = [[] for i in range(h)]
for i in range(h):
    m[i] = list(input().split())
out = 0
for i in range(h):
	for j in range(w):
		num = 0
		if m[i][j] == '#':
			continue
		else:
			num = 1
			l = 1
			r = 1
			u = 1
			d = 1
			while j-l>=0:
				if m[i][j-l] != '#' :
					num += 1
					l +=1
				else:
					break
			
			while  j+r < w:
				if m[i][j+r] != '#':
					num += 1
					r +=1
				else:
					break
			while  i-u >=0:
				if m[i-u][j] != '#':
					num += 1
					u +=1
				else:
					break	
			while  i+d < h:
				if m[i+d][j] != '#':
					num += 1
					d +=1
				else:
					break
		out = max(num,out)	
print(out)

Submission status: Runtime Error

Solution code:
import numpy as np

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

S = [list(input()) for _ in range(H)]

w_point = [[0 for i in range(W)] for j in range(W)]
for h in range(H):
    bw = 0
    for w in range(W):
        if S[h][w] == '#':
            for i in range(bw,w):
                w_point[h][i] = w - bw
            bw = w + 1
        if w == W -1:
            for i in range(bw, w+1):
                w_point[h][i] = w+1 - bw


h_point = [[0 for i in range(W)] for j in range(W)]
for w in range(W):
    bh = 0
    for h in range(H):
        if S[h][w] == '#':
            for i in range(bh,h):
                h_point[i][w] = h - bh
            bh = h + 1
        if h == H - 1:
            for i in range(bh, h+1):
                h_point[i][w] = h+1 - bh

print(np.max(np.array(w_point)+np.array(h_point)-1))

Submission status: Runtime Error

Solution code:
import numpy as np
def cal(S, xx):
    S1 = []
    for s in S:
        indexes = [i for i, x in enumerate(s) if x == "#"]
        indexes.append(xx+1)
        
        cnt = 0
        ret = []
        b_index = 0
        for cnt, index in enumerate(indexes):
            if cnt == 0:
                ret.extend( [index-b_index for _ in range(index-b_index)])
            elif cnt == len(x) -1:
                ret.extend( [index-b_index-2 for _ in range(index-b_index-1)])
            else:
                ret.extend( [index-b_index-1 for _ in range(index-b_index-1)])
            ret.append(0)
            b_index = index
        S1.append(ret[:-2])
    return np.array(S1)

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

S = []
for i in range(H):
    S.append(list(input()))
    
A = np.array(S)
B = A.T

S1 = cal(A, W)
S2 = cal(B, H)

XX = S1 + S2.T
print(np.max(XX) - 1)

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
F = [input() for _ in range(H)]
FH = [[0]*W for _ in range(H)]
FV = [[0]*W for _ in range(H)]


def search(x, y, c, d):
    if not (0 <= x < H and 0 <= y < W):
        return c
    if F[x][y] == "#":
        return c
    else:
        if d == "h":
            return search(x, y+1, c+1, "h")
        else:
            return search(x+1, y, c+1, "v")

ans = 0
for i in range(H):
    for j in range(W):
        if F[i][j] == "#":
            FH[i][j] = 0
        elif F[i][j] == ".":
            if FH[i][j-1] > 0:
                FH[i][j] = FH[i][j-1]
            else:
                FH[i][j] = search(i, j+1, 1, "h")

for i in range(H):
    for j in range(W):
        if F[i][j] == "#":
            FV[i][j] = 0
        elif F[i][j] == ".":
            if FV[i-1][j] > 0:
                FV[i][j] = FV[i-1][j]
            else:
                FV[i][j] = search(i+1, j, 1, "v")

ans = 0
for i in range(H):
    for j in range(W):
        if FH[i][j] + FV[i][j] > ans:
            ans = FH[i][j] + FV[i][j]

print(ans-1)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
S = list(input() for i in range(H))
Grid1 = [[0]*W for i in range(H)]
#print(S)
ans = 0
for i in range(H):
    cou = 0
    l = 0
    ws = [0]*H
    for j in range(W):
        #print(i,j,S[i][j])
        if S[i][j] == ".":
            cou += 1
        else:
            for x in range(l,j):
                ws[x] = cou
            ws[j] = 0
            l = j+1
            cou = 0
        for x in range(l,j+1):
            ws[x] = cou
    Grid1[i] = ws

for i in range(W):
    cou = 0
    l = 0
    ws = [0]*W
    for j in range(H):
        #print(i,j,S[i][j])
        if S[j][i] == ".":
            cou += 1
        else:
            for x in range(l,j):
                ws[x] = cou
            ws[j] = 0
            l = j+1
            cou = 0
        for x in range(l,j+1):
            ws[x] = cou
    for j in range(H):
        ans =max(Grid1[j][i] +ws[j], ans)

print(ans-1)

Submission status: Runtime Error

Solution code:
# coding: UTF-8
import sys
sys.setrecursionlimit(10*5)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(str, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

h, w = readmi()
wt = []
ht = []
count = 0
def dfs(th, tw, allow):
    global count
    if allow == True:
        if tw + 1 < w:
            if wt[th][tw + 1] == '.':
                count += 1
                wt[th][tw] = dfs(th, tw + 1, allow)
            else:
                count += 1
                wt[th][tw] = count
        else:
            count += 1
            wt[th][tw] = count
    return count
count = 0

def dfs_h(th, tw, allow):
    global count
    if allow == True:
        if th + 1 < h:
            if ht[th + 1][tw] == '.':
                count += 1
                ht[th][tw] = dfs_h(th + 1, tw, allow)
            else:
                count += 1
                ht[th][tw] = count
        else:
            count += 1
            ht[th][tw] = count
    return count

for i in range(h):
    p = read()
    wt.append(list(p))
    ht.append(list(p))

for i in range(h):
    for j in range(w):
        if wt[i][j] == '.':
            count = 0
            dfs(i,j,True)
        elif wt[i][j] == '#':
            wt[i][j] = 0

for i in range(w):
    for j in range(h):
        if ht[j][i] == '.':
            count = 0
            dfs_h(j,i,True)
        elif ht[j][i] == '#':
            ht[j][i] = 0
mx = 0
for i in range(w):
    for j in range(h):
        mx = max(mx,ht[j][i] + wt[j][i])
print(mx - 1)

Submission status: Runtime Error

Solution code:
import sys

readline = sys.stdin.readline

H, W = map(int, readline().split())
S = [readline().rstrip() for i in range(H)]

vert = [[0]*W for i in range(W)]
hori = [[0]*W for i in range(W)]

for y in range(H):
    for x in range(W):

        if x > 0 and S[y][x - 1] != '#':
            hori[y][x] = hori[y][x - 1]
        elif S[y][x] == '#':
            hori[y][x] = 0
        else:
            # hori
            count = 1
            while x + count < W and S[y][x + count] == '.':
                count += 1
            hori[y][x] = count

        if y > 0 and S[y - 1][x] != '#':
            vert[y][x] = vert[y - 1][x]
        elif S[y][x] == '#':
            vert[y][x] = 0
        else:
            # hori
            count = 1
            while y + count < H and S[y + count][x] == '.':
                count += 1
            vert[y][x] = count

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

print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy
 
 
def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.array([g, g])
 
  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]
 
  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])
 
  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]
 
  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])
 
  g = g[0] + g[1]
 
  print(numpy.max(g) - 1)
 
 
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
import numpy as np


def acinput():
    return list(map(int, input().split(" ")))


H, W = acinput()
S = [["#"]*(W+2)]
for i in range(H):
    tmp=["#"]
    tmp.extend(list(input()))
    tmp.append("#")

    S.append(tmp)
S.append(["#"]*(W+2))

def search(x,d):
    global res


    xx=(x[0],x[1])
    if xx in dp:
        if len(dp[xx][d])>0:
            return dp[xx]

    if S[x[0]][x[1]] == "#":
        return (x,x,x,x,0)
    
    dp[xx]=[[]for i in range(5)]
    dp[xx][0]=search(x+[1,0],0)[0]
    dp[xx][1]=search(x+[0,1],1)[1]
    dp[xx][2]=search(x+[-1,0],2)[2]
    dp[xx][3]=search(x+[0,-1],3)[3]

    tdp=dp[xx]
    tate=abs(tdp[2][0]-tdp[0][0])-1
    yoko=abs(tdp[3][1]-tdp[1][1])-1
    dp[xx][4]=tate+yoko-1
    if res <tate+yoko-1:
        res=tate+yoko-1
        #input()
    return dp[xx]

dp={}
res=0

for i in range(1,H+1):
    for j in range(1,W+1):
        search(np.array([i,j]),0)


print(res)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
import numpy as np

#debug = True
debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    H, W = map(int, input().split())
    s_arr = np.zeros(shape=(H, W))
    for h in range(H):
        s_row = input()
        for w in range(W):
            if s_row[w] == ".":
                s_arr[h, w] = 0
            else:
                s_arr[h, w] = 1

    memo = [[(-1, -1) for w in range(W)] for h in range(H)]

    def count_light(arr, pos):
        start = 0
        end = 0
        active = False
        for i, s in enumerate(arr):
            if i == pos:
                active = True
            if s == 1:
                if active == True:
                    return (start, end)
                else:
                    start = i + 1
                    end = i + 1
            else:
                end = i
        return start, end

    def count_hw_light(h, w):
        if s_arr[h][w] == 1:
            return 0

        m = memo[h][w] # (3, 2) / (-1, -1) / ( -1, 2) / (3, -1)
        dprint(h, w, m)
        count = 0
        counth = m[0]
        countw = m[1]
        if counth == -1:
            arr = s_arr[:, w]
            start, end = count_light(arr, h)
            count += (end - start) + 1
            dprint("h", arr, h, end, start)
            for i in range(start, end+1):
                memo[i][w] = ((end - start) + 1, countw)
        else:
            count += counth

        if countw == -1:
            arr = s_arr[h, :]
            start, end = count_light(arr, w)
            count += (end - start) + 1
            dprint("w", arr, w, end, start)
            for i in range(start, end+1):
                memo[h][i] = (counth, (end - start) + 1)
        else:
            count += countw

        dprint(h, w, memo[h][w], counth, countw, count)
        dprint(memo)
        return count

    mx_ans = 0
    for h in range(H):
        for w in range(W):
            ans = count_hw_light(h, w) -1 # 重複カウント消し
            if ans >= mx_ans:
                mx_ans = ans

    print(mx_ans)
    dprint(s_arr)
    dprint(memo)

solve()

Submission status: Runtime Error

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(str, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

h, w = readmi()
wt = []
ht = []
count = 0
def dfs(th, tw, allow):
    global count
    if allow == True:
        if tw + 1 < w:
            if wt[th][tw + 1] == '.':
                count += 1
                wt[th][tw] = dfs(th, tw + 1, allow)
            else:
                count += 1
                wt[th][tw] = count
        else:
            count += 1
            wt[th][tw] = count
    return count
count = 0

def dfs_h(th, tw, allow):
    global count
    if allow == True:
        if th + 1 < h:
            if ht[th + 1][tw] == '.':
                count += 1
                ht[th][tw] = dfs_h(th + 1, tw, allow)
            else:
                count += 1
                ht[th][tw] = count
        else:
            count += 1
            ht[th][tw] = count
    return count

for i in range(h):
    p = read()
    wt.append(list(p))
    ht.append(list(p))

for i in range(h):
    for j in range(w):
        if wt[i][j] == '.':
            count = 0
            dfs(i,j,True)
        elif wt[i][j] == '#':
            wt[i][j] = 0

for i in range(w):
    for j in range(h):
        if ht[j][i] == '.':
            count = 0
            dfs_h(j,i,True)
        elif ht[j][i] == '#':
            ht[j][i] = 0
mx = 0
for i in range(w):
    for j in range(h):
        mx = max(mx,ht[j][i] + wt[j][i])
print(mx - 1)

Submission status: Runtime Error

Solution code:
import sys

#readline = sys.stdin.readline
_input = open('input')
readline = _input.readline

H, W = map(int, readline().split())
S = [readline().rstrip() for i in range(H)]

vert = [[0]*W for i in range(W)]
hori = [[0]*W for i in range(W)]

for y in range(H):
    for x in range(W):

        if x > 0 and S[y][x - 1] != '#':
            hori[y][x] = hori[y][x - 1]
        elif S[y][x] == '#':
            hori[y][x] = 0
        else:
            # hori
            count = 1
            while x + count < W and S[y][x + count] == '.':
                count += 1
            hori[y][x] = count

        if y > 0 and S[y - 1][x] != '#':
            vert[y][x] = vert[y - 1][x]
        elif S[y][x] == '#':
            vert[y][x] = 0
        else:
            # hori
            count = 1
            while y + count < H and S[y + count][x] == '.':
                count += 1
            vert[y][x] = count

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

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
W = list(map(int,input().split()))
R = [W[0]]
for i in range(1,N):
    R.append(R[i-1] + W[i])
s = sum(W)

ans = 1000

for i in range(N):
    ans = min(ans,abs(R[i]-(s-R[i])))
print(ans)
"""

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

G_jouge = []
G_sayu = []
for h in range(H):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for w in range(W):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[h][W-1-w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_sayu.append([G_hidari[W-1-i]+G_migi[i] for i in range(W)])
for w in range(W):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for h in range(H):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[H-1-h][w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_jouge.append([G_hidari[H-1-i]+G_migi[i] for i in range(H)])

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,G_sayu[h][w]+G_jouge[w][h])
print(ans+1)

Submission status: Runtime Error

Solution code:
import sys

#readline = sys.stdin.readline
_input = open('input')
readline = _input.readline

H, W = map(int, readline().split())
S = [readline().rstrip() for i in range(H)]

vert = [[0]*W for i in range(W)]
hori = [[0]*W for i in range(W)]

for y in range(H):
    for x in range(W):

        if x > 0 and S[y][x - 1] != '#':
            hori[y][x] = hori[y][x - 1]
        elif S[y][x] == '#':
            hori[y][x] = 0
        else:
            # hori
            count = 1
            while x + count < W and S[y][x + count] == '.':
                count += 1
            hori[y][x] = count

        if y > 0 and S[y - 1][x] != '#':
            vert[y][x] = vert[y - 1][x]
        elif S[y][x] == '#':
            vert[y][x] = 0
        else:
            # hori
            count = 1
            while y + count < H and S[y + count][x] == '.':
                count += 1
            vert[y][x] = count

ans = 0
for y in range(H):
    for x in range(W):
        a = hori[y][x] + vert[y][x] - 1
        ans = max(a, ans)
        sys.stdout.write('{},{}\t'.format(hori[y][x], vert[y][x]))
    print('')

print(ans)

Submission status: Runtime Error

Solution code:
l = input().split()
H = int(l[0])
W = int(l[1])

S = []
for i in range(H):
    l = input().split()
    S.append(l[0])

# print(H, W, S)

TS = []
for i in range(W):
    tmp = ''
    for j in range(H):
        tmp += S[j][i]
    TS.append(tmp)

# print(TS)

HL = []
for i in range(H):
    l = 0
    begin = 0
    tmp = []
    for j in range(W):
        if S[i][j] == '.':
            l += 1
        else:
            tmp.extend([l]*(j - begin))
            tmp.append(0)
            begin = j + 1
            l = 0
    if begin != W:
        tmp.extend([l]*(W - begin))
    HL.append(tmp)

WL = []
for i in range(W):
    l = 0
    begin = 0
    tmp = []
    for j in range(H):
        if TS[i][j] == '.':
            l += 1
        else:
            tmp.extend([l]*(j - begin))
            tmp.append(0)
            begin = j + 1
            l = 0
    if begin != W:
        tmp.extend([l]*(W - begin))
    WL.append(tmp)

max_l = 0
for i in range(H):
    for j in range(W):
        l = HL[i][j] + WL[j][i]
        max_l = max(l, max_l)
print(max_l - 1)

Submission status: Runtime Error

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

s = [[i for i in list(str(input()))] for i in range(h)]

board_w = [[0 for i in range(w)] for i in range(h)]
board_h = [[0 for i in range(h)] for i in range(w)]

# 横、縦の順に走査
for i in range(h):
    cnt_continue = 0
    for j, c in enumerate(s[i]):
        if c == ".":
            cnt_continue += 1
        elif cnt_continue > 0:
            for k in range(1, cnt_continue+1):
                board_w[i][j-k] = cnt_continue
            cnt_continue = 0
    for k in range(cnt_continue):
        board_w[i][w-1-k] = cnt_continue
    cnt_continue = 0

s = list(map(list, zip(*s)))

for i in range(w):
    cnt_continue = 0
    for j, c in enumerate(s[i]):
        if c == ".":
            cnt_continue += 1
        elif cnt_continue > 0:
            for k in range(1, cnt_continue+1):
                board_h[i][j-k] = cnt_continue
            cnt_continue = 0
    for k in range(cnt_continue):
        board_h[i][w-1-k] = cnt_continue
    cnt_continue = 0

board_h = list(map(list, zip(*board_h)))
ans = 0

for i in range(h):
    for j in range(w):
        v = int(board_w[i][j]) + int(board_h[i][j])
        ans = max(ans, v)

print(ans-1)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np
import numba
@numba.jit

H, W = [int(x) for x in stdin.readline().rstrip().split()]
S = [stdin.readline().rstrip() for _ in range(H)]
S_new = np.array([[1 if S[k][l] == '#' else 0 for l in range(W)] for k in range(H)])
ans = 0
for y in range(H):
    for x in range(W):
        if S_new[y][x] == 1:
            continue
        cnt = 1
        for k in range(1, W - x):
            if S_new[y][x + k] == 1:
                break
            cnt += 1
        for l in range(1, x + 1):
            if S_new[y][x - l] == 1:
                break
            cnt += 1
        for m in range(1, H - y):
            if S_new[:, x][y + m] == 1:
                break
            cnt += 1
        for n in range(1, y + 1):
            if S_new[:, x][y - n] == 1:
                break
            cnt += 1
        ans = max(ans, cnt)

print(ans)

Submission status: Runtime Error

Solution code:
import sys

#readline = sys.stdin.readline
_input = open('input')
readline = _input.readline

H, W = map(int, readline().split())
S = [readline().rstrip() for i in range(H)]

vert = [[0]*W for i in range(W)]
hori = [[0]*W for i in range(W)]

for y in range(H):
    for x in range(W):

        if x > 0 and S[y][x - 1] != '#':
            hori[y][x] = hori[y][x - 1]
        elif S[y][x] == '#':
            hori[y][x] = 0
        else:
            # hori
            count = 1
            while x + count < W and S[y][x + count] == '.':
                count += 1
            hori[y][x] = count

        if y > 0 and S[y - 1][x] != '#':
            vert[y][x] = vert[y - 1][x]
        elif S[y][x] == '#':
            vert[y][x] = 0
        else:
            # hori
            count = 1
            while y + count < H and S[y + count][x] == '.':
                count += 1
            vert[x][y] = count

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

print(ans)

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
S = ""
for i in range(H):
    S += input()

light = [0] * (H*W)
for h in range(H):
    cnt = 0
    pre = "@"
    info = []
    for i in range(h*W, (h+1)*W):
        if S[i] == pre:
            cnt += 1
            if i == (h+1)*W-1:
                if S[i] == ".":
                    info.append(cnt)
                else:
                    info.append(-cnt)
        else:
            if pre == ".":
                info.append(cnt)
                cnt = 1
            elif pre == "#":
                info.append(-cnt)
                cnt = 1
    cnt = h*W
    while len(info) > 0:
        LD = info.pop(0)
        if LD > 0: 
            for i in range(LD):
                light[cnt + i] += LD
            cnt += LD
        else:
            for i in range(-LD):
                light[cnt + i] = 0
            cnt += -LD

for w in range(W):
    cnt = 0
    pre = "@"
    info = []
    for i in range(H):
        if S[w + i * H] == pre:
            cnt += 1
            if i == H-1:
                if S[w + i * H] == ".":
                    info.append(cnt)
                else:
                    info.append(-cnt)
        else:
            if pre == ".":
                info.append(cnt)
                cnt = 1
            elif pre == "#":
                info.append(-cnt)
                cnt = 1
    cnt = w
    while len(info) > 0:
        LD = info.pop(0)
        if LD > 0: 
            for i in range(LD):
                light[w + i * H] += LD
            cnt += LD * H
        else:
            for i in range(-LD):
                light[i] = 0
            cnt += -LD * H
print(max(light)-1)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())

S = [['x']*W]*H

for h in range(H):
    S[h] = list(input())
#print(S)

def pmap(func):
    return func()
def hmap():
    for h in range(H):
        bw, sw = 0,0
        for i in range(W):
            if S[h][i] != '#' and i != W-1:
                bw += 1
            elif S[h][i] == '#':
                for asw in range(sw, i):
                    S[h][asw] = bw
                bw = 0
                sw = i+1
                #print(sw,bw)
            elif i == W-1:
                bw += 1
                #print('err')
                for asw in range(sw, W):
                    S[h][asw] = bw
    return S
#print('2nd')
#print(S)
def wmap():
    for w in range(W):
        bh, sh = 0,0
        for i in range(H):
            if S[i][w] != '#' and i != H-1:
                bh += 1
            elif S[i][w] == '#':
                for ash in range(sh, i):
                    S[ash][w] = bh
                bh = 0
                sh = i+1
                #print(sh,bh)
            elif i == H-1:
                bh += 1
                #print('err')
                for ash in range(sh, H):
                    S[ash][w] = bh
    return S
#print(S)
import itertools
from concurrent.futures import ProcessPoolExecutor as PPE
with PPE(max_workers=2) as exe:
    Ss = []
    for aS in exe.map(pmap, [hmap, wmap]):
        Ss.append(list(itertools.chain.from_iterable(aS)))
r = 0
for s1, s2 in zip(Ss[0], Ss[1]):
    if str(s1).isdecimal():
        r = max(r, s1 + s2)
print(r-1)

Submission status: Runtime Error

Solution code:
import numpy as np
H, W = list(map(int, input().split()))

dd = {}
s = []
for i in range(H):
    s.append(input())
    dd[i] = [l for l, s in enumerate(s[-1]) if s=='#']

ss = {}
for i in range(W):
    ss[i] = []
    for j in range(H):
        if s[j,i]=="#":
            ss[i].append(j)

mat_w = np.zeros((H,W))
for i in range(H):
    part = dd[i]
    if len(part)>0:
        mat_w[i,:part[0]-1] += part[0]
        for j in range(1,len(part)-1):
            mat_w[i,part[j-1]+1:part[j]] += part[j]-part[j-1]-1
        mat_w[i,part[-1]+1:] += W-part[-1]-1
for i in range(W):
    part = ss[i]
    if len(part)>0:
        mat_w[:part[0]-1,i] += part[0]
        for j in range(1,len(part)-1):
            mat_w[part[j-1]+1:part[j],i] += part[j]-part[j-1]-1
        mat_w[part[-1]+1:,i] += W-part[-1]-1
print(mat_w.max())

Submission status: Runtime Error

Solution code:
import numpy as np
n,m=map(int,input().split())
s=np.zeros((n,m))


for i in range(n):
    a=list(map(int,input().split()))
    for j in range(m):
        if a[j]=="#":
            s[i][j]=1
    

def tmp(i,j,s,n,m):
    if s[i][j]==1:
        return(0)
    t=0
    for k in range(k,n):
        if s[k][j]==1:
            break
        t+=1
    for k in l[:k:-1]:
        if s[k][j]==1:
            break
        t+=1
    for k in range(k,m):
        if s[i][k]==1:
            break
        t+=1
    for k in l[:k:-1]:
        if s[i][k]==1:
            break
        t+=1
        
    

ans=0
for i in range(n):
    for j in range(m):       
        
        ans=max(ans,tmp(i,j,s,n,m))
        
print(ans-1)

Submission status: Runtime Error

Solution code:
H,W=map(int,input().split())
arr=[]
for i in range(H):
    arr.append(list(input()))
lw=[[0 for i in range(W)] for j in range(H)]
lh=[[0 for i in range(W)] for j in range(H)]
for i in range(H):
    flgh=0
    cnt=0
    tmp=0
    for j in range(W):
        if arr[i][j]==".":
            if flgh==0:
                flgh=1
                tmp=j
            cnt+=1
        else:
            flgh=0
            for k in range(tmp,j):
                lw[i][k]=cnt
            cnt=0
        if j==W-1:
            flgh=0
            for k in range(tmp,j):
                lw[i][k]=cnt
            cnt=0
            
for i in range(W):
    flgw=0      
    cnt=0
    tmp=0
    for j in range(H):
        if arr[j][i]==".":
            if flgw==0:
                flgw=1
                tmp=j
            cnt+=1
        else:
            flgw=0
            for k in range(tmp,j):
                lh[k][i]=cnt
            cnt=0
        if j==H-1:
            flgw=0
            for k in range(tmp,j):
                lh[k][i]=cnt
            cnt=0
ma=0
for i in range(W):
    for j in range(H):
        z=lh[i][j]+lw[i][j]
        if z>=ma:
            ma=z
print(ma)