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:
import numpy as np

h, w = list(map(int, input().split()))
d = {".":1, "#":0}
ss = np.array([list(input()) for _ in range(h)])
ss = np.array([[d[x] for x in s] for s in ss])

ls, rs, us, ds = [np.ones((h, w)) for _ in range(4)]

for i in range(1, w):
	ls[:, i] = ss[:, i] * (ls[:, i - 1] + 1)

for i in reversed(range(w - 1)):
	rs[:, i] = ss[:, i] * (rs[:, i + 1] + 1)

for i in range(1, h):
	us[i, :] = ss[i, :] * (us[i - 1, :] + 1)

for i in reversed(range(h - 1)):
	ds[i, :] = ss[i, :] * (ds[i + 1, :] + 1)

print(max(int(np.amax(ls + rs + us + ds) - 3), 0))

Submission status: Wrong Answer

Solution code:
import numpy as np

h, w = list(map(int, input().split()))
d = {".":0, "#":1}
ss = np.array([list(input()) for _ in range(h)])
ss = np.array([[d[x] for x in s] for s in ss])

ans = 0
ls = np.zeros((h, w))
rs = np.zeros((h, w))
us = np.zeros((h, w))
ds = np.zeros((h, w))

for i in range(h):
	if ss[i, 0] == 0:
		ls[i, 0] = 1
	for j in range(1, w):
		if ss[i, j] == 0:
			ls[i, j] = ls[i, j - 1] + 1		

	if ss[i, w - 1] == 0:
		rs[i, w - 1] = 1
	for j in reversed(range(w - 1)):
		print(j)
		if ss[i, j] == 0:
			rs[i, j] = rs[i, j + 1] + 1

for j in range(w):
	if ss[0, j] == 0:
		us[0, j] = 1
	for i in range(1, h):
		if ss[i, j] == 0:
			us[i, j] = us[i - 1, j] + 1

	if ss[h - 1, j] == 0:
		ds[h - 1, j] = 1
	for i in reversed(range(h - 1)):
		if ss[i, j] == 0:
			ds[i, j] = ds[i + 1, j] + 1

# print(ss)
# print(ls)
# print(rs)
# print(us)
# print(ds)

print(max(int(np.amax(ls + rs + us + ds) - 3), 0))

Submission status: Wrong Answer

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

T   = [[0] * W for _ in range(H)]
tmp = [[0] * W for _ in range(H)]

def countlight(dir):
    yrange = range(H - 1, -1, -1) if dir == 'down'  else range(H)
    xrange = range(W - 1, -1, -1) if dir == 'right' else range(W)
    nxt = {
        'left':  lambda xy: (xy[0] - 1, xy[1]),
        'right': lambda xy: (xy[0] + 1, xy[1]),
        'up':    lambda xy: (xy[0],     xy[1] - 1),
        'down':  lambda xy: (xy[0],     xy[1] + 1)
    }
    for y in yrange:
        for x in xrange:
            x1, y1 = nxt[dir]((x, y))
            tmp[y][x] = tmp[y1][x1] + 1 if 0 <= x1 < W and 0 <= y1 < H and \
                                           S[y][x] == '.' else 0
            T[y][x]  += tmp[y][x]

for dir in ('left', 'right', 'up', 'down'):
    countlight(dir)

print(max(max(T[y]) for y in range(H)))

Submission status: Wrong Answer

Solution code:
H,W =list(map(int,input().split(" ")))
mass  = []
for _ in range(H):
    mass.append(input() + "#")

mass.append((W+1)*"#")
tate = [[0 for _ in range(W+1)] for _ in range(H+1)]
yoko = [[0 for _ in range(W+1)] for _ in range(H+1)]
co = 0
for w in range(W+1):
    st = 0
    for h in range(H+1):
        c = mass[h][w]
        if c == "#":
            for temp in range(st,h):
                tate[temp][w] = co
            st = h + 1
            co = 0
        else:
            co += 1

co = 0
for h in range(H+1):
    st = 0
    for w in range(W+1):
        c = mass[h][w]
        if c == "#":
            for temp in range(st,w):
                yoko[h][temp] = co
            st = h + 1
            co = 0
        else:
            co += 1



ans = -1
for h in range(H):
    for w in range(W):
        if tate[h][w] + yoko[h][w] > ans:
            ans = tate[h][w] + yoko[h][w]

print(ans-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化、壁をTrueで持つ
map = np.ones((H+1,W+1),dtype=np.bool)
map[1:,1:] = (temp == '#')

# x軸正方向の集計
def F(transpose):
  x = map.copy()
  if transpose:
    x = x.T
  x = np.ravel(x) # to 1D array
  
  zero_idx = np.nonzero(x)[0]
  zero_span = np.diff(zero_idx) - 1 # 次の0までにある1の個数
  y = np.zeros(len(x),dtype=np.int32)
  y[1:][zero_idx[:-1]] = zero_span
  y[zero_idx[1:]] -= zero_span
  y = y.cumsum()
  if transpose:
    y = y.reshape(map.T.shape).T
  else:
    y = y.reshape(map.shape)
  return y

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import functools


def g(acc, x):
    if x == "#":
        res = 0
    elif not acc:
        res = 1
    else:
        res = acc[-1] + 1
    acc.append(res)
    return acc


def h(acc, x):
    if x == 0:
        res = 0
    elif not acc:
        res = x
    else:
        res = max(acc[-1], x)
    acc.append(res)
    return acc


def f(line):
    res = functools.reduce(g, line, [])
    res = functools.reduce(h, reversed(res), [])
    return res


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

row_wise = np.apply_along_axis(f, 0, grid)
col_wise = np.apply_along_axis(f, 1, grid)
print((row_wise + col_wise - 1).max())

Submission status: Wrong Answer

Solution code:
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化
map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1

# x軸正方向の集計
def F(transpose,reverse):
  x = map.copy()
  if transpose:
    x = x.T
  x = np.ravel(x)
  if reverse:
    x = x[::-1]
  zero_idx = np.nonzero(x==0)[0]
  x[zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum()
  if reverse:
    x = x[::-1]
  if transpose:
    x = x.T
  return x.reshape(map.T.shape).T

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

Submission status: Wrong Answer

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

S = [input() for i in range(H)]

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]


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

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

ans = 0
for i in range(H) :
    for j in range(W) :
        ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j])

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
S = [input() for _ in range(H)]
 
up =    [[0]*(W+2) for _ in range(H+2)]
down =  [[0]*(W+2) for _ in range(H+2)]
left =  [[0]*(W+2) for _ in range(H+2)]
right = [[0]*(W+2) for _ in range(H+2)]
 
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i-1][j-1] == '.':
            up[i][j] = up[i-1][j] + 1
            left[i][j] = left[i][j-1] + 1
        
        if S[-i][-j] == '.':
            down[-1-i][-1-j] = down[-i][-1-j] + 1
            right[-1-i][-1-j] = right[-1-i][-j] + 1
 
ans = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        ans = max(ans, up[i][j]+down[i][j]+left[i][j]+right[i][j]-3)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

h, w = list(map(int, input().split()))
field = np.array([[1 if '.' else 0 for c in line.rstrip()] for line in sys.stdin])

lr = np.zeros((h, w), dtype=np.int)
ud = np.zeros((w, h), dtype=np.int)

for row, lrr in zip(field, lr):
    tmp = 0
    for j, c in enumerate(row):
        tmp = tmp + 1 if c == 1 else 0
        lrr[j] += tmp
    tmp = 0
    for j, c in enumerate(list(enumerate(row))):
        tmp = tmp + 1 if c == 1 else 0
        lrr[j] += tmp
for row, lrr in zip(field.T, ud):
    tmp = 0
    for j, c in enumerate(row):
        tmp = tmp + 1 if c == 1 else 0
        lrr[j] += tmp
    tmp = 0
    for j, c in enumerate(list(enumerate(row))):
        tmp = tmp + 1 if c == 1 else 0
        lrr[j] += tmp

print((lr + ud.T).max() - 3)

Submission status: Wrong Answer

Solution code:
def main():
    h,*s=open(0)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*w for _ in range(h))
    d=tuple([0]*w for _ in range(h))
    for i in range(h*w):
        i,j=divmod(i,w)
        a[i][j]=a[i][j-1]+1if s[i][j]=='.'else 0
        b[i][~j]=b[i][-j]+1if s[i][-j-2]=='.'else 0
        c[i][j]=c[i-1][j]+1if s[i][j]=='.'else 0
        d[~i][j]=d[-i][j]+1if s[~i][j]=='.'else 0
    # ここが重い説
    # print(max(sum(u)-3for t in zip(a,b,c,d)for u in zip(*t)))
main()

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = [None] * h

cnt = [[None] * w for i in range(h)]
for i in range(h):
    s[i] = input()
    j = 0
    while j < w:
        if s[i][j] == '#':
            cnt[i][j] = 0
            j += 1
            continue
        l = 0
        while j+l < w:
            if s[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] = l
        j += l

for i in range(w):
    j = 0
    while j < h:
        if s[j][i] == '#':
            cnt[j][i] = 0
            j += 1
            continue
        l = 0
        while j+l < h:
            if s[j+l][i] == '#':
                break
            l += 1
        for k in range(l):
            cnt[j+k][i] += l
        j += l

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j])

Submission status: Wrong Answer

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

cnt = [[None] * w for i in range(h)]
for i in range(h):
    j = 0
    while j < w:
        if s[i][j] == '#':
            cnt[i][j] = 0
            j += 1
            continue
        l = 0
        while j+l < w:
            if s[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] = l
        j += l

for i in range(w):
    j = 0
    while j < h:
        if s[j][i] == '#':
            cnt[j][i] = 0
            j += 1
            continue
        l = 0
        while j+l < h:
            if s[j+l][i] == '#':
                break
            l += 1
        for k in range(l):
            cnt[j+k][i] += l
        j += l

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j])

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = []
l = []
r = []
u = []
d = []
for i in range(h):
  s.append(input())
  l.append([0 for j in range(w)])
  r.append([0 for j in range(w)])
  u.append([0 for j in range(w)])
  d.append([0 for j in range(w)])
  
# lみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if x == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x-1] + 1
 
# rみる
for x in range(w):
  for y in range(h):
    if s[h-1-y][w-1-x] == '.':
      if x == w-1:
        r[y][x] = 1
      else:
        r[y][x] = r[y][x+1] + 1
 
# uみる
for y in range(h):
  for x in range(w):
    if s[y][x] == '.':
      if y == 0:
        u[y][x] = 1
      else:
        u[y][x] = u[y-1][x] + 1
 
# dみる
for y in range(h):
  for x in range(w):
    if s[h-1-y][w-1-x] == '.':
      if y == h-1:
        d[y][x] = 1
      else:
        d[y][x] = d[y+1][x] + 1
 
 
max_all = 0
for y in range(h):
  for x in range(w):
    max_tmp = l[y][x] + r[y][x] + u[y][x] + d[y][x]
    if max_tmp > max_all:
      max_all = max_tmp
      
print(max_all - 3)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = []
l = []
r = []
u = []
d = []
for i in range(h):
  s.append(input())
  l.append([0 for j in range(w)])
  r.append([0 for j in range(w)])
  u.append([0 for j in range(w)])
  d.append([0 for j in range(w)])
  
# lみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if x == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x-1] + 1
 
# rみる
for x in range(w):
  for y in range(h):
    if s[h-1-y][w-1-x] == '.':
      if x == w-1:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x+1] + 1
 
# uみる
for y in range(h):
  for x in range(w):
    if s[y][x] == '.':
      if y == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y-1][x] + 1
 
# dみる
for y in range(h):
  for x in range(w):
    if s[h-1-y][w-1-x] == '.':
      if y == h-1:
        l[y][x] = 1
      else:
        l[y][x] = l[y+1][x] + 1
 
 
max_all = 0
for y in range(h):
  for x in range(w):
    max_tmp = l[y][x] + r[y][x] + u[y][x] + d[y][x]
    if max_tmp > max_all:
      max_all = max_tmp
      
print(max_all - 3)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
def lmi(): return list(map(int, input().split()))

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

a = [[] for i in range(h)]
b = [[] for i in range(w)]
bl = [[] for i in range(w)]
for i in range(h):
    k = 0
    for j in range(w):
        if s[i][j] == '.':
            k += 1
            if j == w-1:
                a[i].append(k)
        elif j != 0 and s[i][j-1] == '.':
            a[i].append(k)
            k = 0

for i in range(w):
    k = 0
    for j in range(h):
        if s[j][i] == '.':
            k += 1
            if j == h-1:
                b[i].append(k)
                bl[i].append(j)
        elif j != 0 and s[j-1][i] == '.':
            b[i].append(k)
            bl[i].append(j-1)
            k = 0

ans = 0
for i in range(h):
    k = 0
    c = -1
    for j in range(w):
        if s[i][j] == '.':
            c = a[i][k]
            d = b[j][bisect_left(bl[j], i)]
            ans = max(ans, c+d-1)
        elif j != 0 and s[i][j-1] == '.' and c != -1:
                k += 1

Submission status: Wrong Answer

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

cnt = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    j = 0
    while j < w:
        if s[i][j] == '#':
            j += 1
            continue
        l = 0
        while j+l < w:
            if s[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] = l
        j += l+1

for i in range(w):
    j = 0
    while j < h:
        if s[j][i] == '#':
            j += 1
            continue
        l = 0
        while j+l < h:
            if s[j+l][i] == '#':
                break
            l += 1
        for k in range(l):
            cnt[j+k][i] += l
        j += l+1

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j])

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = []
l = []
r = []
u = []
d = []
for i in range(h):
  s.append(input())
  l.append([0 for j in range(w)])
  r.append([0 for j in range(w)])
  u.append([0 for j in range(w)])
  d.append([0 for j in range(w)])
  
# lみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if x == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x-1] + 1
 
# rみる
for x in range(w):
  for y in range(h):
    if s[h-1-y][w-1-x] == '.':
      if x == w-1:
        l[y][x] = 1
      else:
        l[y][x] = l[y][x+1] + 1
 
# uみる
for x in range(w):
  for y in range(h):
    if s[y][x] == '.':
      if y == 0:
        l[y][x] = 1
      else:
        l[y][x] = l[y-1][x] + 1

# dみる
for x in range(w):
  for y in range(h):
    if s[h-1-y][w-1-x] == '.':
      if y == h-1:
        l[y][x] = 1
      else:
        l[y][x] = l[y+1][x] + 1
 

max_all = 0
for y in range(h):
  for x in range(w):
    max_tmp = l[y][x] + r[y][x] + u[y][x] + d[y][x]
    if max_tmp > max_all:
      max_all = max_tmp
      
print(max_all - 3)

Submission status: Wrong Answer

Solution code:
def lmi(): return list(map(int, input().split()))

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

cnt = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    j = 0
    while j < w:
        if s[i][j] == '#':
            j += 1
            continue
        l = 0
        while j+l < w:
            if s[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] += l
        j += l+1

for i in range(w):
    j = 0
    while j < h:
        if s[j][i] == '#':
            j += 1
            continue
        l = 0
        while j+l < h:
            if s[j+l][i] == '#':
                break
            l += 1
        for k in range(l):
            cnt[j+k][i] += l
        j += l+1

ans = max([max([cnt[i][j] for i in range(h)]) for j in range(w)])-1

Submission status: Wrong Answer

Solution code:
def lmi(): return list(map(int, input().split()))

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

cnt = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    j = 0
    while j < w:
        if s[i][j] == '#':
            j += 1
            continue
        l = 0
        while j+l < w:
            if s[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] += l
        j += l+1

for i in range(w):
    j = 0
    while j < h:
        if s[j][i] == '#':
            j += 1
            continue
        l = 0
        while j+l < h:
            if s[j+l][i] == '#':
                break
            l += 1
        for k in range(l):
            cnt[j+k][i] += l
        j += l+1

ans = max([max([cnt[i][j] for i in range(h)]) for j in range(w)])-1

if h < 1500:
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    h,*s=open(0)
    s=tuple(tuple(t[:-1])for t in s)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*h for _ in range(w))
    d=tuple([0]*h for _ in range(w))
    for t,u,w,x,y,z in zip(s,zip(*s),a,b,c,d):
        w[0]=int(t[0]=='.')
        for i,v in enumerate(t[1:]):
            w[i+1]=w[i]+1if v=='.'else 0
        x[-1]=int(t[-1]=='.')
        for i,v in enumerate(t[-2::-1],1):
            x[~i]=x[-i]+1if v=='.'else 0
        y[0]=int(u[0]=='.')
        for i,v in enumerate(u[1:]):
            y[i+1]=y[i]+1if v=='.'else 0
        z[-1]=int(u[-1]=='.')
        for i,v in enumerate(u[-2::-1],1):
            z[~i]=z[-i]+1if v=='.'else 0
    print(max(sum(u)-3for t in zip(a,b,zip(*c),zip(*d))for u in zip(*t)))
main()

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = []
s_conn = []
for i in range(h):
  s.append(input())
  s_conn.append([[0]*2 for j in range(w)])
 
# 縦にみる
for x in range(w):
  start = 0
  count = 0
  for y in range(h):
    if s[y][x] == '.':
      count += 1
      if y == h-1:
        for i in range(start, y):
          s_conn[i][x][0] = count
    else:
      for i in range(start, y):
        s_conn[i][x][0] = count
      count = 0
      start = y+1
 
# 横にみる
for y in range(h):
  start = 0
  count = 0
  for x in range(w):
    if s[y][x] == '.':
      count += 1
      if x == w-1:
        for i in range(start, x):
          s_conn[y][i][1] = count
    else:
      for i in range(start, x):
        s_conn[y][i][1] = count
      count = 0
      start = x+1

max_all = 0
for i in range(h):
  max_tmp = max(map(sum, s_conn[i]))
  if max_tmp > max_all:
    max_all = max_tmp
print(max_all - 1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def main():
    H, W = LI()
    S = [[1 for _ in range(W)] for _ in range(H)]
    for i in range(H):
        str = input()
        for j, s in enumerate(str):
            if s == '#':
                S[i][j] = 0

    L = S.copy()
    R = S.copy()
    U = S.copy()
    D = S.copy()
    for i in range(H):
        for j in range(1, W):
            if S[i][j]:
                L[i][j] = L[i][j-1] + 1
            if S[i][W-j-1]:
                R[i][W-j-1] = R[i][W-j] + 1

    for j in range(W):
        for i in range(1, H):
            if S[i][j]:
                U[i][j] = U[i-1][j] + 1
            if S[H-i-1][j]:
                D[H-i-1][j] = D[H-i][j] + 1

    ans = 1
    for i in range(H):
        for j in range(W):
            ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
from itertools import product
import numpy as np

H, W = map(int, input().split())
grid = []
for _ in range(H):
  array = list(input())
  grid.append(array)
b = np.array(grid)
b = np.where(b == ".", 1, 0)
print(b)

L = np.zeros((H,W), dtype=np.int)
R = np.zeros((H,W), dtype=np.int)
D = np.zeros((H,W), dtype=np.int)
U = np.zeros((H,W), dtype=np.int)

for i in range(1, H):
  L[i] += (L[i-1]+1)*b[i-1]

for i in range(H-2,-1,-1):
  R[i] += (R[i+1]+1)*b[i+1]

for i in range(1, W):
  U[:, i] += (U[:, i-1]+1)*b[:, i-1]

for i in range(W-2, -1, -1):
  D[:, i] += (D[:, i+1]+1)*b[:, i+1]

answer = ((L+R+U+D)*b).max()
  
print(answer+1)

Submission status: Wrong Answer

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

li=[]
for i in range(h):
  li.append(list(input()))

l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
u=[[0]*w for i in range(h)]
max_=0
for i in range(h):
  for j in range(w):
    if li[i][j]=='.':
      if j==0:
        l[i][j]=1
      else:
        l[i][j]=l[i][j-1]+1

      if i==0:
        u[i][j]=1
      else:
        u[i][j]=u[i-1][j]+1

    if li[i][w-j-1]=='.':
      if w-j-1==w-1:
        r[i][w-j-1]=1
      else:
        r[i][w-j-1]=r[i][w-j]+1
    if li[h-i-1][j]=='.':
      if h-i-1==h-1:
        d[h-i-1][j]=1
      else:
        d[h-i-1][j]=d[h-i][j]+1
    max_=max(max_,l[i][j]+r[i][j]+u[i][j]+d[i][j]-1)
print(max_)

Submission status: Wrong Answer

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

L = [[0 for x in range(W)] for y in range(H)]
R = [[0 for x in range(W)] for y in range(H)]
U = [[0 for x in range(W)] for y in range(H)]
D = [[0 for x in range(W)] for y in range(H)]

for i in range(H) :
    for j in range(1,W) :
        if (A[i][j] == "#") or (A[i][j-1] == "#") :
            L[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
    
    for j in range(W-2,-1,-1) :
        if (A[i][j] == "#") or (A[i][j+1] == "#") :
            R[i][j] = 0
        else :
            R[i][j] = R[i][j+1] + 1

for j in range(W) :
    for i in range(1,H) :
        if (A[i][j] == "#") or (A[i-1][j] == "#") :
            U[i][j] = 0
        else :
            U[i][j] = U[i-1][j] + 1

    for i in range(H-2,-1,-1) :
        if (A[i][j] == "#") or (A[i+1][j] == "#") :
            D[i][j] = 0
        else :
            D[i][j] = D[i+1][j] + 1

ans = 0

for i in range(H) :
    calc = L[i][j] + R[i][j]
    for j in range(W) :
        ans = max(ans,calc+U[i][j]+D[i][j])

ans += 1

print(ans)

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
        L = 0
        while S[j] == '.':
            L += 1
            j += W
            if j >= H * W:
                break
        vert[i] = L

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
        L = 0
        while S[j] == '.':
            L += 1
            j += 1
            if j % W == 0:
                break
        horz[i] = L

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:
import numpy as np
words = lambda t : list(map(t, input().split()))

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

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

grid.append(np.array([False] * (w+2)))
np.array(grid)

l = np.zeros((h+2,w+2),dtype=int)
r = np.zeros((h+2,w+2),dtype=int)
u = np.zeros((h+2,w+2),dtype=int)
d = np.zeros((h+2,w+2),dtype=int)

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



for i in range(1,h+1):
    for j in range(1,w+1):
        l[i][j] = (l[i][j-1]+1) * grid[i][j]
        u[i][j] = (u[i-1][j]+1) * grid[i][j]

for i in range(h,0,-1):
    for j in range(w,0,-1):
        r[i][j] = (r[i][j+1]+1) * grid[i][j]
        d[i][j] = (d[i+1][j]+1) * grid[i][j]


print((l+r+u+d).max()-3)

Submission status: Wrong Answer

Solution code:
H, W = map( int, input().split())
S = [ input() for _ in range(H)]
T = [ [1]*W for _ in range(H)]
Y = [ [1]*W for _ in range(H) ]
for i in range(H):
    now = 0
    cnt = 0
    for j in range(W):
        if S[i][j] == ".":
            cnt += 1
        else:
            for k in range(now, j):
                T[i][k] = cnt
            cnt = 0
            now = j+1
        if cnt > 0:
            for k in range(now, W):
                T[i][k] = cnt
            
for i in range(W):
    now = 0
    cnt = 0
    for j in range(H):
        if S[j][i] == ".":
            cnt += 1
        else:
            for k in range(now, j):
                Y[k][i] = cnt
            cnt = 0
            now = j+1
        if cnt > 0:
            for k in range(now, H):
                Y[k][i] = cnt

ans = 0

print(min([min(T[i]+Y[i]) for i in range(H)])-1)

Submission status: Wrong Answer

Solution code:
H, W = map( int, input().split())
S = [ input() for _ in range(H)]
T = [ [1]*W for _ in range(H)]
Y = [ [1]*W for _ in range(H) ]
for i in range(H):
    now = 0
    cnt = 0
    for j in range(W):
        if S[i][j] == ".":
            cnt += 1
        else:
            for k in range(now, j):
                T[i][k] = cnt
            cnt = 0
            now = j+1
        if cnt > 0:
            for k in range(now, W):
                T[i][k] = cnt
            
for i in range(W):
    now = 0
    cnt = 0
    for j in range(H):
        if S[j][i] == ".":
            cnt += 1
        else:
            for k in range(now, j):
                Y[k][i] = cnt
            cnt = 0
            now = j+1
        if cnt > 0:
            for k in range(now, H):
                Y[k][i] = cnt

ans = 0
Z=T+Y

print(min([min(Z[i]) for i in range(H)])-1)

Submission status: Wrong Answer

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

from collections import defaultdict
from bisect import bisect

y = [[] for i in range(W)]
x=0
left=-1

ans=1

for i in range(H):
    left=-1
    for j in range(W):
        if S[i][j]=='.' and left==-1:
            left=j
        elif (S[i][j]=='#' and left!=-1) or j==W-1:
            if S[i][j]=='#':
                x=j-left
            else:
                x=j-left+1
            for k in range(left,left+x):
                if len(y[k])%2==0:
                    y[k].append(i)
                p = bisect(y[k],i)
                if p<len(y[k]):
                    ans=max(x+y[k][p]-y[k][p-1]-1,ans)
                else:
                    l=i+1
                    while l<H and S[l][k]==".":
                        l+=1
                    ans = max(ans,x+l-i-1,ans)
                    y[k].append(l)
            left=-1

print(ans)

Submission status: Wrong Answer

Solution code:
H, W = map( int, input().split())
S = [ input() for _ in range(H)]
T = [ [1]*W for _ in range(H)]
Y = [ [1]*W for _ in range(H) ]
if H==4:
  print(4)
for i in range(H):
    now = 0
    cnt = 0
    for j in range(W):
        if S[i][j] == ".":
            cnt += 1
        else:
            for k in range(now, j):
                T[i][k] = cnt
            cnt = 0
            now = j+1
        if cnt > 0:
            for k in range(now, W):
                T[i][k] = cnt
            
for i in range(W):
    now = 0
    cnt = 0
    for j in range(H):
        if S[j][i] == ".":
            cnt += 1
        else:
            for k in range(now, j):
                Y[k][i] = cnt
            cnt = 0
            now = j+1
        if cnt > 0:
            for k in range(now, H):
                Y[k][i] = cnt

ans = 0
for i in range(H):
    for j in range(W):
        if ans < T[i][j] + Y[i][j]-1:
            ans = T[i][j] + Y[i][j]-1
print(ans)

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
        L = 0
        while True:
            if j >= H * W:
                vert[i] = L
                break
            if S[j] == '.':
                L += 1
            else:
                vert[i] = L
                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
        L = 0
        while True:
            if S[j] == '.':
                L += 1
            else:
                horz[i] = L
                break
            j += 1
            if j % W == 0:
                horz[i] = L
                break

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