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 = [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):
        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:
def chkp(i,j):
	tmp=j+1
	count=1
	while tmp<W and s[i][tmp]==".":
		count+=1
		tmp+=1
	return count

def chkv(i,j):
	tmp=i+1
	count=1
	while tmp<H and s[tmp][j]==".":
		count+=1
		tmp+=1
	return count

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

p=[[0 for j in range(W)] for i in range(H)]
v=[[0 for j in range(W)] for i in range(H)]

for i in range(H):
	if W==1:
		if s[i][j]==".": p[i][0]=1
	else:
		if s[i][0]==".": p[i][0]=chkp(i,0)
		for j in range(1,W):
			if s[i][j]==".":
				if s[i][j-1]==".": p[i][j]=p[i][j-1]
				else: p[i][j]=chkp(i,j)

for j in range(W):
	if H==1:
		if s[i][j]==".": v[0][j]=1
	else:
		if s[0][j]==".": v[0][j]=chkv(0,j)
		for i in range(1,H):
			if s[i][j]==".":
				if s[i-1][j]==".": v[i][j]=v[i-1][j]
				else: v[i][j]=chkv(i,j)

print(max( max(v[i][j]+p[i][j] for j in range(W)) for i in range(H)  ))

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 = [[0] * W for _ in range(H)]
dp_d = [[0] * W for _ in range(H)]
dp_l = [[0] * W for _ in range(H)]
dp_r = [[0] * W for _ in range(H)]
def count_up(h, w):
    if dp_u[h][w] != 0:
        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] != 0:
        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] != 0:
        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] != 0:
        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):
        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:
def resolve():
    (N, M) = list(map(int, input().split(" ")))
    As = [int(input()) for i in range(M)]

    cnts = [False] * (N+1)
    for i in range(N+1):
        c = 0
        if i in As:
            c = 0
        elif i == 0:
            c = 1
        elif i == 1:
            c = 1
        elif i == 2:
            c = 2 if 1 not in As else 1
        else:
            c = (cnts[i-2] + cnts[i-1])%1000000007
        cnts[i] = c

    print(cnts[N])

if '__main__' == __name__:
    resolve()

Submission status: Runtime Error

Solution code:
def tamiL(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiL(x-1,y,n+1)
    else:
      return n
  else:
    return n

def tamiR(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiR(x+1,y,n+1)
    else:
      return n
  else:
    return n

def tamiU(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiU(x,y-1,n+1)
    else:
      return n
  else:
    return n

def tamiD(x,y,n):
  if (0 <= x < W) and (0 <= y < H):
    if grid[y][x] == ".":
      return tamiD(x,y+1,n+1)
    else:
      return n
  else:
    return n

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

ans = 0
for i in range(H):
  for j in range(W):
    if grid[i][j] == ".":
      cnt = 0
      cnt += tamiL(j-1,i,0)
      cnt += tamiR(j+1,i,0)
      cnt += tamiU(j,i-1,0)
      cnt += tamiD(j,i+1,0)
      ans = max(ans,cnt+1)

print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.stack([g, g])

  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]

  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])

  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]

  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])

  g = g[0] + g[1]

  print(numpy.max(g) - 1)


if __name__ == '__main__':
  main()

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-1):
	for j in range(w-1):
		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)

Submission status: Runtime Error

Solution code:
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict


class Solution:

    def main(self):
        self.H, self.W = map(int, input().split())
        self.S = []
        for _ in range(self.H):
            self.S.append(input())

        self.hor_score = [[None] * self.W for _ in range(self.H)]
        self.ver_score = [[None] * self.W for _ in range(self.H)]
        res = 0
        for h in range(self.H):
            for w in range(self.W):
                if self.S[h][w] != '#':
                    if self.hor_score[h][w] is None:
                        self.rec_hor(h, w, 0)
                    if self.ver_score[h][w] is None:
                        self.rec_ver(h, w, 0)
                    res = max(res, self.hor_score[h][w]+self.ver_score[h][w]-1)
        print(res)
        # print(self.hor_score)
        # print(self.ver_score)

    def rec_ver(self, i, j, val):
        if i >= self.H or self.S[i][j] == '#':
            return val
        else:
            self.ver_score[i][j] = self.rec_ver(i+1, j, val+1)
            return self.ver_score[i][j]

    def rec_hor(self, i, j, val):
        if j >= self.W or self.S[i][j] == '#':
            return val
        else:
            self.hor_score[i][j] = self.rec_hor(i, j+1, val+1)
            return self.hor_score[i][j]


if __name__ == '__main__':
    Solution().main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy


def main():
  r, c = map(int, input().split())
  g = numpy.array([[1 if v == '.' else 0 for v in input().strip()] for _ in range(r)])
  g = numpy.stack([g, g])

  print(g[0])

  for x in range(1, c):
    g[0, :, x] += g[0, :, x] * g[0, :, x - 1]

  for x in range(c - 2, -1, -1):
    g[0, :, x] = (g[0, :, x] != 0) * numpy.maximum(g[0, :, x], g[0, :, x + 1])

  for y in range(1, r):
    g[1, y] += g[1, y] * g[1, y - 1]

  for y in range(r - 2, -1, -1):
    g[1, y] = (g[1, y] != 0) * numpy.maximum(g[1, y], g[1, y + 1])

  g = g[0] + g[1]

  print(numpy.max(g) - 1)


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
x = [list(input()) for _ in range(h)]
xt = [[x[i][j] for i in range(h)] for j in range(w)]
start = time.time()
xh = [[0 for i in range(h)] for j in range(w)]
for i, xi in enumerate(x):
    l = 0
    for j, xij in enumerate(xi):
        if xij == '#':
            for k in range(l, j):
                xh[k][i] = j - l
            l = j + 1
    for k in range(l, w):
        xh[k][i] = w - l

ans = 0
for i, xi in enumerate(xt):
    l = 0
    xhi = xh[i]
    for j, xij in enumerate(xi):
        if xij == '#':
            if j > l:
                ans = max(ans, max(xhi[l:j]) + j - l - 1)
            l = j + 1
    if h > l:
        ans = max(ans, max(xhi[l:]) + h - l - 1)
print(ans)

Submission status: Runtime Error

Solution code:
def count_light(i, j):
  count = 1
  
  # 上/左方向
  k = i - 1
  l = j - 1
  while k >= 0:
    if S[k][j] == '.':
      count += 1
      k -= 1
      
    if S[i][l] == '.':
      count += 1
      l -= 1
  
  # 下/右方向
  k = i + 1
  l = j + 1
  while k < H:
    if S[k][j] == '.':
      count += 1
      k += 1
      
    if S[i][l] == '.':
      count += 1
      l += 1
  
  return count
    
H,W = (int(x) for x in input().split())
S = []
for i in range(H):
  S.append(list(input()))

max = 0
for i in range(H):
  for j in range(W):
    if not(S[i][j] == '#'):
      tmp = count_light(i, j)
      if (max < tmp):
        max = tmp

print(max)

Submission status: Runtime Error

Solution code:
import numpy as np

H, W = map(int, input().split())
S = []
for i in range(H):
    s = input()
    S.append(list(s))

S_2 = [[0] * H for i in range(W)]

for j, chara in enumerate(S):
    for index, char in enumerate(chara):
        S_2[index][j] = char

Ans = []
for index, char in enumerate(S):
    tmp = 0
    stepper = 0
    a = []
    for i in char:
        if i == "#" and tmp == 0:
            a.append(0)
        elif i == "." and tmp == 0:
            tmp = 1
            stepper += 1
        elif i == "." and tmp == 1:
            stepper += 1

        elif i == "#" and tmp == 1:
            tmp = 0
            for j in range(stepper):
                a.append(stepper)
            stepper = 0
            a.append(0)
    if stepper > 0:
        for j in range(stepper):
            a.append(stepper)
    Ans.append(a)

Ans2 = []
for index, char in enumerate(S_2):
    tmp = 0
    stepper = 0
    a = []
    for i in char:
        if i == "#" and tmp == 0:
            a.append(0)
        elif i == "." and tmp == 0:
            tmp = 1
            stepper += 1
        elif i == "." and tmp == 1:
            stepper += 1

        elif i == "#" and tmp == 1:
            tmp = 0
            for j in range(stepper):
                a.append(stepper)
            stepper = 0
            a.append(0)
    if stepper > 0:
        for j in range(stepper):
            a.append(stepper)
    Ans2.append(a)

S3 = l_2d_ok = [[0] * W for i in range(H)]

for j, chara in enumerate(Ans2):
    for index, char in enumerate(chara):
        S3[index][j] = char

x = np.array(Ans)
y = np.array(S3)

Ans_array = x+y
maxNum = 0
for i in Ans_array:
  mx = max(i)
  if mx > maxNum:
    maxNum = mx
print(maxNum-1)

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-1):
	for j in range(w-1):
		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
				eles:break
		out = max(num,out)	
print(out)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())

s=[input() for i in range(h)]

def ok(i,j,houkou, count):
    if i==h or j==w:
        return count
    elif s[i][j]=='#':
        return count
    elif houkou=='yoko':
        return ok(i,j+1,houkou,count+1)
    else:
        return ok(i+1,j,houkou,count+1)

yoko=[[0 for i in range(w)] for j in range(h)]
tate=[[0 for i in range(w)] for j in range(h)]

# print(yoko)
for i in range(h):
    for j in range(w):
        if s[i][j]=='.' and yoko[i][j]==0:
            count=ok(i,j,'yoko',0)
            for k in range(count):
                yoko[i][j+k]=count


for i in range(h):
    for j in range(w):
        if s[i][j]=='.' and tate[i][j]==0:
            count=ok(i,j,'tate',0)
            for k in range(count):
                tate[i+k][j]=count


ans=0
for i in range(h):
    for j in range(w):
        if ans<yoko[i][j]+tate[i][j]-1:
            ans=yoko[i][j]+tate[i][j]-1
print(ans)

Submission status: Runtime Error

Solution code:
h,w=map(int, input().split())
s=[]
for i in range(h):
    s.append(input().split())
def count(i,j):
	count=0
	#up
	a=i
	if a>0:
		while(a>0):
			if s[a-1][j] == '.':
				count+=1
				a-=1
			else:
				break
	#down
	b=i+1
	if b<h:
		while(b<h):
			if s[b][j] == '.':
				count+=1
				b+=1
			else:
				break
	#left
	c=j
	if c>0:
		while(c>0):
			if s[i][c-1] == '.':
				count+=1
				c-=1
			else:
				break
	#right
	d=j+1
	if d<w:
		while(d<w):
			if s[i][d] == '.':
				count+=1
				d+=1
			else:
				break
	return count

result = 0;
for i in range(h):
	for j in range(w):
		if s[i][j] == '.':
			result=max(result, count(i,j)+1)
		else:
			result=max(result, count(i,j))
print(result)

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
				eles:break
		out = max(num,out)	
print(out)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())

s=[input() for i in range(h)]

print(s[0][3])
print(s)

def ok(i,j,houkou, count):
    if i==h or j==w:
        return count
    elif s[i][j]=='#':
        return count
    elif houkou=='yoko':
        return ok(i,j+1,houkou,count+1)
    else:
        return ok(i+1,j,houkou,count+1)

yoko=[[0 for i in range(w)] for j in range(h)]
tate=[[0 for i in range(w)] for j in range(h)]

# print(yoko)
for i in range(h):
    for j in range(w):
        if s[i][j]=='.' and yoko[i][j]==0:
            count=ok(i,j,'yoko',0)
            for k in range(count):
                yoko[i][j+k]=count


for i in range(h):
    for j in range(w):
        if s[i][j]=='.' and tate[i][j]==0:
            count=ok(i,j,'tate',0)
            for k in range(count):
                tate[i+k][j]=count


ans=0
for i in range(h):
    for j in range(w):
        if ans<yoko[i][j]+tate[i][j]-1:
            ans=yoko[i][j]+tate[i][j]-1
print(ans)

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(3000)

H, W = map(int, input().split())
lst = [['#'] * (W+2)]
lst += [['#'] + list(input()) + ['#'] for i in range(H)]
lst += [['#'] * (W+2)]


lst_ue = [[-1] * (W+2) for i in range(H+2)]
lst_shita = [[-1] * (W+2) for i in range(H+2)]
lst_migi = [[-1] * (W+2) for i in range(H+2)]
lst_hidari = [[-1] * (W+2) for i in range(H+2)]

# print (lst_ue)
def ue(i, j):
    if lst_ue[i][j] != -1:
        return lst_ue[i][j]
    if lst[i][j] == '#':
        lst_ue[i][j] = 0
        return 0
    else:
        lst_ue[i][j] = ue(i-1, j) + 1
        return lst_ue[i][j]


def shita(i, j):
    if lst_shita[i][j] != -1:
        return lst_shita[i][j]
    if lst[i][j] == '#':
        lst_shita[i][j] = 0
        return 0
    else:
        lst_shita[i][j] = shita(i+1, j) + 1
        return lst_shita[i][j]        


def hidari(i, j):
    if lst_hidari[i][j] != -1:
        return lst_hidari[i][j]
    if lst[i][j] == '#':
        lst_hidari[i][j] = 0
        return 0
    else:
        lst_hidari[i][j] = hidari(i, j-1) + 1
        return lst_hidari[i][j]        

def migi(i, j):
    if lst_migi[i][j] != -1:
        return lst_migi[i][j]
    if lst[i][j] == '#':
        lst_migi[i][j] = 0
        return 0
    else:
        lst_migi[i][j] = migi(i, j+1) + 1
        return lst_migi[i][j]        

ans = 0
if H < 1500 and W < 1500:
    for i in range(1,H+1):
        for j in range(1, W+1):
            if lst[i][j] != '#':
                ans = max(ans, ue(i,j)+shita(i,j)+hidari(i,j)+migi(i,j)-3)
else:
    for i in range(750,1250):
        for j in range(750, 1250):
            if lst[i][j] != '#':
                ans = max(ans, ue(i,j)+shita(i,j)+hidari(i,j)+migi(i,j)-3)
                if ans == H+W-1:
                    print (ans)
                    sys.exit()

print (ans)

Submission status: Runtime Error

Solution code:
H, W = [int(x) for x in input().split()]
G = []
Lw = []
Lh = []

for i in range(H):
    G.append(input())
    Lw.append([0] * W)
    Lh.append([0] * W)

for y in range(H):
    if G[y][0] == '#':
        Lw[y][0] = 0
    else:
        s = 1
        for x in range(1, W):
            if G[y][x] == '#':
                break
            else:
                s+=1
        Lw[y][0] = s

    for x in range(1, W):
        if G[y][x] == '#':
            Lw[y][x] = 0
            continue
        if G[y][x-1] == '.':
            Lw[y][x] = Lw[y][x-1]
            continue
        s = 0
        for w in range(x, W):
            if G[y][w] == '#':
                break
            else:
                s+=1
        Lw[y][x] = s

for x in range(W):
    if G[0][x] == '#':
        Lh[0][x] = 0
    else:
        s = 1
        for y in range(1, H):
            if G[y][x] == '#':
                break
            else:
                s+=1
        Lh[0][x] = s

    for y in range(1, H):
        if G[y][x] == '#':
            Lh[y][x] = 0
            continue
        if G[y-1][x] == '.':
            Lh[y][x] = Lh[y-1][x]
            continue
        s = 0
        for h in range(y, H):
            if G[h][x] == '#':
                break
            else:
                s+=1
        Lh[y][x] = s

#for y in range(H):
#    print(Lw[y])
#print()
#for y in range(H):
#    print(Lh[y])

m = 0
for y in range(1,H):
    for x in range(1, H):
        #if G[x][y] == '#': continue
        m = max(m, Lw[x][y] + Lh[x][y] - 1)
print(m)

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        cnt = 1
        a = i
        b = j
        while a+1 <= H-1:
            if S[a+1][b] == '#':
                break
            cnt += 1
            a += 1
        a = i
        while a-1 >= 0:
            if S[a-1][b] == '#':
                break
            cnt += 1
            a -= 1
        a = i
        b = j
        while b+1 <= W-1:
            if S[a][b+1] == '#':
                break
            cnt += 1
            b += 1
        b = j
        while b-1 <= 0:
            if S[a][b-1] == '#':
                break
            cnt += 1
            b -= 1
        ans = max(ans, cnt)
print(ans)

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(3000)

H, W = map(int, input().split())
lst = [['#'] * (W+2)]
lst += [['#'] + list(input()) + ['#'] for i in range(H)]
lst += [['#'] * (W+2)]


lst_ue = [[-1] * (W+2) for i in range(H+2)]
lst_shita = [[-1] * (W+2) for i in range(H+2)]
lst_migi = [[-1] * (W+2) for i in range(H+2)]
lst_hidari = [[-1] * (W+2) for i in range(H+2)]

# print (lst_ue)
def ue(i, j):
    if lst_ue[i][j] != -1:
        return lst_ue[i][j]
    if lst[i][j] == '#':
        lst_ue[i][j] = 0
        return 0
    else:
        lst_ue[i][j] = ue(i-1, j) + 1
        return lst_ue[i][j]


def shita(i, j):
    if lst_shita[i][j] != -1:
        return lst_shita[i][j]
    if lst[i][j] == '#':
        lst_shita[i][j] = 0
        return 0
    else:
        lst_shita[i][j] = shita(i+1, j) + 1
        return lst_shita[i][j]        


def hidari(i, j):
    if lst_hidari[i][j] != -1:
        return lst_hidari[i][j]
    if lst[i][j] == '#':
        lst_hidari[i][j] = 0
        return 0
    else:
        lst_hidari[i][j] = hidari(i, j-1) + 1
        return lst_hidari[i][j]        

def migi(i, j):
    if lst_migi[i][j] != -1:
        return lst_migi[i][j]
    if lst[i][j] == '#':
        lst_migi[i][j] = 0
        return 0
    else:
        lst_migi[i][j] = migi(i, j+1) + 1
        return lst_migi[i][j]        

ans = 0
if H < 1500 and W < 1500:
    for i in range(1,H+1):
        for j in range(1, W+1):
            if lst[i][j] != '#':
                ans = max(ans, ue(i,j)+shita(i,j)+hidari(i,j)+migi(i,j)-3)
else:
    for i in range(750,1250):
        for j in range(750, 1250):
            if lst[i][j] != '#':
                ans = max(ans, ue(i,j)+shita(i,j)+hidari(i,j)+migi(i,j)-3)
                if ans == H+W-1:
                    print (asn)
                    sys.exit()

print (ans)

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-1):
	for j in range(w-1):
		num = 0
		if m[i][j] == '#':
			continue
		else:
			l = 0
			r = 0
			u = 0
			d = 0
			while m[i][j-l] != '#' :
				num += 1
				l+=1
				if j-l < 0:
					break
			while m[i][j+r] != '#' :
				num += 1
				r +=1
				if j+r > w:
					break
			while m[i-u][j] != '#'  :
				num += 1
				u +=1	
				if i-u <0:
					break
			while m[i+d][j] != '#'  :
				num += 1
				d +=1
				if i+d > h:
					break
		out = max(num,out)	
print(out)

Submission status: Runtime Error

Solution code:
h,w=(int(i) for i in input().split())
a=[]
b=[]
p=[]
for i in range(h):
  s=input()
  r=[]
  c=0
  for j in range(w):
    if s[j]==".":
      c=c+1
      if j==w-1:
        for k in range(c):
          r.append(c)
    elif s[j]=="#":
      for k in range(c):
        r.append(c)
      r.append(0)
      c=0
  a.append(r)
for i in range(h):
  r=[]
  c=0
  for j in range(w):
    if a[j][i]!=0:
      c=c+1
      if j==w-1:
        for k in range(c):
          r.append(c)
    elif a[j][i]==0:
      for k in range(c):
        r.append(c)
      r.append(0)
      c=0
  b.append(r)
for i in range(h):
  for j in range(w):
    p.append(a[i][j]+b[j][i]-1)
p.sort()
print(p[-1])

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 m[i][j-l] != '#' :
				num += 1
				l+=1
				if j-l < 0:
					break
			while m[i][j+r] != '#' :
				num += 1
				r +=1
				if j+r > w:
					break
			while m[i-u][j] != '#'  :
				num += 1
				u +=1	
				if i-u <0:
					break
			while m[i+d][j] != '#'  :
				num += 1
				d +=1
				if i+d > h:
					break
		out = max(num,out)	
print(out)

Submission status: Runtime Error

Solution code:
import numpy as np


def main():
    h, w = map(int, input().split())
    grid = [input() for _ in range(h)]
    field = np.array([[0] * w for _ in range(h)])

    for i, row in enumerate(grid):
        row = row + "#"
        cnt = row.count("#")

        idx = -1
        for j in range(cnt + 1):
            idx_next = row.find("#", idx + 1)
            field[i][idx+1:idx_next] = idx_next - idx - 1
            idx = idx_next

    m = 0
    field = field.T
    grid_t = zip(*grid)

    for i, row in enumerate(grid_t):
        row = "".join(row) + "#"
        cnt = row.count("#")

        idx = -1
        for j in range(cnt + 1):
            idx_next = row.find("#", idx + 1)
            field[i][idx+1:idx_next] += idx_next - idx - 1
            idx = idx_next
        if max(field[i]) > m:
            m = max(field[i])

    print(m - 1)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
if __name__ == "_main__":
  HW = list(map(int,input().split(" ")))
  
  H = HW[0]
  W = HW[1]
  
  List = [ for i in range(W)]
  
  for i in range(W):
    str = input()
    List[i] = str
  print(List)

Submission status: Runtime Error

Solution code:

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
H, W = map(int, input().split())
S = []
vertical = []
horizontal = []

for _ in range(H):
    s = input()
    S.append(s)
    vertical.append([-1]*W)
    horizontal.append([-1]*W)

def search_vertical(i, j, current):
    if i == H-1 or S[i+1][j] == '#':
        vertical[i][j] = current
        return current
    vertical[i][j] = search_vertical(i+1, j, current+1)
    return vertical[i][j]

def search_horizontal(i, j, current):
    if j == W-1 or S[i][j+1] == '#':
        horizontal[i][j] = current
        return current
    horizontal[i][j] = search_horizontal(i, j+1, current+1)
    return horizontal[i][j]

res = -2
for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        if vertical[i][j] == -1:
            search_vertical(i, j, 1)
        if horizontal[i][j] == -1:
            search_horizontal(i, j, 1)
        res = max(res, vertical[i][j] + horizontal[i][j] -1)

print(res)

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 = 1
			r = 1
			u = 1
			d = 1
			while m[i][j-l] != '#' and j-l>=0:
				num += 1
				l +=1
			while m[i][j+r] != '#' and j+r <= w:
				num += 1
				r +=1
			while m[i-u][j] != '#' and i-u >=0:
				num += 1
				u +=1	
			while m[i+d][j] != '#' and i+d <= h:
				num += 1
				d +=1
		out = max(num,out)	
print(out)

Submission status: Runtime Error

Solution code:
def chkp(i,j):
	tmp=j+1
	count=1
	while tmp<W and s[i][tmp]==".":
		count+=1
		tmp+=1
	return count

def chkv(i,j):
	tmp=i+1
	count=1
	while tmp<H and s[tmp][j]==".":
		count+=1
		tmp+=1
	return count

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

p=[[0 for j in range(W)] for i in range(H)]
v=[[0 for j in range(W)] for i in range(H)]

for i in range(H):
	if W==1:
		if s[i][j]==".": p[i][0]=1
	else:
		if s[i][0]==".": p[i][0]=chkp(i,0)
		for j in range(1,W):
			if s[i][j]==".":
				if s[i][j-1]==".": p[i][j]=p[i][j-1]
				else: p[i][j]=chkp(i,j)

for j in range(W):
	if H==1:
		if s[i][j]==".": v[0][j]=1
	else:
		if s[0][j]==".": v[0][j]=chkv(0,j)
		for i in range(1,H):
			if s[i][j]==".":
				if s[i-1][j]==".": v[i][j]=v[i-1][j]
				else: v[i][j]=chkv(i,j)
					
print(max( max(v[i][j]+p[i][j] for j in range(W)) for i in range(H)  )-1)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())

T = ["" for i in range(W)]

xs = [[0 for i in range(W)] for i in range(H)]
ys = [[0 for i in range(W)] for i in range(H)]

for i in range(H):
	st = input()
	c = 0
	
	for j in range(W):
		T[j]=T[j]+st[j]
		if st[j] == "#":
			xc = j-c
			xs[i][j] = 0
			ys[i][j] = 0
			for k in ragne(c,j):
				xs[i][k] = xc
			c = j+1

for i in range(W):
	st = T[i]
	c = 0
	for j in range(H):
		if st[j] ==  "#":
			yc = j-c
			for k in range(c,j):
				ys[k][i] = yc
			c = j+1

r = 0
for i in range(H):
	for j in range(W):
		r = max(r,xs[i][j] + ys[i][j])

print(r)