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())
data=[list(input()) for i in range(h)]
map1=[[0]*w for i in range(h)]
map2=[[0]*w for i in range(h)]
for i in range(h):
  count=0
  for j in range(w):
    if data[i][j]=="#":
      count=0
    else:
      count+=1
      map1[i][j]=count
  count=0
  for j in range(w):
    if map1[i][-1-j]==0:
      count=0
    else:
      if count==0:count=map1[i][-1-j]
      map1[i][-1-j]=count
for i in range(w):
  count=0
  for j in range(h):
    if data[j][i]=="#":
      count=0
    else:
      count+=1
      map2[j][i]=count
  count=0
  for j in range(h):
    if map2[-j-1][i]==0:
      count=0
    else:
      count=max(map2[-j-1][i],count)
      map2[-j-1][i]=count
ans=0
import numpy
map1=numpy.ndarray(map1)
map2=numpy.ndarray(map2)
map3=map1+map2
print(int(max(map3)-1))

Submission status: Runtime Error

Solution code:

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

yoko = 0
for h in range(H):
  yoko = max(len(max(S[h].split("#"))), yoko)
  
 ans = 0
for hw in zip(*S):
  hw = "".join(hw)
  t = len(max(hw.split("#")))
  ans = max(yoko+t-1, ans)

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

field = np.zeros((H,W))

for i in range(H):
    S = input().rstrip()
    for j in range(W):
        if S[j] == '#':
            field[i, j] = 1
        
lighted_max = 0
lighted_total =0
for i in range(H): 
    row_slice = field[i,:]
      
    for j in range(W):
        if field[i, j] == 1:
            continue
           
        lighted_row = 1
        k = j
        while k > 0:
            if row_slice[k] == 1:
              	lighted_row-=1
                break
            lighted_row += 1
            k -= 1
            
        k = j+1
        while k < W:
            if row_slice[k] == 1:
                break
            lighted_row += 1
            k+=1
        
        col_slice = field[:, j]
        
        
        lighted_col = 0
        k = i
        while k > 0:
            if col_slice[k] == 1:
                break
            lighted_col += 1
            k -= 1
            
        k = i+1
        while k < H:
            if col_slice[k] == 1:
                break
            lighted_col += 1
            k+=1
        
        lighted_total = lighted_row + lighted_col
        if lighted_total > lighted_max:
            lighted_max = lighted_total
        
print(lighted_max-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(indexes):
                ret.extend( [index-b_index-2 for _ in range(index-b_index-1)])
            else cnt == len(indexes):
                ret.extend( [index-b_index-1 for _ in range(index-b_index-1)])
            ret.append(0)
            b_index = index
        ret.pop()
        ret.pop()
        S1.append(ret)
    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())
mp=[]
h_wall=[]
for i in range(h):
    h_wall_l=[]
    l=input()
    mp.append(l)
    for a in range(len(l)):
        if l[a]=='#':
            h_wall_l.append(a)
    h_wall.append(h_wall_l)
v_wall=[]
for i in range(w):
    vl=''
    for j in range(h):
      vl+=mp[j][i]
    v_wall_vl=[]
    for a in range(len(vl)):
        if vl[a]=='#':
            v_wall_vl.append(a)
    v_wall.append(v_wall_vl)
# h_mp=[]
# for i in h_wall:
#     if len(i)!=0:
#         hll=[]
#         first=i[0]
#         for j in range(first):
#             hll.append(first)
#         hll.append(-1)
#         if len(i)>=2:
#             for j in range(len(i)-1):
#                 mid=i[j+1]-i[j]-1
#                 for z in range(mid):
#                     hll.append(mid)
#                 hll.append(-1)
#         if len(hll)<w:
#             diff = w-len(hll)
#             for z in range(diff):
#                 hll.append(diff)
#     else:
#         hll=[w for zz in range(w)]
#     h_mp.append(hll)
# v_mp = []
# for i in v_wall:
#     if len(i)!=0:
#         vll=[]
#         first=i[0]
#         for j in range(first):
#             vll.append(first)
#         vll.append(-1)
#         if len(i)>=2:
#             for j in range(len(i)-1):
#                 mid=i[j+1]-i[j]-1
#                 for z in range(mid):
#                     vll.append(mid)
#                 vll.append(-1)
#         if len(vll)<h:
#             diff = h-len(vll)
#             for z in range(diff):
#                 vll.append(diff)
#     else:
#         vll=[h for zz in range(h)]
#     v_mp.append(vll)
# # for i in v_mp:
# #     print(i)
# # print("---")

# v_mp = [list(x) for x in zip(*v_mp)]
# # for i in h_mp:
# #     print(i)
# # print("---")
# # for i in v_mp:
# #     print(i)

maxx=1

for i in range(h):
    for j in range(w):
        # hhh = h_mp[i][j]
        # vvv = v_mp[i][j]
        hhh = 3
        www = 3
        if hhh != -1 and vvv != -1:
            temp = hhh+vvv-1
            if temp >= maxx:
                maxx=temp
print(maxx)

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
    piyo = 0
    hoge = [0]*H
    for j in range(W):
        #print(i,j,S[i][j])
        if S[i][j] == ".":
            cou += 1
        else:
            hoge[piyo]= cou
            piyo += 1
            cou = 0
    hoge[piyo] = cou
    ws = []
    for j in hoge[:piyo+1]:
        ws = ws+[j]*j+[0]
    #print(ws,ws[:-1])
    Grid1[i] = ws[:-1]

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

print(ans-1)

Submission status: Runtime Error

Solution code:
h, w = (int(_) for _ in input().split())
grid = []

litfinal = []
if h == 1 and w == 1:
    print(1)
else:
    for i in range(h):
        lit = []
        row = input()
        grid.append(row)
        end = False
        pos = 0
        prev = 0
        hori = w
        first = True
        while not end:
            pos = row.find('#', pos)
            if pos == -1:
                for j in range(prev, w-1):
                    lit.append([hori])
                end = True
            elif pos != 0:
                if first:
                    for j in range(pos - prev):
                        lit.append([pos - prev])
                    first = False
                    lit.append([0])
                else:
                    if pos - prev == 1:
                        lit.append([0])
                    else:
                        for j in range(pos - prev - 1):
                            lit.append([pos - prev - 1])
                            lit.append([0])
                hori = hori - (pos-prev) - 1
            else:
                lit.append([0])
            prev = pos
            pos += 1
        litfinal.append(lit)
    ans = 0
    for i in range(w):
        pos = []
        prev = 0
        for j in range(h):
            if grid[j][i] == '#':
                pos.append(j)
        vert = h
        if pos == []:
            for c in range(h):
                litfinal[c][i].append(vert)
                total = litfinal[c][i][0] + litfinal[c][i][1]
                if total > ans:
                    ans = total
        for k in range(len(pos)):
            if k == 0:
                if pos[k] != 0:
                    for c in range(pos[k]):
                        litfinal[c][i].append(pos[k])
                        total = litfinal[c][i][0] + litfinal[c][i][1]
                        if total > ans:
                            ans = total
            else:
                for c in range(prev + 1, pos[k]):
                    litfinal[c][i].append(pos[k] - prev - 1)
                    total = litfinal[c][i][0] + litfinal[c][i][1]
                    if total > ans:
                        ans = total
            prev = pos[k]   
print(ans-1)        
        

#print(litfinal)

Submission status: Runtime Error

Solution code:
h, w = map(int,input().split())
sList = [list(input()) for i in range(h)]
vNum = 0
hNumList = [0] * w
preSharpX = -1
preSharpYList = [-1] * w
answer = 0
for y in range(h):
  for x in range(w):
    if sList[y][x] == "#":
      vNum = 0
      hNumList[x] = 0
      preSharpX = x
      preSharpYList[x] = y
    else:
      if vNum == 0:
        for i in range(x, w):
          if sList[y][i] == "#":
            break
          else:
            vNum += 1
        vNum += (x - preSharpX - 1)
      if hNumList[x] == 0:
        for j in range(y, h):
          if sList[j][x] == "#":
            break
          else:
            hNumList[x] += 1
        hNumList[x] += (y - preSharpYList[y] - 1)
      if answer < vNum + hNumList[x] - 1:
        answer = vNum + hNumList[x] - 1
  vNum = 0
  preSharpX = -1
print(answer)

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
whole = [input() for _ in range(h)]
result = []
for hi in range(h):
  old = whole[hi]
  now = 0
  tmp = 0
  new = []
  while now < w:
    if old[now] == '#':
      new += [tmp]*tmp
      new += [0]
    else:
      tmp += 1
    now += 1
  new += [tmp]*tmp
  result.append(new)
print(result)
twhole = list(map(lambda x:[x],whole[0]))
print(twhole)
for hi in range(1,h):
  low = whole[hi]
  for wi in range(w):
    twhole[wi].append(h[wi])
print(twhole)

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

rows = [[0 for _ in range(w+1)] for _ in range(h)]
cols = [[0 for _ in range(w+1)] for _ in range(h+1)]
field = [[0 for _ in range(w)] for _ in range(h)]

for i in range(len(rows)):
  rows[i][0] = 0

for i in range(len(cols)):
  cols[0][i] = 0

# for i in range(h):
#   for j in range(1,w+1):
#     if s[i][j-1] == "#":
#       rows[i][j] = 0
#     else:
#       rows[i][j] = rows[i][j-1] + 1


# for i in range(w):
#   for j in range(1,h+1):
#     if s[j-1][i] == "#":
#       cols[j][i] = 0
#     else:
#       cols[j][i] = cols[j-1][i] + 1

# for v in rows:
#   v.pop(0)
# cols.pop(0)

# v = 0
# for i in range(h):
#   for j in reversed(range(w)):
#     v = 0 if rows[i][j] == 0 else max(v,rows[i][j])
#     rows[i][j] = v
# v = 0
# for i in range(w):
#   for j in reversed(range(h)):
#     v = 0 if cols[j][i] == 0 else max(v,cols[j][i])
#     cols[j][i] = v

# for i in range(h):
#   for j in range(w):
#     field[i][j] = rows[i][j] + cols[i][j] - 1


# print(max([max(v) for v in field]))

Submission status: Runtime Error

Solution code:
H,W=map(int,input().split())
S=list(list(input())for _ in range(H))

def dfsr(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsr(h,w+1)
    else:return
def dfsl(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsl(h,w-1)
    else:return

def dfsd(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsd(h+1,w)
    else:return

def dfsu(h,w):
    if 0<=h<=H-1 and 0<=w<=W-1 and S[h][w]=='.':
        global ans
        ans+=1
        dfsu(h-1,w)
    else:return

rans=0
ans=0
for h in range(H):
    for w in range(W):
        ans=0
        if S[h][w]=='.':
            dfsr(h,w+1)
            dfsl(h,w-1)
            dfsu(h-1,w)
            dfsd(h+1,w)
            ans+=1
            rans=max(ans,rans)
print(rans)

Submission status: Runtime Error

Solution code:

h,w = map(int,input().split())
map = []
for _ in range(h):
    map.append(input())

mapCount = [[-1]*w for _ in range(h)]
xCount = [[-1]*w for _ in range(h)]
yCount = [[-1]*w for _ in range(h)]

def counter(y,x,yoff,xoff,total):
    if x<0 or x==w or y<0 or y==h:
        return total-1
    if map[y][x] == "#":
        return total-1
    return counter(y+yoff,x+xoff,yoff,xoff,total+1)
def counterWrite(y,x,yoff,xoff,total):
    if x<0 or x==w or y<0 or y==h:
        return
    if map[y][x] == "#":
        return
    
    if xoff!=0:
        yCount[y][x] = total
    else:
        xCount[y][x] = total
    return counter(y+yoff,x+xoff,yoff,xoff,total)

for y in range(h):
    for x in range(w):
        if map[y][x] == "#":
            xCount[y][x] = 0
            yCount[y][x] = 0
            mapCount[y][x] = 0    
            continue
        if xCount[y][x]==-1:
            tmp_xCount = counter(y,x,0,1,0) + counter(y,x,0,-1,0)
            counter(y,x,0,1,tmp_xCount)
            counter(y,x,0,-1,tmp_xCount)
            xCount[y][x] = tmp_xCount
        else:
            tmp_xCount = xCount[y][x]

        if yCount[y][x]==-1:
            tmp_yCount = counter(y,x,1,0,0) + counter(y,x,-1,0,0)
            counter(y,x,1,0,tmp_yCount)
            counter(y,x,-1,0,tmp_yCount)
            yCount[y][x] = tmp_yCount
        else:
            tmp_xCount = xCount[y][x]

        mapCount[y][x] = tmp_xCount + tmp_yCount + 1

# for i in map:
#     print(i)
# for i in mapCount:
#     print(i)

ans = 0
for i in mapCount:
    for j in i:
        ans = max(ans,j)
print(ans)

# print("")
# for i in xCount:
#     print(i)
# print("")
# for i in yCount:
#     print(i)

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

rows = [[0 for _ in range(w+1)] for _ in range(h)]
cols = [[0 for _ in range(w+1)] for _ in range(h+1)]
field = [[0 for _ in range(w)] for _ in range(h)]

for i in range(len(rows)):
  rows[i][0] = 0

for i in range(len(cols)):
  cols[0][i] = 0

for i in range(h):
  for j in range(1,w+1):
    if s[i][j-1] == "#":
      rows[i][j] = 0
    else:
      rows[i][j] = rows[i][j-1] + 1


for i in range(w):
  for j in range(1,h+1):
    if s[j-1][i] == "#":
      cols[j][i] = 0
    else:
      cols[j][i] = cols[j-1][i] + 1

# for v in rows:
#   v.pop(0)
# cols.pop(0)

# v = 0
# for i in range(h):
#   for j in reversed(range(w)):
#     v = 0 if rows[i][j] == 0 else max(v,rows[i][j])
#     rows[i][j] = v
# v = 0
# for i in range(w):
#   for j in reversed(range(h)):
#     v = 0 if cols[j][i] == 0 else max(v,cols[j][i])
#     cols[j][i] = v

# for i in range(h):
#   for j in range(w):
#     field[i][j] = rows[i][j] + cols[i][j] - 1


# print(max([max(v) for v in field]))

Submission status: Runtime Error

Solution code:
import numpy as np


def getblank(li):
  cnt = 0
  ans = []
  start = []
  end = []
  i=-1
  for s in li:
    i += 1
    if s == ".":
      if cnt == 0:
        start.append(i)
      cnt += 1
      if i == len(li)-1:
        ans.append(cnt)
        end.append(i)
    else:
      if cnt > 0:
        ans.append(cnt)
        end.append(i-1)
        cnt = 0
  return ans,start,end




#input
h,w = (int(x) for x in input().split())

grid = []
for i in range(h):
  grid.append([c for c in input()])

trgrid = []
for i in range(w):
  tr_row = []
  for v in grid:
    tr_row.append(v[i])
  trgrid.append(tr_row)

ans = []
trans = []
start = []
trstart = []
end = []
trend = []

if h<w:
  for i in range(w):
    ans2,start2,end2 = getblank(trgrid[i])
    trans.append(max(ans2))
    trstart.append(start2)
    trend.append(end2)
    #print("ans2,start2,end2 = {},{},{}".format(ans2,start2,end2))
    if i < h:
      ans1,start1,end1 = getblank(grid[i])
      ans.append(max(ans1))
      start.append(start1)
      end.append(end1)
      #print("ans,start,end = {},{},{}".format(ans,start,end))
else:
  for i in range(h):
    ans1,start1,end1 = getblank(grid[i])
    ans.append(max(ans1))
    start.append(start1)
    end.append(end1)
    #print("ans,start,end = {},{},{}".format(ans,start,end))
    if i < w:
      ans2,start2,end2 = getblank(trgrid[i])
      trans.append(max(ans2))
      trstart.append(start2)
      trend.append(end2)
      #print("ans2,start2,end2 = {},{},{}".format(ans2,start2,end2))

print(max(ans)+max(trans)-1)

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

rows = [[0 for _ in range(w+1)] for _ in range(h)]
cols = [[0 for _ in range(w+1)] for _ in range(h+1)]
field = [[0 for _ in range(w)] for _ in range(h)]

for i in range(len(rows)):
  rows[i][0] = 0

for i in range(len(cols)):
  cols[0][i] = 0

for i in range(h):
  for j in range(1,w+1):
    if s[i][j-1] == "#":
      rows[i][j] = 0
    else:
      rows[i][j] = rows[i][j-1] + 1


for i in range(w):
  for j in range(1,h+1):
    if s[j-1][i] == "#":
      cols[j][i] = 0
    else:
      cols[j][i] = cols[j-1][i] + 1

# for v in rows:
#   v.pop(0)
# cols.pop(0)

v = 0
for i in range(h):
  for j in reversed(range(w)):
    v = 0 if rows[i][j] == 0 else max(v,rows[i][j])
    rows[i][j] = v
v = 0
for i in range(w):
  for j in reversed(range(h)):
    v = 0 if cols[j][i] == 0 else max(v,cols[j][i])
    cols[j][i] = v

for i in range(h):
  for j in range(w):
    field[i][j] = rows[i][j] + cols[i][j] - 1


print(max([max(v) for v in field]))

Submission status: Runtime Error

Solution code:
H, W = [int(s) for s in input().split()]
S = []
for _ in range(H):
    S.append(input())


dp_u = [[-1] * W for _ in range(H)]
dp_d = [[-1] * W for _ in range(H)]
dp_l = [[-1] * W for _ in range(H)]
dp_r = [[-1] * W for _ in range(H)]
def count_up(h, w):
    if dp_u[h][w] != -1:
        return dp_u[h][w]
    elif S[h][w] == '#':
        dp_u[h][w] = 0
        return dp_u[h][w]
    else:
        if h > 0:
            dp_u[h][w] = count_up(h - 1, w) + 1
        else:
            dp_u[h][w] = 0
        return dp_u[h][w]

def count_down(h, w):
    if dp_d[h][w] != -1:
        return dp_d[h][w]
    elif S[h][w] == '#':
        dp_d[h][w] = 0
        return dp_d[h][w]
    else:
        if h < H - 1:
            dp_d[h][w] = count_down(h + 1, w) + 1
        else:
            dp_d[h][w] = 0
        return dp_d[h][w]

def count_left(h, w):
    if dp_l[h][w] != -1:
        return dp_l[h][w]
    elif S[h][w] == '#':
        dp_l[h][w] = 0
        return dp_l[h][w]
    else:
        if w > 0:
            dp_l[h][w] = count_left(h, w - 1) + 1
        else:
            dp_l[h][w] = 0
        return dp_l[h][w]

def count_right(h, w):
    if dp_r[h][w] != -1:
        return dp_r[h][w]
    elif S[h][w] == '#':
        dp_r[h][w] = 0
        return dp_r[h][w]
    else:
        if w < W - 1:
            dp_r[h][w] = count_right(h, w + 1) + 1
        else:
            dp_r[h][w] = 0
        return dp_r[h][w]


# north, west, south, east
best = 0
for h in range(H):
    for w in range(W):
        if S[h][w] != '#':
            best = max([best, count_up(h, w) + count_down(h, w) + count_left(h, w) + count_right(h, w)])

print(best)

Submission status: Runtime Error

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

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)

# print(HL)
# print(WL)

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

Submission status: Runtime Error

Solution code:
 import numpy as np
def cal(S, xx):
    S1 = []
    for s in S:
        s2  = "".join(s)
        indexes = [i for i, x in enumerate(s) if x == "#"]
        indexes.append(xx+1)
        li3 = [len(ss) for ss in s2.split("#")]
        
        cnt = 0
        ret = []
        b_index = 0
        for index in indexes:
            if cnt == 0:
                ret.extend( [li3[cnt] for _ in range(index-b_index)])
            else:
                ret.extend( [li3[cnt] for _ in range(index-b_index-1)])
            ret.append(0)
            b_index = index
            cnt += 1
        ret.pop()
        ret.pop()
        S1.append(ret)
    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:
from sys import stdin
hw = [int(i) for i in stdin.readline().rstrip().split(" ")]
r = []
for i in range(hw[0]):
    r.append(stdin.readline().rstrip())
c = []
for i in range(hw[1]):
    c.append("".join([r[j][i] for j in range(hw[0])]))
result = 0
for i in range(hw[0]):
    for j in range(hw[1]):
        tmp = 0
        if r[i][j] == "#":
            continue;
        else:
            for p in range(j):
                if r[i][j-1-p] == ".":
                    tmp +=1
                else:
                    break;
            for p in range(hw[1] - j - 1):
                if r[i][j+p+1] == ".":
                    tmp +=1
                else:
                    break;
            for q in range(i):
                if c[j][i-1-j]== ".":
                    tmp +=1
                else:
                    break;
            for q in range(hw[0]-i-1):
                if c[j][i+q+1]== ".":
                    tmp +=1
                else:
                    break;
            if result < tmp:
                result = tmp
print(result+1)

Submission status: Runtime Error

Solution code:
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(i, y) returns the tuple (i//y, i%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose same words: Ctrl+Shift+l
import sys
from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
from math import factorial
def combinations_count(n, r):
    # faster than the following code
    # def combinations_count(n, r):
    #     return factorial(n) // (factorial(n - r) * factorial(r))
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combination_with_repetition_count(n, r):
    return combinations_count(n + r - 1, r)
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from functools import reduce
from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(i, y):
    return (i * y) // gcd(i, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)
# set the inputs
    # open(0).read() is a convenient method:
    # ei) n, m, *i = map(int, open(0).read().split())
    #     min(i[::2]) - mai(i[1::2])
    # ei2) *i, = map(int, open(0).read().split())
    #     don't forget to add comma after *i if only one variable is used
    # R = lambda: map(int, input().split()) :it's fashionable, isn't it?
    # ei1) n, k = R()
    # ei2) v = list(R())
    # ei3) bc = [list(R()) for i in range(m)]

# R = lambda: list(map(int, input().split()))
# n = int().input()
# ab = [R() for i in range(n)]
# c = R()
# c = sorted(c, reverse = True)

# R = lambda: list(map(int, input().split()))
h, w = R()
s = [input() for i in range(h)]

# h, w = 4, 6
# s = ["#..#..",".....#","....#.","#.#..."]
s_ = [list(x) for x in zip(*s)]

ho = [[0]*w for i in range(h)]
he = [[0]*h for i in range(w)]

for j,str in enumerate(s):
    count = 0
    col = 0
    for i, eachstr in enumerate(str):
        if eachstr == "#":
            if i == 0:
                pass
            else:
                for k in range(col,i):
                    ho[j][k] = count
            col = i + 1
            count = 0
        else:
            count += 1
    else:
        if col < w:
            for k in range(col,i+1):
                ho[j][k] = count

for j,str in enumerate(s_):
    count = 0
    col = 0
    for i, eachstr in enumerate(str):
        if eachstr == "#":
            if i == 0:
                pass
            else:
                for k in range(col,i):
                    he[j][k] = count
            col = i + 1
            count = 0
        else:
            count += 1
    else:
        if col < w:
            for k in range(col,i+1):
                he[j][k] = count

he_ = [list(x) for x in zip(*he)]

ans = 0
for i,j in zip(ho,he_):
    for ss, tt in zip(i,j):
        ans = max(ans, ss+tt)
print(ans-1)

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
S = [0 for i in range(H)]
for i in range(H):
    S[i] = input()
T = ['' for j in range(W)]
for j in range(W):
    for i in range(H):
        T[j] += S[i][j]
#print(T)
yoko = [[0 for j in range(W)] for i in range(H)]
tate = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    tenretu = S[i].split('#')
    count = 0
    for now in tenretu:
        if now == '':
            count += 1
        else:
            length = len(now)
            for j in range(length):
                yoko[i][count] = length
                count += 1
            count += 1


for j in range(H):
    tenretu = T[j].split('#')
    count = 0
    for now in tenretu:
        if now == '':
            count += 1
        else:
            length = len(now)
            for i in range(length):
                tate[count][j] = length
                count += 1
            count += 1
maxdp = 0
for i in range(H):
    for j in range(W):
        maxdp = max(maxdp, tate[i][j] + yoko[i][j]-1)
print(maxdp)

#print(yoko)
#print(tate)

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

rows = [[0 for _ in range(w+1)] for _ in range(h)]
cols = [[0 for _ in range(w+1)] for _ in range(h+1)]
field = [[0 for _ in range(w)] for _ in range(h)]

for i in range(len(rows)):
  rows[i][0] = 0

for i in range(len(cols)):
  cols[0][i] = 0

for i in range(h):
  for j in range(1,w+1):
    if s[i][j-1] == "#":
      rows[i][j] = 0
    else:
      rows[i][j] = rows[i][j-1] + 1


for i in range(w):
  for j in range(1,h+1):
    if s[j-1][i] == "#":
      cols[j][i] = 0
    else:
      cols[j][i] = cols[j-1][i] + 1

for v in rows:
  v.pop(0)
cols.pop(0)

v = 0
for i in range(h):
  for j in reversed(range(w)):
    v = 0 if rows[i][j] == 0 else max(v,rows[i][j])
    rows[i][j] = v
v = 0
for i in range(w):
  for j in reversed(range(h)):
    v = 0 if cols[j][i] == 0 else max(v,cols[j][i])
    cols[j][i] = v

for i in range(h):
  for j in range(w):
    field[i][j] = rows[i][j] + cols[i][j] - 1


print(max([max(v) for v in field]))

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:
			l = 0
			r = 0
			u = 0
			d = 0
			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)