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: Wrong Answer

Solution code:
H, W = map(int, input().split())
S = ""
for i in range(H):
    S += input()

vert = [0] * (H*W)
horz = [0] * (H*W)

for i in range(H*W):
    if S[i] == '.':
        if i - W >= 0:
            if S[i - W] == '.':
                vert[i] = vert[i - W]
                continue
        j = i
        while True:
            if j >= H * W:
                break
            if S[j] == '.':
                vert[i] += 1
            else:
                break
            j += W

for i in range(H*W):
    if S[i] == '.':
        if i % W > 0:
            if S[i - 1] == '.':
                horz[i] = horz[i - 1]
                continue
        j = i
        while True:
            if S[j] == '.':
                horz[i] += 1
            else:
                break
            j += 1
            if j % W == 0:
                break

light = [0] * (H*W)
for i in range(H * W):
    light[i] = horz[i] + vert[i]
print(max(light))

Submission status: Wrong Answer

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

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

board = [[[0 for _ in range(2)] for _ in range(w)] for _ in range(h)]

# 右、左、上、下の順に走査
for i in range(h):
    cnt_continue = 0
    for j in range(w):
        if s[i][j] == "#":
            cnt_continue = 0
        else:
            cnt_continue += 1
            board[i][j][0] = cnt_continue

for i in range(h):
    for j in reversed(range(w-1)):
        if board[i][j][0] == 0:
            continue
        board[i][j][0] = board[i][j+1][0]

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

for i in range(w):
    for j in reversed(range(h-1)):
        if board[j][i][1] == 0:
            continue
        board[j][i][1] = board[j+1][i][1]

ans = 0

for i in range(h):
    for j in range(w):
        v = sum(board[i][j]) - 1
        ans = max(ans, v)

print(ans)

Submission status: Wrong Answer

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

tail = "."
yoko_memo = collections.defaultdict(dict)
tate_memo = collections.defaultdict(dict)

tate_cumsum = [0 for _ in range(W + 1)]
for i in range(1, H + 1):
  yoko_cumsum = 0
  for j, c in enumerate(input().strip(), start=1):
    if c == tail:
      yoko_cumsum += 1
      tate_cumsum[j] +=1
    else:
      yoko_memo[i][j - 1] = yoko_cumsum
      tate_memo[i - 1][j] = tate_cumsum[j]
      # yoko_memo[i][j] = 0
      # tate_memo[i][j] = 0

      tate_cumsum[j] = 0
      yoko_cumsum = 0
  yoko_memo[i][j] = yoko_cumsum
for j in range(1, W + 1):
  tate_memo[i][j] = tate_cumsum[j]


ans = -1
for i in range(H, 0, -1):
  for j in range(W, 0, -1):
    if j != W and yoko_memo[i][j + 1] != 0: 
      yoko_memo[i][j] = yoko_memo[i][j + 1]
    if i != H and tate_memo[i + 1][j] != 0: 
      tate_memo[i][j] = tate_memo[i + 1][j]
    ans = max(ans, yoko_memo[i][j] + tate_memo[i][j] - 1)

# # print(*square, sep='\n')
# # print()
# # print(*tate_memo, sep='\n')
# # print()
# # print(*yoko_memo, sep='\n')
# # print()
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from numpy.fft import fft, ifft
from fractions import gcd
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
S = [input() for _ in range(H)]

L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]


for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			L[i][j] = 0
		elif j == 0:
			L[i][j] = 1
		else:
			L[i][j] = L[i][j-1] + 1

for i in range(H):
	for j in range(W-1, -1, -1):
		if S[i][j] == '#':
			R[i][j] = 0
		elif j == W-1:
			R[i][j] = 1
		else:
			R[i][j] = R[i][j+1] + 1

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			U[i][j] = 0
		elif i == 0:
			U[i][j] = 1
		else:
			U[i][j] = U[i-1][j] + 1

for i in range(H-1, -1, -1):
	for j in range(W):
		if S[i][j] == '#':
			D[i][j] = 0
		elif i == H-1:
			D[i][j] = 1
		else:
			D[i][j] = D[i+1][j] + 1

L = np.array(L)
R = np.array(R)
U = np.array(U)
D = np.array(D)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
words = lambda t : list(map(t, input().split()))

h,w = words(int)
wq = [0] * w

grid = []
grid.append(['#'] * (w+2))
for i in range(h):
    grid.append(['#'] + list(input()) + ['#'])
grid.append(['#'] * (w+2))

l = np.array([[0] * (w+2) for _ in range(h+2)])
r = np.array([[0] * (w+2) for _ in range(h+2)])
u = np.array([[0] * (w+2) for _ in range(h+2)])
d = np.array([[0] * (w+2) for _ in range(h+2)])

#for i in range(h+2):
#    print(grid[i])


'''
for i in range(1,h+1):
    for j in range(1,w+1):
        if grid[i][j] == '#':
            continue
        else:
            l[i][j] = l[i][j-1]+1

for i in range(1,h+1):
    for j in range(w+1,0,-1):
        if grid[i][j] == '#':
            continue
        else:
            r[i][j] = r[i][j+1]+1

for j in range(1,w+1):
    for i in range(1,h+1):
        if grid[i][j] == '#':
            continue
        else:
            u[i][j] = u[i-1][j]+1

for j in range(1,w+1):
    for i in range(h+1,0,-1):
        if grid[i][j] == '#':
            continue
        else:
            d[i][j] = d[i+1][j]+1
'''
print((l+r+u+d).max()-3)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
vert = [[0] * W]*H; hori = [[0] * W]*H;
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            hori[i][j] = hori[i][j-1] + 1 if j >= 1 else 1
            vert[i][j] = vert[i-1][j] + 1 if i >= 1 else 1
for i in reversed(range(H-1)):
    for j in reversed(range(W-1)):
        if grid[i][j] == '.':
            hori[i][j] = hori[i][j+1]
            vert[i][j] = vert[i+1][j]
for i in range(H):
    for j in range(W):
        ans = max(ans, hori[i][j] + vert[i][j] - 1)
print(ans)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
L = [[0] * W]*H; R = [[0] * W]*H; D = [[0] * W]*H; U = [[0] * W]*H;
for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            L[i][j] = L[i][j-1] if j >= 1 else 1
            U[i][j] = U[i-1][j] if i >= 1 else 1
for i in reversed(range(H)):
    for j in reversed(range(W)):
        if grid[i][j] == '.':
            R[i][j] = R[i][j+1] if j <= W-2 else 1
            D[i][j] = D[i+1][j] if i <= H-2 else 1
for i in range(H):
    for j in range(W):
        ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3)
print(ans)

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
S = list(input() for i in range(H))
Grid1 = [[0]*W for i in range(H)]
for i in range(H):
    cou = 0
    l = 0
    for j in range(W):
        if S[i][j] == ".":
            cou += 1
        else:
            for x in range(l,j):
                Grid1[i][x] = cou
            l = j+1
            cou = 0
    for x in range(l,j+1):
        Grid1[i][x] = cou    
print(Grid1)
for i in range(W):
    cou = 0
    l = 0
    for j in range(H):
        #print(i,j,S[i][j])
        if S[j][i] == ".":
            cou += 1
        else:
            for x in range(l,j):
                Grid1[x][i] += cou
            l = j+1
            cou = 0
    for x in range(l,j+1):
        Grid1[x][i] += cou

print(max(max(Grid1[i]) for i in range(H))-1)

Submission status: Wrong Answer

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

    mat = [[0 for _ in range(w)] for _ in range(h)]
    count_h = [0] * w
    idx_h = [0] * w
    for hh in range(h):
        s = input()
        count_w = 0
        idx = 0
        for i in range(w):
            if s[i] == '#':
                for ii in range(idx, i):
                    mat[hh][ii] += count_w
                idx = i + 1
                count_w = 0
                for j in range(idx_h[i], hh):
                    mat[j][i] += count_h[i]
                idx_h[i] = hh + 1
                count_h[i] = 0
            elif s[i] == '.':
                count_w += 1
                count_h[i] += 1
                if i + 1 == w:
                    for ii in range(idx, i + 1):
                        mat[hh][ii] += count_w
                if hh + 1 == h:
                    for j in range(idx_h[i], hh):
                        mat[j][i] += count_h[i]
    maxv = 0
    for hh in range(h):
        for ww in range(w):
            if maxv < mat[hh][ww]:
                maxv = mat[hh][ww]
    print(maxv - 1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys

H, W = list(map(int, sys.stdin.readline().split()))
S = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)]) == '.'
uds = np.zeros((H, W), dtype=int)
lrs = np.zeros((H, W), dtype=int)

for h in range(1, H):
    uds[h] = (uds[h - 1] + 1) * S[h - 1]
    uds[H - h - 1] = (uds[H - h] + 1) * S[H - h]
for w in range(1, W):
    lrs[:, w] = (lrs[:, w - 1] + 1) * S[:, w - 1]
    lrs[:, W - w - 1] = (lrs[:, W - w] + 1) * S[:, W - w]
print(((uds + lrs) * S).max() + 1)

Submission status: Wrong Answer

Solution code:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

H,W = map(int,input().split())
grid = [list(input()) for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]
for i in range(H):
    bool = False
    for j in range(W):
        if j == 0 or bool:
            if grid[i][j] ==".":
                L[i][j] = 1
                bool = False
            else:
                bool = True
        else:
            if grid[i][j] ==".":
                L[i][j] = L[i][j-1]+1
                bool = False
            else:
                L[i][j] = L[i][j-1]
                bool = True
for i in range(H):
    bool = False
    for j in range(W)[::-1]:
        if j == W-1 or bool:
            if grid[i][j] ==".":
                R[i][j] = 1
                bool = False
            else:
                bool = True
        else:
            if grid[i][j] ==".":
                R[i][j] = R[i][j+1]+1
                bool = False
            else:
                R[i][j] = R[i][j+1]
                bool = True
for i in range(W):
    bool = False
    for j in range(H):
        if j == 0 or bool:
            if grid[j][i] ==".":
                U[j][i] = 1
                bool = False
            else:
                bool = True
        else:
            if grid[j][i] ==".":
                U[j][i] = U[j-1][i]+1
                bool = False
            else:
                U[j][i] = U[j-1][i]
                bool = True
for i in range(W):
    bool = False
    for j in range(H)[::-1]:
        if j == H-1 or bool:
            if grid[j][i] ==".":
                D[j][i] = 1
                bool = False
            else:
                bool = True
        else:
            if grid[j][i] ==".":
                D[j][i] = D[j+1][i]+1
                bool = False
            else:
                D[j][i] = D[j+1][i]
                bool = True
ans = 0
for i in range(H):
    for j in range(W):
        if grid[i][j] =="#":
            ans = max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j])
        else:
            ans = max(ans,L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
print(ans)

Submission status: Wrong Answer

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

def clist(l):
  ll = l.split("#")
  tmp = [len(lll) for lll in ll]
  ret = "0".join([str(t)*t for t in tmp])
  return(ret)

S = []
for h in range(H):
  S.append(input())

#print(S)

t_list = []
for s in S:
  t_list.append(clist(s))

y_list = []
for w in range(W):
  tmp = "".join([S[h][w] for h in range(H)])
  y_list.append(clist(tmp))

#print(t_list, y_list)

ret = 0
for h in range(H):
  for w in range(W):
    #print(t_list[h][w])
    #print(y_list[w][h])
    #print(int(t_list[h][w])+int(y_list[w][h]))
    ret = max(ret, int(t_list[h][w])+int(y_list[w][h])-1)

print(ret)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = []
cnt = 0
while(cnt != h*w):
    for i in range(h):
        for j in range(w):
            tmp = 0
            if c[i][j] == '.':
                me = [i,j]
                # 上
                mas = c[i][j]
                if me[0]-1 >= 0:
                    mast = c[me[0]-1][me[1]]
                    while(mast == '.' and me[0]-1 >= 0):
                        mast = c[me[0]-1][me[1]]
                        me[0] -= 1
                        tmp += 1
                # 下
                me = [i,j]
                if me[0]+1 < h:
                    mast = c[me[0]+1][me[1]]
                    while(mast == '.' and me[0]+1 < h):
                        mast = c[me[0]+1][me[1]]
                        me[0] += 1
                        tmp += 1
                # 左
                me = [i,j]
                if me[1]-1 >= 0:
                    mast = c[me[0]][me[1]-1]
                    while(mast == '.' and me[1]-1 >= 0):
                        mast = c[me[0]][me[1]-1]
                        me[1] -= 1
                        tmp += 1
                # 右
                me = [i,j]
                if me[1]+1 < w:
                    mast = c[me[0]][me[1]+1]
                    while(mast == '.' and me[1]+1 < w):
                        mast = c[me[0]][me[1]+1]
                        me[1] += 1
                        tmp += 1
            ans.append(tmp)
    cnt += 1
print(max(ans))

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
si = []
for i in range(h):
    si.append(input())

col = []
for i in range(len(si)):
    col.append([])
    start = -1
    for j in range(len(si[i])):
        if si[i][j] == "#":
            if start != -1:
                col[i].append([start, j-1, j-start])
            start = j+1
        elif start == -1:
            start = 0
    if si[i][len(si[i])-1] == ".":
        col[i].append([start, len(si[i])-1, len(si[i])-start])

row = []
for j in range(w):
    row.append([])
    start = -1
    for i in range(h):
        if si[i][j] == "#":
            if start != -1:
                row[j].append([start, i-1, i-start])
            start = i+1
        elif start == -1:
            start = 0
    if si[h-1][j] == ".":
        row[j].append([start, h-1, h-start])
        
maxx = 0
for i in range(h):
    for c in col[i]:
        for j in range(c[0], c[1]+1):
            for r in row[j]:
                if j >= r[0] and j <= r[1]:
                    cand = c[2] + r[2]
                    if cand > maxx:
                        maxx = cand
                    break
print(maxx - 1)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
si = []
for i in range(h):
    si.append(input())

col = []
for i in range(len(si)):
    col.append([])
    start = -1
    for j in range(len(si[i])):
        if si[i][j] == "#":
            if start != -1:
                col[i].append([start, j-1, j-start])
            start = j+1
        elif start == -1:
            start = 0
    if si[i][len(si[i])-1] == ".":
        col[i].append([start, len(si[i])-1, len(si[i])-start])

row = []
for j in range(w):
    row.append([])
    start = -1
    for i in range(h):
        if si[i][j] == "#":
            if start != -1:
                row[j].append([start, i-1, i-start])
            start = i+1
        elif start == -1:
            start = 0
    if si[h-1][j] == ".":
        row[j].append([start, h-1, h-start])
        
maxx = 0
for i in range(h):
    for c in col[i]:
        for j in range(c[0], c[1]+1):
            for r in row[j]:
                if j >= r[0] and j <= r[1]:
                    cand = c[2] + r[2]
                    if cand > maxx:
                        maxx = cand
print(maxx - 1)

Submission status: Wrong Answer

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) -1:
                ret.extend( [index-b_index-2 for _ in range(index-b_index-1)])
            else:
                ret.extend( [index-b_index-1 for _ in range(index-b_index-1)])
            ret.append(0)
            b_index = index
        S1.append(ret[:-2])
    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)


print(np.max(S1 + S2.T) - 2)

Submission status: Wrong Answer

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) -1:
                ret.extend( [index-b_index-2 for _ in range(index-b_index-1)])
            else:
                ret.extend( [index-b_index-1 for _ in range(index-b_index-1)])
            ret.append(0)
            b_index = index
        S1.append(ret[:-2])
    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) - 2)

Submission status: Wrong Answer

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

M = []
for i in range(H):
  M.append([c == '.' for c in list(input().strip())])

max_size = 0
max_pos = None
for i in range(H):
  for j in range(W):
    if not M[i][j]:
      continue

    a = 1
    for x in range(j + 1, min(W, j + 5)):
      if not M[i][x]: break
      a += 1
    for x in range(j - 1, max(-1, j - 5), -1):
      if not M[i][x]: break
      a += 1
    for y in range(i + 1, min(H, i + 5)):
      if not M[y][j]: break
      a += 1
    for y in range(i - 1, max(-1, i - 5), -1):
      if not M[y][j]: break
      a += 1

    if a > max_size:
      max_size = a
      max_pos = (i, j)


print(max_size, max_pos)

Submission status: Wrong Answer

Solution code:
H,W =map(int,input().split())
lis =[[1 if i=="." else 0 for i in input()]for _ in range(H)]
tatelis = [[0 for _ in range(W)]for __ in range(H)]
yokolis = [[0 for _ in range(W)]for __ in range(H)]




cou = 0
for i in range(H):
    num = 0
    cou = 0
    for j in range(W):
        if lis[i][j]:
            cou += 1
        else:
            yokolis[i][num]=cou
            yokolis[i][j]=-cou
            num = j +1
            cou = 0
    if cou != 0:
        yokolis[i][num] = cou
        cou = 0

for j in range(W):
    num = 0
    cou = 0
    for i in range(H):
        if lis[i][j]:
            cou += 1
        else:
            tatelis[num][j]=cou
            tatelis[i][j]=-cou
            num = i+1
            cou = 0
    if cou != 0:
        tatelis[num][j]=cou
        cou = 0


for i in range(H):
    for j in range(1,W):
        yokolis[i][j] += yokolis[i][j-1]
ans = 0
for j in range(W):
    for i in range(1,H):
        tatelis[i][j] += tatelis[i-1][j]
        foo = tatelis[i][j] + yokolis[i][j]
        if ans < foo:
            ans = foo

print(ans-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
[H,W] = list(map(int,input().split()))

S =[]
while True:
    try:
        S.append(list(input()))
    except:
        break;

yoko = np.zeros((H,W))
tate = np.zeros((H,W))

for i in range(H):
    ren = 0
    for j in range(W):
        if S[i][j]=="#":
            if ren >0:
                yoko[i,mark:j]=ren
            ren = 0
        elif S[i][j]==".":
            ren+=1
            print(ren)
            if ren == 1:
                mark = j
            if j==W-1:
                yoko[i,mark:j+1]=ren

for j in range(W):
    ren = 0
    for i in range(H):
        if S[i][j]=="#":
            if ren >0:
                tate[mark:i,j]=ren
            ren = 0
        elif S[i][j]==".":
            ren+=1
            if ren == 1:
                mark = i
            if i==H-1:
                tate[mark:i+1,j]=ren

out = tate + yoko
print(int(np.max(out)-1))

Submission status: Wrong Answer

Solution code:

h, w = map(int, input().split())
s = [input() for i in range(h)]
num = [[0 for _ in range(w)] for _ in range(h)]


if s[0][0] =='.':
    num[0][0] = 1
else:
    num[0][0] = 0

for i in range(h-1):
    if s[i+1][0] =='.':
        num[i+1][0] = num[i][0] +1
    else:
        num[i+1][0] = 0

for i in range(w-1):
    if s[0][i+1] =='.':
        num[0][i+1] = num[0][i] +1
    else:
        num[0][i+1] = 0

for i in range(h-1):
    for j in range(w-1):
        if s[i+1][j+1] =='.':
            num[i+1][j+1] = max(num[i][j+1], num[i+1][j]) + 1
        else:
            num[i+1][j+1] = 0

res = 0
for i in range(h):
    for j in range(w):
        if res < num[i][j]-1:
            res = num[i][j]-1

print(res)

Submission status: Wrong Answer

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)-1:
                ret.extend( [index-b_index-2 for _ in range(index-b_index-1)])
            else:
                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) - 2)

Submission status: Wrong Answer

Solution code:
# H,W = 2000,2000
# table = [[".#"]*1000 for i in range(2000)]

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

H_max = [0]*W
H_tmp = [0]*W

# 列
W_max = 0
for i in range(H):
    W_tmp = 0
    for j in range(W):
        if table[i][j] == ".":
            H_tmp[j] += 1
            W_tmp += 1
        else:
            H_max[j] = max(H_tmp[j],H_max[j])
            W_max = max(W_max,W_tmp)
            H_tmp[j] = 0
            W_tmp = 0
    # 最後まで"."だったとき
    W_max = max(W_max,W_tmp)
# 最後まで"."だったとき
for j in range(W):
    H_max[j] = max(H_tmp[j],H_max[j])
    
print(max(H_max)+W_max-1)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
H,W=map(int,input().split())
arr=[]
for i in range(H):
    arr.append(list(input()))
lw=[[0 for i in range(W)] for j in range(H)]
lh=[[0 for i in range(W)] for j in range(H)]
for i in range(H):
    flgh=0
    cnt=0
    tmp=0
    for j in range(W):
        if arr[i][j]==".":
            if flgh==0:
                flgh=1
                tmp=j
            cnt+=1
        else:
            flgh=0
            for k in range(tmp,j):
                lw[i][k]=cnt
            cnt=0
        if j==W-1:
            flgh=0
            for k in range(tmp,j):
                lw[i][k]=cnt
            cnt=0
            
for i in range(W):
    flgw=0      
    cnt=0
    tmp=0
    for j in range(H):
        if arr[j][i]==".":
            if flgw==0:
                flgw=1
                tmp=j
            cnt+=1
        else:
            flgw=0
            for k in range(tmp,j):
                lh[k][i]=cnt
            cnt=0
        if j==H-1:
            flgw=0
            for k in range(tmp,j):
                lh[k][i]=cnt
            cnt=0
ma=0
for i in range(H):
    for j in range(W):
        z=lh[i][j]+lw[i][j]
        if z>=ma:
            ma=z
print(ma)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
import itertools

INF = 10 ** 10

# H <= 2000, W <= 2000
H, W = [int(x) for x in stdin.readline().rstrip().split()]
S = [[x for x in stdin.readline().rstrip().split()] for _ in range(H)] 

dot_count1 = []
dot_count2 = []
S2 = [[""] for _ in range(W)] 

for line in S:
    string = line.pop()
    for i, s in enumerate(string):
        S2[i].append(S2[i].pop() + s)
    dot_count1.append(string.count("."))

for line in S2:
    string = line.pop()
    dot_count2.append(string.count("."))

max_dot_count1 = max(dot_count1)
max_dot_count2 = max(dot_count2)

ans = max_dot_count1 + max_dot_count2 - 1
print(ans)

Submission status: Wrong Answer

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-1
        while k > 0:
            if row_slice[k] == 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: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = []
for i in range(h):
    line = list(input())
    s.append(line)
table = [[1]*w for i in range(h)]
for i in range(h):

    tuzuki = False
    count = 0
    for j in range(w):
        if s[i][j] == '.':

            if tuzuki:
                count += 1
            else:
                start = j
                count = 1
                tuzuki = True
            if j == w-1:
                for k in range(start, w):
                    table[i][k] += count-1  
        else:
            if tuzuki:
                tuzuki = False
                for k in range(start, j):
                    table[i][k] += count-1
            
for j in range(w):
    tuzuki = False
    count = 0
    for i in range(h):
        if s[i][j] == '.':
            if tuzuki:
                count += 1
            else:
                start = i
                count += 1
                tuzuki = True
            if i == h-1:
                for k in range(start, h):
                    table[k][j] += count - 1
        else:
            if tuzuki:

                tuzuki = False
                for k in range(start, i):
                    table[k][j] += count - 1
m = 1
for i in range(h):
    for j in range(w):
        if table[i][j] > m:
            m = table[i][j]
print(m)

Submission status: Wrong Answer

Solution code:
import sys

def lightup(field, starty, startx):
    w_count = 0
    w_flag = False
    for i, v in enumerate(field[starty]):
        if w_flag:
            w_count += 1
        if v == '#':
            if i < startx:
                w_flag = True
            else:
                break
    
    y_count = 0
    y_flag = False
    for y in range(len(S)):
        if y_flag:
            y_count += 1
        
        if S[y][startx] == "#":
            if y < starty:
                y_flag = True
            else:
                break
        

    
    return y_count + w_count


H, W = map(int, input().split())
S = [y for y in sys.stdin.read().split('\n')[:H]]

result = [[-1 for i in range(W)] for i in range(H)]

for y in range(H):
    for x in range(W):
        if S[y][x] == '.':
            result[y][x] = lightup(S, y, x)

print(result)
print(max(result))

Submission status: Wrong Answer

Solution code:
H,W = [int(x) for x in input().split()]
S = [input() for x in range(H)]
a = []
b = []
for i in range(H):
    a.append(S[i].count("."))
for j in range(W):
    b.append(0)
    for i in range(H):
        if S[i][j] == ".":
            b[j] += 1


print(max(a)+max(b)-1)