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 = [int(i) for i in input().split()]

mymap = [] 
for i in range(H):
    mymap.append(list(input()))
Lmap = list(list(-1 for a in range(W)) for b in range(H)) 
Rmap = list(list(-1 for a in range(W)) for b in range(H)) （逆順）
Umap = list(list(-1 for a in range(W)) for b in range(H)) 
Dmap = list(list(-1 for a in range(W)) for b in range(H)) （逆順）

#Lmap
for i in range(H):
  mycnt = 1
  for j in range(W):
    if mymap[i][j] == '#':
      Lmap[i][j] = 0
      mycnt = 1
    else: 
      Lmap[i][j] = mycnt
      mycnt += 1

#Rmap
for i in range(H):
  mycnt = 1
  for j in reversed(range(W)):
    if mymap[i][j] == '#':
      Rmap[i][j] = 0
      mycnt = 1
    else: 
      Rmap[i][j] = mycnt
      mycnt += 1

#Umap
for i in range(W):
  mycnt = 1
  for j in range(H):
    if mymap[j][i] == '#':
      Umap[j][i] = 0
      mycnt = 1
    else: 
      Umap[j][i] = mycnt
      mycnt += 1

#Dmap
for i in range(W):
  mycnt = 1
  for j in reversed(range(H)):
    if mymap[j][i] == '#':
      Dmap[j][i] = 0
      mycnt = 1
    else: 
      Dmap[j][i] = mycnt
      mycnt += 1

      
mymax = -99
for i in range(H):
  for j in range(W):
    if Lmap[i][j]+ Rmap[i][j]+ Umap[i][j]+ Dmap[i][j] > mymax:
      mymax = Lmap[i][j]+ Rmap[i][j]+ Umap[i][j]+ Dmap[i][j] 
      
print(mymax-3)


H, W = [int(i) for i in input().split()]

mymap = [] 
for i in range(H):
    mymap.append(list(input()))
Lmap = list(list(-1 for a in range(W)) for b in range(H)) 
Rmap = list(list(-1 for a in range(W)) for b in range(H)) （逆順）
Umap = list(list(-1 for a in range(W)) for b in range(H)) 
Dmap = list(list(-1 for a in range(W)) for b in range(H)) （逆順）

#Lmap
for i in range(H):
  mycnt = 1
  for j in range(W):
    if mymap[i][j] == '#':
      Lmap[i][j] = 0
      mycnt = 1
    else: 
      Lmap[i][j] = mycnt
      mycnt += 1

#Rmap
for i in range(H):
  mycnt = 1
  for j in reversed(range(W)):
    if mymap[i][j] == '#':
      Rmap[i][j] = 0
      mycnt = 1
    else: 
      Rmap[i][j] = mycnt
      mycnt += 1


for i in range(W):
  mycnt = 1
  for j in reversed(range(H)):
    if mymap[j][i] == '#':
      Dmap[j][i] = 0
      mycnt = 1
    else: 
      Dmap[j][i] = mycnt
      mycnt += 1

#Umap
for i in range(W):
  mycnt = 1
  for j in range(H):
    if mymap[j][i] == '#':
      Umap[j][i] = 0
      mycnt = 1
    else: 
      Umap[j][i] = mycnt
      mycnt += 1

      

mymax = -99
for i in range(H):
  mycnt = 1
  for j in range(W):
    if mymap[i][j] == '#':
      Lmap[i][j] = 0
      mycnt = 1
    else: 
      Lmap[i][j] = mycnt
      mycnt += 1
      
      if Lmap[i][j]+ Rmap[i][j]+ Umap[i][j]+ Dmap[i][j] > mymax:
        mymax = Lmap[i][j]+ Rmap[i][j]+ Umap[i][j]+ Dmap[i][j] 
        
print(mymax-3)

import numpy as np


H, W = [int(i) for i in input().split()]

mymap = [] 
for i in range(H):
    mymap.append(list(input()))
Lmap = list(list(-1 for a in range(W)) for b in range(H)) 
Rmap = list(list(-1 for a in range(W)) for b in range(H)) （逆順）
Umap = list(list(-1 for a in range(W)) for b in range(H)) 
Dmap = list(list(-1 for a in range(W)) for b in range(H)) （逆順）

#Lmap
for i in range(H):
  mycnt = 1
  for j in range(W):
    if mymap[i][j] == '#':
      Lmap[i][j] = 0
      mycnt = 1
    else: 
      Lmap[i][j] = mycnt
      mycnt += 1
      
#Rmap
for i in range(H):
  mycnt = 1
  for j in reversed(range(W)):
    if mymap[i][j] == '#':
      Rmap[i][j] = 0
      mycnt = 1
    else: 
      Rmap[i][j] = mycnt
      mycnt += 1


for i in range(W):
  mycnt = 1
  for j in reversed(range(H)):
    if mymap[j][i] == '#':
      Dmap[j][i] = 0
      mycnt = 1
    else: 
      Dmap[j][i] = mycnt
      mycnt += 1

#Umap
for i in range(W):
  mycnt = 1
  for j in range(H):
    if mymap[j][i] == '#':
      Umap[j][i] = 0
      mycnt = 1
    else: 
      Umap[j][i] = mycnt
      mycnt += 1

print(np.max(np.array(Lmap)+np.array(Rmap)+np.array(Umap)+np.array(Dmap)) -3)




H, W = [int(i) for i in input().split()]

mymap = [] 　
myansmap = list(list(-1 for a in range(W)) for b in range(H))　
myansmap2 = list(list(-1 for a in range(W)) for b in range(H))　


for i in range(H):
  myinput =  input()
  for j in range(W):
    if myinput[j] == '#':
      myansmap[i][j] = 0
    elif myinput[j] == '.':
      if myansmap [i][j] == -1 :
        mycnt = 0
        for m in range(j,W):
          if myinput[m] == '#':
            break
          mycnt += 1
      for k in range(j, m+1):
        myansmap[i][k] = mycnt
  mymap.append(myinput)

mymax = -99　


for i in range(H):
  for j in range(W):
    
    if myansmap2 [i][j] == -1:
      mycnt = 0
      for m in range(i,H):
        if myansmap[m][j] == 0:
          break
        mycnt += 1
      for k in range(i, m+1):
        if i > 0 and i < H or  j > 0 and i < W:
          myansmap2[k][j] = mycnt
        else: 
          myansmap2[k][j] = mycnt
    if myansmap[i][j] == 0:
      myansmap2[i][j] = 0

      
    if mymax < myansmap[i][j] + myansmap2[i][j]:
      mymax=myansmap[i][j] + myansmap2[i][j]

print(mymax-1) 



import numpy as np
 
H, W = map(int, input().split())

mymap = [] 
for i in range(H):
    mymap.append(list(input()))


mymap = (np.array(mymap) == ".")
  
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 j in range(W):
  if j == 0: 
    L[:, j] = mymap[:, j] #true = 1, false = 0
  else:
    L[:, j] = (L[:, j - 1] + 1) * mymap[:, j] 


for j in range(W - 1, -1, -1): 
  if j >= W - 1: 
    R[:, j] = mymap[:, j]
  else:
    R[:, j] = (R[:, j + 1] + 1) * mymap[:, j] 


for i in range(H):
  if i <= 0: 
    U[i, :] = mymap[i, :]
  else:
    U[i, :] = (U[i - 1, :] + 1) * mymap[i, :]


for i in range(H - 1, -1, -1):
  if i >= H - 1: 
    D[i, :] = mymap[i, :]
  else:
    D[i, :] = (D[i + 1, :] + 1) * mymap[i, :]


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



Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Runtime Error

Accepted