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=list(list(input()) for i in range(h))
ans=0
dpL=[[0]*(w) for i in range(h)]
dpR=[[0]*(w) for i in range(h)]
dpU=[[0]*(w) for i in range(h)]
dpD=[[0]*(w) for i in range(h)]
#四方向用意
for i in range(h):
    for j in range(w):
        
        if s[i][j]=='.':
            if j==0:
                dpL[i][j]=1
            else:
                dpL[i][j]=dpL[i][j-1]+1
        else:
            continue
            
for i in range(h):
    for j in range(w-1,-1,-1):
        if s[i][j]=='.':
            if j==w-1:
                dpR[i][j]=1
            else:
                dpR[i][j]=dpR[i][j+1]+1
        else:
            continue
            
for i in range(w):
    for j in range(h):
        if s[j][i]=='.':
            if j==0:
                dpU[j][i]=1
            else:
                dpU[j][i]=dpU[j-1][i]+1
        else:
            continue
            
for i in range(w):
    for j in range(h-1,-1,-1):
        if s[j][i]=='.':
            if j==h-1:
                dpD[j][i]=1
            else:
                dpD[j][i]=dpD[j+1][i]+1
        else:
            continue

for i in range(h):
    for j in range(w):
        if dpU[i][j]+dpD[i][j]+dpR[i][j]+dpL[i][j]-3>ans:
            ans=dpU[i][j]+dpD[i][j]+dpR[i][j]+dpL[i][j]
print(ans)

Submission status: Wrong Answer

Solution code:
h,w=map(int, input().split())
s=list(list(input()) for i in range(h))
ans=0
dpL=[[0]*(w) for i in range(h)]
dpR=[[0]*(w) for i in range(h)]
dpU=[[0]*(w) for i in range(h)]
dpD=[[0]*(w) for i in range(h)]
#四方向用意
#1行目1列目と最終行列は壁として使う。
for i in range(h):
    for j in range(w):
        
        if s[i][j]=='.':
            if j==0:
                dpL[i][j]=1
            else:
                dpL[i][j]=dpL[i][j-1]+1
        else:
            s[i][j]=0
            
for i in range(h):
    for j in range(w-1,-1,-1):
        if s[i][j]=='.':
            if j==w-1:
                dpR[i][j]=1
            else:
                dpR[i][j]=dpR[i][j+1]+1
        else:
            s[i][j]=0
            
for i in range(w):
    for j in range(h):
        if s[j][i]=='.':
            if j==0:
                dpU[j][i]=1
            else:
                dpU[j][i]=dpU[j-1][i]+1
        else:
            s[j][i]=0
            
for i in range(w):
    for j in range(h-1,-1,-1):
        if s[j][i]=='.':
            if j==h-1:
                dpD[j][i]=1
            else:
                dpD[j][i]=dpD[j+1][i]+1
        else:
            s[j][i]=0

for i in range(h):
    for j in range(w):
        if dpU[i][j]+dpD[i][j]+dpR[i][j]+dpL[i][j]-3>ans:
            ans=dpU[i][j]+dpD[i][j]+dpR[i][j]+dpL[i][j]
print(ans)

Submission status: Wrong Answer

Solution code:
#ABC129 D
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
L = [[0 for i in range(W)] for j in range(H)]
R = [[0 for i in range(W)] for j in range(H)]
D = [[0 for i in range(W)] for j in range(H)]
U = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if S[i][j] == '#':
            continue
        elif j == 0:
            L[i][j] = 1
        elif L[i][j - 1] == 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] == '#':
            continue
        elif j == W - 1:
            R[i][j] = 1
        elif L[i][j + 1] == 0:
            R[i][j] = 1            
        else:
            R[i][j] = R[i][j + 1] + 1
            
for j in range(W):
    for i in range(H):
        if S[i][j] == '#':
            continue
        elif i == 0:
            L[i][j] = 1
        elif L[i - 1][j] == 0:
            L[i][j] = 1            
        else:
            L[i][j] = L[i - 1][j] + 1
            
for j in range(W):
    for i in range(H - 1, -1, -1):
        if S[i][j] == '#':
            continue
        elif i == H - 1:
            R[i][j] = 1
        elif L[i + 1][j] == 0:
            R[i][j] = 1            
        else:
            R[i][j] = R[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] + D[i][j] + U[i][j] - 3))
        
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
h,w=map(int,input().split())
s = [list(input()) for i in range(h)]
s = np.array(s)
ans=0
for i in range(h):
  for j in range(w):
    if s[i,j]=='.':
      cnt=0
      tmp_i=i
      tmp_j=j
      while s[i,j]=='.':
        i+=1
        if i<0 or h<=i:
          break
        cnt+=1
      i=tmp_i
      while s[i,j]=='.':
        i-=1
        if i<0 or h<=i:
          break
        cnt+=1
      i=tmp_i
      while s[i,j]=='.':
        j+=1
        if j<0 or w<=j:
          break
        cnt+=1
      j=tmp_j
      while s[i,j]=='.':
        j-=1
        if j<0 or w<=j:
          break
        cnt+=1
      ans=max(ans,cnt)
print(ans)

Submission status: Wrong Answer

Solution code:

Submission status: Wrong Answer

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

u = [[0 for i in range(w)] for j in range(h)]
d = [[0 for i in range(w)] for j in range(h)]
l = [[0 for i in range(w)] for j in range(h)]
r = [[0 for i in range(w)] for j in range(h)]

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

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

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

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

s = [[0 for i in range(w)] for j in range(h)] 
maxs = 0
for i in range(h):
    for j in range(w):
        s[i][j] = u[i][j] + l[i][j] + d[i][j] + r[i][j] - 3

print(maxs)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
meiro = [list(input()) for i in range(H)]
print(meiro)
right = [[0 for _ in range(W)] for _ in range(H)]
left= [[0 for _ in range(W)] for _ in range(H)]
up = [[0 for _ in range(W)] for _ in range(H)]
down = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    cur=0
    for j in range(W):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        left[i][j]=cur
for i in range(H):
    cur=0
    for j in range(W-1,-1,-1):
        if meiro[i][j]=="#":
            cur = 0
        else:
            cur +=1
        right[i][j]=cur
for i in range(W):
    cur=0
    for j in range(H):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        up[j][i]=cur
for i in range(W):
    cur=0
    for j in range(H-1,-1,-1):
        if meiro[j][i]=="#":
            cur = 0
        else:
            cur +=1
        down[j][i]=cur
res = 0
for i in range(H):
    for j in range(W):
        res = max(res,right[i][j]+left[i][j]+up[i][j]+down[i][j]-3)
print(res)

Submission status: Wrong Answer

Solution code:
import sys

H,W = list(map(int, input().split()))
S = [[]]*H

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

T = [None]*W

for w in range(W):
    t = [S[h][w] for h in range(H)]
    T[w] = ''.join(t)

print(S)
print(T)


def calc_lights_map(MAP, H, W):
    LIGHTS_MAP = [None]*H
    for h in range(H):
        lights_map_row = calc_lights_map_row(MAP[h], W)
        LIGHTS_MAP[h] = lights_map_row
    return LIGHTS_MAP


def calc_lights_map_row(ROW, W):
    lights_map_row = []
    lights = 0
    for here, masu in enumerate(ROW):
        if masu == '#':
            lights_map_row.append(0)
            lights = 0
            continue
        if lights > 0:
            lights_map_row.append(lights)
            continue
        try:
            wall_id = ROW.index('#', here)
        except:
            wall_id = len(ROW)
        lights = wall_id - here
        lights_map_row.append(lights)
        continue
    return lights_map_row

S_lights_map = calc_lights_map(S, H, W)

print(S)
print(S_lights_map)

T_lights_map = calc_lights_map(T, W, H)

print(T)
print(T_lights_map)


max_lights = 0
for h in range(H):
    for w in range(W):
        lights = S_lights_map[h][w] + T_lights_map[w][h] - 1
        max_lights = max(max_lights, lights)


print(max_lights)

Submission status: Wrong Answer

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

#横
hl=[[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    left=0
    temp=0
    for j in range(w):
        if s[i][j]==".":
            if j==(w-1):
                temp +=1
                for k in range(left,w):
                    hl[i][k]=temp
            else:
                temp+=1
        else:
            for k in range(left,j):
                hl[i][k]=temp
            hl[i][j]=0
            temp=0
            left=j+1

#縦
wl=[[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    up=0
    temp=0
    for i in range(h):
        if s[i][j]==".":
            if i==(h-1):
                temp +=1
                for k in range(up,h):
                    wl[k][j]=temp
            else:
                temp+=1
        else:
            for k in range(up,i):
                wl[k][j]=temp
            wl[i][j]=0
            temp=0
            up=j+1

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

print(ans-1)

Submission status: Wrong Answer

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

#横
hl=[[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    left=0
    temp=0
    for j in range(w):
        if s[i][j]==".":
            if j==(w-1):
                temp +=1
                for k in range(left,w):
                    hl[i][k]=temp
            else:
                temp+=1
        else:
            for k in range(left,j):
                hl[i][k]=temp
            hl[i][j]=0
            temp=0
            left=j+1

#縦
wl=[[0 for _ in range(w)] for _ in range(h)]
for j in range(w):
    up=0
    temp=0
    for i in range(h):
        if s[i][j]==".":
            if i==(h-1):
                temp +=1
                for k in range(up,h):
                    wl[k][j]=temp
            else:
                temp+=1
        else:
            for k in range(up,i):
                wl[k][j]=temp
            wl[i][j]=0
            temp=0
            up=j+1

whl=[0 for i in range(h*w)]
for i in range(h):
    for j in range(w):
        whl[j+i*w]=hl[i][j]+wl[i][j]

print(max(whl)-1)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

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

num_yoko = [[0 for i in range(W)] for j in range(H)]
num_tate = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            if j == 0:
                num_yoko[i][j] = 1
            else:
                num_yoko[i][j] = num_yoko[i][j - 1] + 1
            if i == 0:
                num_tate[i][j] = 1
            else:
                num_tate[i][j] = num_tate[i - 1][j] + 1
for i in range(H - 1, -1, -1):
    for j in range(W - 1, -1, -1):
        if grid[i][j] == '.':
            if j != W - 1:
                if num_yoko[i][j + 1] != 0:
                    num_yoko[i][j] = num_yoko[i][j + 1]
            if i != H - 1:
                if num_tate[i + 1][j] != 0:
                    num_tate[i][j] = num_tate[i + 1][j]

num_max = 0
for i in range(H - 1):
    for j in range(W - 1):
        if num_yoko[i][j] + num_tate[i][j] > num_max:
            num_max =  num_yoko[i][j] + num_tate[i][j]

print(max(0, num_max - 1))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque, defaultdict
import copy
import bisect
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 9)

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

num_yoko = [[0 for i in range(W)] for j in range(H)]
num_tate = [[0 for i in range(W)] for j in range(H)]

for i in range(H):
    for j in range(W):
        if grid[i][j] == '.':
            if j == 0:
                num_yoko[i][j] = 1
            else:
                num_yoko[i][j] = num_yoko[i][j - 1] + 1
            if i == 0:
                num_tate[i][j] = 1
            else:
                num_tate[i][j] = num_tate[i - 1][j] + 1
for i in range(H - 1, -1, -1):
    for j in range(W - 1, -1, -1):
        if grid[i][j] == '.':
            if j != W - 1:
                if num_yoko[i][j + 1] != 0:
                    num_yoko[i][j] = num_yoko[i][j + 1]
            if i != H - 1:
                if num_tate[i + 1][j] != 0:
                    num_tate[i][j] = num_tate[i + 1][j]

num_max = 0
for i in range(H - 1):
    for j in range(W - 1):
        if num_yoko[i][j] + num_tate[i][j] > num_max:
            num_max =  num_yoko[i][j] + num_tate[i][j]

print(num_max - 1)

Submission status: Wrong Answer

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

def search(h, w, F, H, W):
    cnt = 0
    for i in range(h+1, H):
        if F[i][w] == '.':
            cnt += 1
            F[i][w] = ''
    for i in range(w+1, W):
        if F[h][i] == '.'    :
            cnt += 1
            F[h][i] = ''
    for i in range(h-1, -1, -1):
        if F[i][w] == '.':
            cnt += 1
            F[i][w] = ''
    for i in range(w-1, -1, -1):
        if F[h][i] == '.':
            cnt += 1
            F[h][i] = ''
    return cnt

cnt = 0
for w in range(W):
    for h in range(H):
        if S[h][w] == '.':
            cnt = max(search(h, w, copy.deepcopy(S), H, W)+1, cnt)

print(cnt)

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
s=[0 for j in range(H)]
for i in range(H):
  s[i]=str(input())
  s[i]=[j for j in s[i]]
L=[[0 for i in range(W)] for j in range(H)]
R=[[0 for i in range(W)] for j in range(H)]
U=[[0 for i in range(W)] for j in range(H)]
D=[[0 for i in range(W)] for j in range(H)]
a=1
for i in range(H):
  if s[i][0]=='.':
    L[i][0]=1
  if s[i][W-1]=='.':
    R[i][W-1]=1
for j in range(W):
  if s[0][j]=='.':
    U[0][j]=1
  if s[H-1][j]=='.':
    D[H-1][j]=1
for i in range(1,H):
  for j in range(1,W):
    if s[i][j]=='.':
      L[i][j]=L[i][j-1]+1
      U[i][j]=U[i-1][j]+1
    if s[H-i-1][W-j-1]=='.':
      R[H-i-1][W-j-1]=R[H-i-1][W-j]+1
      D[H-i-1][W-j-1]=D[H-i][W-j-1]+1
for i in range(H):
  for j in range(W):
    count=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3
    if a<count:
      a=count
print(a)

Submission status: Wrong Answer

Solution code:
H, W = list(map(int, input().split()))
M = [['.' for w in range(W)] for h in range(H)]
for h in range(0, H):
    M[h] = list(input())

Yoko = [[0 for w in range(W)] for h in range(H)]
Tate = [[0 for w in range(W)] for h in range(H)]
for h in range(0, H):
    for w in range(0, W):
        if M[h][w] != '#':
            if w >= 0 and M[h][w - 1] != '#':
                Yoko[h][w] = Yoko[h][w - 1]
            else:
                c = 0
                for d in range(w, W):
                    if M[h][d] == '#':
                        break
                    c += 1
                Yoko[h][w] = c
for w in range(0, W):
    for h in range(0, H):
        if M[h][w] != '#':
            if h >= 0 and Tate[h - 1][w] > 0:
                Tate[h][w] = Tate[h - 1][w]
            else:
                c = 0
                for d in range(h, H):
                    if M[d][w] == '#':
                        break
                    c += 1
                Tate[h][w] = c
mx = 0
for w in range(0, W):
    for h in range(0, H):
        c = Yoko[h][w] + Tate[h][w] - 1
        if Yoko[h][w] == 0 or Tate[h][w] == 0:
            c += 1
        if c > mx:
            mx = c
print(mx)

Submission status: Wrong Answer

Solution code:
H, W = list(map(int, input().split()))
M = [['.' for w in range(W)] for h in range(H)]
for h in range(0, H):
    M[h] = list(input())

Yoko = [[0 for w in range(W)] for h in range(H)]
Tate = [[0 for w in range(W)] for h in range(H)]
for h in range(0, H):
    for w in range(0, W):
        if M[h][w] != '#':
            if w >= 0 and M[h][w - 1] != '#':
                Yoko[h][w] = Yoko[h][w - 1]
            else:
                c = 0
                for d in range(w, W):
                    if M[h][d] == '#':
                        break
                    c += 1
                Yoko[h][w] = c
for w in range(0, W):
    for h in range(0, H):
        if M[h][w] != '#':
            if h >= 0 and Tate[h - 1][w] > 0:
                Tate[h][w] = Tate[h - 1][w]
            else:
                c = 0
                for d in range(h, H):
                    if M[d][w] == '#':
                        break
                    c += 1
                Tate[h][w] = c
mx = 0
for w in range(0, W):
    for h in range(0, H):
        if M[h][w] != '#':
            c = Yoko[h][w] + Tate[h][w] - 1
            if c > mx:
                mx = c
print(mx)

Submission status: Wrong Answer

Solution code:
H, W = list(map(int, input().split()))
M = [['.' for w in range(W)] for h in range(H)]
for h in range(0, H):
    M[h] = list(input())

Yoko = [[0 for w in range(W)] for h in range(H)]
Tate = [[0 for w in range(W)] for h in range(H)]
for h in range(0, H):
    for w in range(0, W):
        if M[h][w] != '#':
            if w >= 0 and M[h][w - 1] != '#':
                Yoko[h][w] = Yoko[h][w - 1]
            else:
                c = 0
                for d in range(w, W):
                    if M[h][d] == '#':
                        break
                    c += 1
                Yoko[h][w] = c
for w in range(0, W):
    for h in range(0, H):
        if M[h][w] != '#':
            if h >= 0 and Tate[h - 1][w] > 0:
                Tate[h][w] = Tate[h - 1][w]
            else:
                c = 0
                for d in range(h, H):
                    if M[d][w] == '#':
                        break
                    c += 1
                Tate[h][w] = c
mx = 0
for w in range(0, W):
    for h in range(0, H):
        c = Yoko[h][w] + Tate[h][w] - 1
        if c > mx:
            mx = c
print(mx)

Submission status: Wrong Answer

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

# In[64]:


import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for i in range(H)])
"""
4 6
#..#..
.....#
....#.
#.#...
"""


# In[72]:


field = np.ones((H, W))
field[S=='#'] = 0
lm, rm, um, dm = (field.copy() for _ in [0]*4)
#print(field)


# In[73]:


#np.where()
for i in range(1, H):
    um[i] = (um[i-1]+1) * field[i]
    dm[-1-i] = (dm[-i]+1) * field[i]
    
for i in range(1, W):
    lm[:, i] = (lm[:, i-1]+1) * field[:, i]
    rm[:, -1-i] = (rm[:, -i]+1) * field[:, i]


# In[75]:


#print(um)
#print(dm)
#print(lm)
#print(rm)
print(int(np.max(um+dm+lm+rm)-3))


# In[ ]:

Submission status: Wrong Answer

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

s = [0] * H

for i in range(H) :
    s[i] = list(input())

# 端をゼロパディング
L = [[0 for _ in range(W+2)] for _ in range(H+2)]
R = [[0 for _ in range(W+2)] for _ in range(H+2)]
U = [[0 for _ in range(W+2)] for _ in range(H+2)]
D = [[0 for _ in range(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] == '#' :
            L[i][j] = 0
            U[i][j] = 0
        else :
            L[i][j] = L[i][j-1] + 1
            U[i][j] = U[i-1][j] + 1
        # 右下から
        if s[-i][-j] == '#' :
            R[i][j] = 0
            D[i][j] = 0
        else :
            R[-i-1][-j-1] = R[-i-1][-j] + 1
            D[-i-1][-j-1] = D[-i][-j-1] + 1

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    h,w = map(int,input().split())
    a = {}
    for i in range(h):
        a[i] = input()
    ans = 0
    L = []
    R = []
    D = []
    U = []
    for x in range(h):
        L.append([])
        R.append([])
        for y in range(w):
            if a[x][y] == "#":
                L[x].append(0)
            elif y == 0:
                L[x].append(1)
            else:
                L[x].append(L[x][y-1]+1)
        for y in range(w-1,-1,-1):
            if a[x][y] == "#":
                R[x].append(0)
            elif y == w-1:
                R[x].append(1)
            else:
                R[x].append(R[x][w-y-2]+1)
        R[x].reverse()
    for y in range(w):
        D.append([])
        U.append([])
        for x in range(h):
            if a[x][y] == "#":
                U[y].append(0)
            elif x == 0:
                U[y].append(1)
            else:
                U[y].append(U[y][x-1]+1)
        for x in range(h-1,-1,-1):
            if a[x][y] == "#":
                D[y].append(0)
            elif x == h-1:
                D[y].append(1)
            else:
                D[y].append(D[y][h-x-2]+1)
        D[x].reverse()

    for x in range(h):
        for y in range(w):
            ans = max(ans, R[x][y]+L[x][y]+U[y][x]+D[y][x]-3)
            
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import itertools
h,w = map(int,input().split())
S = [0 for i in range(h)]
Left =[[1 for j in range(w)] for i in range(h)]
Right = [[1 for j in range(w)] for i in range(h)]
Up = [[1 for j in range(w)] for i in range(h)]
Down = [[1 for j in range(w)] for i in range(h)]


for i in range(h):
    S[i] = list(input())
    
for i in range(h):
    cnt = 0
    for j in range(w-1,0,-1):
        if S[i][j] == '#':
            #Left[i][j] = 0
            cnt = 0
        else:
            cnt += 1
            Left[i][j] += cnt
for i in range(h):
    cnt = 0
    for j in range(0,w,1):
        if S[i][j] == '#':
            #Right[i][j] = 0
            cnt = 0
        else:
            cnt += 1
            Right[i][j] = cnt
for j in range(w):
    cnt = 0
    for i in range(0,h,1):
        if S[i][j] == '#':
            #Down[i][j] = 0
            cnt = 0
        else:
            cnt += 1
            Down[i][j] = cnt
for j in range(w):
    cnt = 0
    for i in range(h-1,0,-1):
        if S[i][j] == '#':
            #Up[i][j] = 0
            cnt = 0
        else:
            cnt += 1
            Up[i][j] = cnt

ans = 0
for i in range(h):
    for j in range(w):
        if S[i][j] != 1:
            ans = max(ans,Left[i][j]+Right[i][j]+Down[i][j]+Up[i][j]-3)

print(ans)

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
s=[list(input())for _ in range(h)]
score=[[0]*w for _ in range(h)]
ans=0
range_w=range(w)
range_h=range(h)
for i in range_h:
  tmp_1=0
  tmp_2=0
  for j in range_w:
    if s[i][j]=="#":
      tmp_1=0
    else:
      tmp_1+=1
    score[i][j]+=tmp_1
    
    if s[i][-j-1]=="#":
      tmp_2=0
    else:
      tmp_2+=1
    score[i][-j-1]+=tmp_2
    
for j in range_w:
  tmp_3=0
  tmp_4=0
  for i in range_h:
    if s[i][j]=="#":
      tmp_3=0
    else:
      tmp_3+=1
    score[i][j]+=tmp_3
    
    if s[-i-1][j]=="#":
      tmp_4=0
    else:
      tmp_4+=1
    score[-i-1][j]+=tmp_4-3
for i in range(h):
  for j in range(w):
    ans=max(ans,score[i][j])

Submission status: Wrong Answer

Solution code:
import numpy
h,w=map(int,input().split())
s=[list(input())for _ in range(h)]
score=[[0]*w for _ in range(h)]
ans=0
range_w=range(w)
range_h=range(h)
r_range_w=range(w)[::-1]
r_range_h=range(h)[::-1]
for i in range_h:
  tmp=0
  for j in range_w:
    if s[i][j]=="#":
      tmp=0
    else:
      tmp+=1
    score[i][j]+=tmp
for i in range_h:
  tmp=0
  for j in r_range_w:
    if s[i][j]=="#":
      tmp=0
    else:
      tmp+=1
    score[i][j]+=tmp
for j in range_w:
  tmp=0
  for i in range_h:
    if s[i][j]=="#":
      tmp=0
    else:
      tmp+=1
    score[i][j]+=tmp
for j in range_w:
  tmp=0
  for i in r_range_h:
    if s[i][j]=="#":
      tmp=0
    else:
      tmp+=1
    score[i][j]+=tmp-3
    ans=max(ans,score[i][j])
print(score)
print(ans)

Submission status: Wrong Answer

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

mcnt=0
res=(0,0)

for y in range(H):
    for x in range(W):
        cnt=0
        if S[y][x] == '#':
            continue
        ny = y
        while ny >= 0:
            if S[ny][x] == '.':
                cnt+=1
                ny-=1
            else:
                break
        ny = y
        while ny < H:
            if S[ny][x] == '.':
                cnt+=1
                ny+=1
            else:
                break
        nx = x
        while nx >= 0:
            if S[y][nx] == '.':
                nx-=1
                cnt+=1
            else:
                break
        nx = x
        while nx < W:
            if S[y][nx] == '.':
                nx+=1
                cnt+=1
            else:
                break
        cnt-=3
        if mcnt < cnt:
            mcnt = cnt
            res=(y,x)

print(mcnt)

Submission status: Wrong Answer

Solution code:

import sys


# python template for atcoder1
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H, W = map(int, input().split())
grid = [[v for v in input()[:-1]] for _ in range(H)]

col_seq = [[-1]*W for _ in range(H)]
row_seq = [[-1]*W for _ in range(H)]

for row in range(H):
    for col in range(W):
        if grid[row][col] == "#":
            col_seq[row][col] = 0
            row_seq[row][col] = 0

# init columns
for row in range(H):
    for col1, col2 in zip(range(W), range(1, W)):
        if grid[row][col1] == "." and grid[row][col2] == "." and col_seq[row][col1] == -1:
            seq = 2
            next_col = col2+1
            while next_col < W:
                if grid[row][next_col] == ".":
                    seq += 1
                else:
                    break
                next_col += 1
            for i in range(col1, col1+seq):
                col_seq[row][i] = seq

# init rows:
for col in range(W):
    for row1, row2 in zip(range(H), range(1, H)):
        if grid[row1][col] == "." and grid[row2][col] == "." and row_seq[row1][col] == -1:
            seq = 2
            next_row = row2+1
            while next_row < H:
                if grid[next_row][col] == ".":
                    seq += 1
                else:
                    break
                next_row += 1
            for i in range(row1, row1+seq):
                row_seq[i][col] = seq

ans = 0
for row in range(H):
    for col in range(W):
        if grid[row][col] == ".":
            tmp = col_seq[row][col]+row_seq[row][col]-1
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:

import sys


# python template for atcoder1
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H, W = map(int, input().split())
grid = [[v for v in input()[:-1]] for _ in range(H)]

col_seq = [[0]*W for _ in range(H)]
row_seq = [[0]*W for _ in range(H)]

# init columns
for row in range(H):
    for col1, col2 in zip(range(W), range(1, W)):
        if grid[row][col1] == "." and grid[row][col2] == "." and col_seq[row][col1] == 0:
            seq = 2
            next_col = col2+1
            while next_col < W:
                if grid[row][next_col] == ".":
                    seq += 1
                else:
                    break
                next_col += 1
            for i in range(col1, col1+seq):
                col_seq[row][i] = seq

# init rows:
for col in range(W):
    for row1, row2 in zip(range(H), range(1, H)):
        if grid[row1][col] == "." and grid[row2][col] == "." and row_seq[row1][col] == 0:
            seq = 2
            next_row = row2+1
            while next_row < H:
                if grid[next_row][col] == ".":
                    seq += 1
                else:
                    break
                next_row += 1
            for i in range(row1, row1+seq):
                row_seq[i][col] = seq

ans = 0
for row in range(H):
    for col in range(W):
        if grid[row][col] == ".":
            tmp = col_seq[row][col]+row_seq[row][col]-1
            ans = max(ans, tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
H,W = map(int,input().split())
S=[input() for i in range(H)]
A=[ [0]*W for i in range(H)] # extensionable size at row direction
B=[ [0]*W for i in range(H)] # extentionable size at collum direction
# make extension table
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      A[i][j] = B[i][j] = 0
      continue
    # Calcurate extension case
    if j== 0 or A[i][j-1] == 0:
      numA = 0 # extension size of row 
      k = j
      while True:
        numA += 1
        if k == W-1 or S[i][k+1] == "#": # boundary point
          A[i][j] = numA
          break
        k += 1
    else:
      A[i][j] = A[i][j-1]
    
    if i == 0 or B[i-1][j] == 0:
      numB =0
      k = i
      while True: # extension size of cullum
        numB += 1
        if k == H-1 or S[k+1][j] == "#": # boundary point
          B[i][j] = numB
          break
        k += 1
    else:
      B[i][j] = B[i-1][j]

# max of A[i][j]+B[i][j]-1
ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans,A[i][j]+B[i][j]-1)
    print(A[i][j]+B[i][j]-1,end=",") # for debug
  print("")
print(ans)