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

H, W = map(int, input().split())
grid = []
for i in range(H):
    tmp = input()
    grid.append(tmp)


import numpy as np
grid_int = np.zeros((H, W))
for i in range(H):
    count = 0
    for j in range(W):
        if grid[i][j] == '.':
            count += 1
            if j == W - 1:
                grid_int[i, j-count + 1:j + 1] = count
        elif grid[i][j] == '#':
            if j == 0:
                continue
            grid_int[i, j- count, j] = count
            count = 0


for j in range(W):
    count = 0
    for i in range(H):
        if grid[i][j] == '.':
            count += 1
            if i == H - 1:
                grid_int[i - count + 1: i + 1, j] += count
        elif grid[i][j] == '#':
            if i == 0:
                continue
            grid_int[i-count: i, j] += count
            count = 0

ans = 0
for i in range(H):
    tmp_max = max(grid_int[i]) - 1
    if ans < tmp_max:
        ans = tmp_max
print(int(ans))



H, W = map(int, input().split())
grid = []
for i in range(H):
    tmp = input()
    grid.append(tmp)


import NumPy as np
grid_int = np.zeros(H, W)
for i in range(H):
    count = 0
    for j in range(W):
        if grid[i][j] == '.':
            count += 1
            if j == W - 1:
                for l in range(count):
                    grid_int[i][j-l] = count
        elif grid[i][j] == '#':
            if j == 0:
                continue
            for k in range(count):
                grid_int[i][j- k - 1] = count
            count = 0


for j in range(W):
    count = 0
    for i in range(H):
        if grid[i][j] == '.':
            count += 1
            if i == H - 1:
                for m in range(count):
                    grid_int[i - m][j] += count
        elif grid[i][j] == '#':
            if i == 0:
                continue
            for k in range(count):
                grid_int[i-k-1][j] += count
            count = 0

ans = 0
for i in range(H):
    tmp_max = max(grid_int[i]) - 1
    if ans < tmp_max:
        ans = tmp_max
print(ans)


H, W = map(int, input().split())
grid = []
for i in range(H):
    tmp = input()
    grid.append(tmp)


import numpy as np
grid_int = np.zeros((H, W))
for i in range(H):
    count = 0
    for j in range(W):
        if grid[i][j] == '.':
            count += 1
            if j == W - 1:
                grid_int[i, j-count + 1:j + 1] = count
        elif grid[i][j] == '#':
            if j == 0:
                continue
            grid_int[i, j- count, j] = count
            count = 0


for j in range(W):
    count = 0
    for i in range(H):
        if grid[i][j] == '.':
            count += 1
            if i == H - 1:
                grid_int[i - count + 1, i + 1, j] += count
        elif grid[i][j] == '#':
            if i == 0:
                continue
            grid_int[i-count: i, j] += count
            count = 0

ans = 0
for i in range(H):
    tmp_max = max(grid_int[i]) - 1
    if ans < tmp_max:
        ans = tmp_max
print(int(ans))



H, W = map(int, input().split())
grid = []
for i in range(H):
    tmp = input()
    grid.append(tmp)


import numpy as np
grid_int = np.zeros(H, W)
for i in range(H):
    count = 0
    for j in range(W):
        if grid[i][j] == '.':
            count += 1
            if j == W - 1:
                for l in range(count):
                    grid_int[i][j-l] = count
        elif grid[i][j] == '#':
            if j == 0:
                continue
            for k in range(count):
                grid_int[i][j- k - 1] = count
            count = 0


for j in range(W):
    count = 0
    for i in range(H):
        if grid[i][j] == '.':
            count += 1
            if i == H - 1:
                for m in range(count):
                    grid_int[i - m][j] += count
        elif grid[i][j] == '#':
            if i == 0:
                continue
            for k in range(count):
                grid_int[i-k-1][j] += count
            count = 0

ans = 0
for i in range(H):
    tmp_max = max(grid_int[i]) - 1
    if ans < tmp_max:
        ans = tmp_max
print(ans)

#import sys

import numpy as np

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

    up = np.zeros((H,W), dtype=int)
    down = np.zeros((H,W), dtype=int)
    left = np.zeros((H,W), dtype=int)
    right = np.zeros((H,W), dtype=int)
    
    for i in range(H-1):
        up[i+1,:] = (up[i,:] + 1) * S[i,:] 
    for i in range(H-1):                   
        down[H - 2 - i,:] = (down[H - 1 - i,:] + 1) * S[H - 1 - i,:]
    for i in range(W-1):
        left[:,i+1] = (left[:,i] + 1) * S[:,i]
    for i in range(W-1):
        right[:,H - 2 - i] = (right[:,H - 1 - i] + 1) * S[:,H - 1 - i]
        
    print(((up+down+left+right)*S).max()+1) 
    
if __name__ == "__main__":
    main()



H, W = map(int, input().split())
grid = []
for i in range(H):
    tmp = input()
    grid.append(tmp)


import numpy
grid_int = [[0] * W for i in range(H)]
grid_int = np.array(grid_int)
for i in range(H):
    count = 0
    for j in range(W):
        if grid[i][j] == '.':
            count += 1
            if j == W - 1:
                for l in range(count):
                    grid_int[i][j-l] = count
        elif grid[i][j] == '#':
            if j == 0:
                continue
            for k in range(count):
                grid_int[i][j- k - 1] = count
            count = 0


for j in range(W):
    count = 0
    for i in range(H):
        if grid[i][j] == '.':
            count += 1
            if i == H - 1:
                for m in range(count):
                    grid_int[i - m][j] += count
        elif grid[i][j] == '#':
            if i == 0:
                continue
            for k in range(count):
                grid_int[i-k-1][j] += count
            count = 0

ans = 0
for i in range(H):
    tmp_max = max(grid_int[i]) - 1
    if ans < tmp_max:
        ans = tmp_max
print(ans)

#import sys

import numpy as np

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

    up = np.zeros((H,W), dtype=int)
    down = np.zeros((H,W), dtype=int)
    left = np.zeros((H,W), dtype=int)
    right = np.zeros((H,W), dtype=int)
    
    for i in range(H-1):
        up[i+1,:] = (up[i,:] + 1) * S[i,:] 
    for i in range(H-1):                   
        down[H - 2 - i,:] = (down[H - 1 - i,:] + 1) * S[H - 1 - i,:]
    for i in range(W-1):
        left[:,i+1] = (left[:,i] + 1) * S[:,i]
    for i in range(W-1):
        right[:,W - 2 - i] = (right[:,W - 1 - i] + 1) * S[:,W - 1 - i]
        
    print(((up+down+left+right)*S).max()+1) 
    
if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted