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

import numpy as np
import sys
buf = sys.stdin.buffer

H,W = map(int,buf.readline().split())

grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1))+b'\n',dtype='S1') == b'.').reshape((H,W+1))


def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  L = len(x)
  
  left_zero = -np.arange(L) 
  left_zero[x] = 0
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = np.arange(L) 
  right_zero[x[::-1]] = 0
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)



import numpy as np
import sys


def get_data(stream):
    buf = b''
    b = stream.buffer.read(1)
    while b != b'\n':
        buf += b
        b = stream.buffer.read(1)
    H, W = map(int, buf.split())
    c = stream.buffer.read(H * (W + 1))
    arr = np.array(c.split())
    arr = np.frombuffer(arr, dtype='S1').reshape((H, W))
    return H, W, arr


def main():
    H, W, arr = get_data(sys.stdin)
    

if __name__ == "__main__":
    main()


import numpy as np

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

grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:-1] = (np.array([list(input()) for _ in range(H)]) == '.')

L = grid.size
a = np.arange(L)


def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  
  left_zero = -a 
  left_zero[x] = 0
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = a 
  right_zero[x[::-1]] = 0
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)


import numpy as np

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

map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1


def F(transpose,reverse):
  x = map.copy()
  if transpose:
    x = x.T
  x = np.ravel(x)
  if reverse:
    x = x[::-1]
  zero_idx = np.nonzero(x==0)[0]
  x[zero_idx[1:]] = 1-np.diff(zero_idx) 
  x = x.cumsum()
  if reverse:
    x = x[::-1]
  if transpose:
    x = x.T
  return x.reshape(map.T.shape).T

answer = np.zeros_like(map)
for t in [True,False]:
  for r in [True,False]:
    answer += F(t,r)
    
answer = answer.max() - 3
print(answer)


import numpy as np

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

grid = (np.array([list(input()) for _ in range(H)]) == '.')



import numpy as np
import sys
buf = sys.stdin.buffer

H,W = map(int,buf.readline().split())

grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1))




import numpy as np

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

grid = np.array([list(input()) for _ in range(H)])



import numpy as np
import sys
buf = sys.stdin.buffer

H,W = map(int,buf.readline().split())

grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1))



import numpy as np

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

grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:-1] = (np.array([list(input()) for _ in range(H)]) == '.')


import numpy as np

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

map = np.ones((H+1,W+1),dtype=np.bool)
map[1:,1:] = (temp == '#')


def F(transpose):
  x = map.copy()
  if transpose:
    x = x.T
  x = np.ravel(x) # to 1D array
  
  zero_idx = np.nonzero(x)[0]
  zero_span = np.diff(zero_idx) - 1 
  y = np.zeros(len(x),dtype=np.int32)
  y[1:][zero_idx[:-1]] = zero_span
  y[zero_idx[1:]] -= zero_span
  y = y.cumsum()
  if transpose:
    y = y.reshape(map.T.shape).T
  else:
    y = y.reshape(map.shape)
  return y

answer = np.zeros(map.shape,dtype=np.int32)
for t in [True,False]:
  answer += F(t)
    
answer = answer.max() - 1
print(answer)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W = map(int,readline().split())
floor = np.frombuffer(read(),dtype='S1').reshape(H,-1)[:,:W] == b'.'

score = np.zeros((H,W),np.int32)

x = np.zeros((H,W),np.int32)
for n in range(1,H):
    x[n] = (1+x[n-1])*floor[n-1]
score += x

x[:] = 0
for n in range(H-1,0,-1):
    x[n-1] = (1+x[n])*floor[n]
score += x

x[:] = 0
for n in range(1,W):
    x[:,n] = (1+x[:,n-1])*floor[:,n-1]
score += x

x[:] = 0
for n in range(W-1,0,-1):
    x[:,n-1] = (1+x[:,n])*floor[:,n]
score += x

score *= floor
answer = score.max() + 1
print(answer)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted