Problem: 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.

Submission attempts (in order):
import numpy as np

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

maze_x = [input() for _ in range(H)]
maze_y = [''.join(x) for x in zip(*maze_x)]

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst1 = [i for i in maze[hh].split('
        lst2 = [i for i in maze[hh].split('.') if i != '']
        lst2.append('#')
        ww = 0
        k1 = 0
        k2 = 0
        if maze[hh][0]=='#':
            ww += len(lst2[0])
            k2 += 1
          
        while len(lst1)>k1:
            ln = len(lst1[k1])
            cnt[hh][ww:ww+ln] = [ln]*ln
            k1 += 1

            ln = len(lst2[k2])
            cnt[hh][ww:ww+ln] = [0]*ln
            k2 += 1
            ww += ln
    return cnt
cnt = (np.array(count_light(maze_x, W, H)) + np.array(count_light(maze_y, H, W)).T -1)

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


import numpy as np

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

maze_x = [input() for _ in range(H)]
maze_y = [''.join(x) for x in zip(*maze_x)]

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst = [i for i in maze[hh].split('
        ww = 0
        k = 0
        while 0 <= ww <= W - 1:
            if maze[hh][ww] == '.':
                ln = len(lst[k])
                cnt[hh][ww:ww+ln] = [ln]*ln
                ww += ln-1
                k += 1
            ww += 1
    return cnt
cnt = (np.array(count_light(maze_x, W, H)) + np.array(count_light(maze_y, H, W)).T -1)

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


import numpy as np

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

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

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst1 = [i for i in maze[hh].split('
        lst2 = [i for i in maze[hh].split('.') if i != '']
        ww = 0
        k1 = 0
        k2 = 0
        if maze[hh][0]=='#':
            ww += len(lst2[0])
            k2 += 1
          
        while len(lst1)>k1:
            if maze[hh][ww] == '.':
                ln = len(lst1[k1])
                cnt[hh][ww:ww+ln] = [ln]*ln
                k1 += 1
                ww += ln
            else:
                ln = len(lst2[k2])
                cnt[hh][ww:ww+ln] = [0]*ln
                k2 += 1
                ww += ln

    return cnt
u = np.zeros((H, W), dtype=np.int32)
l = np.zeros((H, W), dtype=np.int32)

u[0] = maze01[0]
l[H - 1] = maze01[H - 1]
for hh in range(1,H):
    u[hh] = u[hh-1] + maze01[hh]
    u[hh] = [x * y for x, y in zip(u[hh], maze01[hh])]
    l[H - hh - 1, :] = l[H - hh] + maze01[H - hh - 1]
    l[H - hh - 1] = [x * y for x, y in zip(l[H - hh -1], maze01[H - hh - 1])]

cnt = np.array(count_light(maze_x, W, H)) + u + l - 2

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


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

maze = [input() for _ in range(H)]

light_max = 0

def light(xx, yy):
    ans = 0
    for dy in [-1, 1]:
        xx0 = xx
        yy0 = yy + dy
        while 0 <= yy0 <= H-1:
            if maze[yy0][xx0] == '#':break
            ans += 1
            yy0 += dy
    return ans

for hh in range(H):
    hh_lst = [i for i in maze[hh].split('
    ww = 0
    k = 0
    while ww<=W-1:
        if maze[hh][ww] == '.':
            for j in range(len(hh_lst[k])):
                light_max = max(light_max, light(ww + j, hh)+len(hh_lst[k]))
                
            ww += j
            k += 1
        ww += 1
print(light_max)

import numpy as np

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

maze_x = [input() for _ in range(H)]
maze_y = [''.join(x) for x in zip(*maze_x)]

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst1 = [i for i in maze[hh].split('
        ww = 0
        k = 0
        while 0 <= ww <= W - 1:
            if maze[hh][ww] == '.':
                ln = len(lst1[k])
                cnt[hh][ww:ww+ln] = [ln]*ln
                ww += ln-1
                if len(lst1)==k:break
                k += 1
            ww += 1
    return cnt
cnt = (np.array(count_light(maze_x, W, H)) + np.array(count_light(maze_y, H, W)).T -1)

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


import numpy as np

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

maze_x = [input() for _ in range(H)]
maze_y = [''.join(x) for x in zip(*maze_x)]

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst1 = [i for i in maze[hh].split('
        lst2 = [i for i in maze[hh].split('.') if i != '']
        
        ww = 0
        k1 = 0
        k2 = 0
        while len(lst1)>k1:
            if maze[hh][ww] == '.':
                ln = len(lst1[k1])
                cnt[hh][ww:ww+ln] = [ln]*ln
                k1 += 1
            else:
                ln = len(lst2[k2])
                cnt[hh][ww:ww+ln] = [0]*ln
                k2 += 1
            ww += ln
    return cnt
cnt = (np.array(count_light(maze_x, W, H)) + np.array(count_light(maze_y, H, W)).T -1)

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

import numpy as np

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

maze_x = [input() for _ in range(H)]
maze_y = [''.join(x) for x in zip(*maze_x)]

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst1 = [i for i in maze[hh].split('
        lst2 = [i for i in maze[hh].split('.') if i != '']
        
        ww = 0
        k1 = 0
        k2 = 0
        
        while 0 <= ww <= W - 1:
            if maze[hh][ww] == '.':
                ln = len(lst1[k1])
                cnt[hh][ww:ww+ln] = [ln]*ln
                ww += ln
                if len(lst1)==k1:break
                k1 += 1
            else:
                ln = len(lst2[k2])
                cnt[hh][ww:ww+ln] = [0]*ln
                ww += ln
                k2 += 1
    return cnt
cnt = (np.array(count_light(maze_x, W, H)) + np.array(count_light(maze_y, H, W)).T -1)

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


import numpy as np

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

maze_x = [input() for _ in range(H)]
maze_y = [''.join(x) for x in zip(*maze_x)]

def count_light(maze, W, H):
    cnt = [[0]*W for _ in range(H)]
    for hh in range(H):
        lst = [i for i in maze[hh].split('
        ww = 0
        k = 0
        while 0 <= ww <= W - 1:
            if maze[hh][ww] == '.':
                for i in range(len(lst[k])):
                    cnt[hh][ww + i] = len(lst[k])
                ww += i
                k += 1
            ww += 1
    return cnt

cnt_x = np.array(count_light(maze_x, W, H))
cnt_y = np.array(count_light(maze_y, H, W))
cnt = (cnt_y.T + cnt_x - 1).tolist()

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


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)]))


Verdicts: Wrong Answer

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Accepted