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

h, w = map(int, sys.stdin.readline().split())
grid = np.array([list(sys.stdin.readline().rstrip()) for _ in range(h)], dtype='U')
grid = np.pad(grid, 1, mode='constant')

def main():
    cnt = np.zeros((h+2, w+2))
    cnt[grid == '.'] = np.inf
    
    l = cnt.copy()
    r = cnt.copy()
    u = cnt.copy()
    d = cnt.copy()

    for i in range(1, w+1):
        l[1:h+1, i] = np.minimum(l[1:h+1, i], l[1:h+1, i-1]+1)
        i = w + 1 - i
        r[1:h+1, i] = np.minimum(r[1:h+1, i], r[1:h+1, i+1]+1)
    
    for i in range(1, h+1):
        u[i, 1:w+1] = np.minimum(r[i, 1:w+1], u[i-1, 1:w+1]+1)
        i = h + 1 - i
        d[i, 1:w+1] = np.minimum(d[i, 1:w+1], d[i+1, 1:w+1]+1)
    
    res = np.maximum(l + r + u + d - 3, 0).astype(np.int64)
    return np.amax(res)

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

Solution code:
h, w = list(map(int, input().split(' ')))
field = []
for i in range(h):
    field.append(input())
 
dp = []
for i in range(h):
    dp.append([(0, 0)] * w)
for i in range(h):
    for j in range(w):  # 2e3 * 2e3
        if field[i][j] == '#':
            x, y = 0, 0
        else:
            if i == j == 0:
               x, y = 1, 1
            else:
                y = (dp[i-1][j][0] + 1) if i-1 >= 0 else 1
                x = (dp[i][j-1][1] + 1) if j-1 >= 0 else 1
        dp[i][j] = (y, x)
ans = 0
 
for i in range(h-1, -1, -1):
    for j in range(w-1, -1, -1):
        if field[i][j] != '#':
            y = dp[i+1][j][0] if i+1 < h else dp[i][j][0]
            x = dp[i][j+1][1] if j+1 < w else dp[i][j][1]
            dp[i][j] = (max(dp[i][j][0], y), max(dp[i][j][1], x))
            ans = max(x + y - 1, ans)
print(ans)

Submission status: Wrong Answer

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

dp = []
for i in range(h):
    dp.append([(0, 0)] * w)
for i in range(h):
    for j in range(w):  # 2e3 * 2e3
        if field[i][j] == '#':
            x, y = 0, 0
        else:
            if i == j == 0:
               x, y = 1, 1
            else:
                y = (dp[i-1][j][0] + 1) if i-1 >= 0 else 1
                x = (dp[i][j-1][1] + 1) if j-1 >= 0 else 1
        dp[i][j] = (y, x)
ans = 0

for i in range(h-1, -1, -1):
    for j in range(w-1, -1, -1):
        if field[i][j] != '#':
            y = dp[i+1][j][0] if i+1 < h else dp[i][j][0]
            x = dp[i][j+1][1] if j+1 < w else dp[i][j][1]
            dp[i][j] = (max(dp[i][j][0], y), max(dp[i][j][1], x))
            ans = max(x + y - 1, ans)
print(ans)

Submission status: Wrong Answer

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

dp = []
for i in range(h):
    dp.append([(0, 0)] * w)
for i in range(h):
    for j in range(w):  # 2e3 * 2e3
        if field[i][j] == '#':
            x, y = 0, 0
        else:
            if i == j == 0:
               x, y = 1, 1
            else:
                y = (dp[i-1][j][0] + 1) if i-1 >= 0 else 1
                x = (dp[i][j-1][1] + 1) if j-1 >= 0 else 1
        dp[i][j] = (y, x)
ans = 0

for i in range(h-1, -1, -1):
    for j in range(w-1, -1, -1):
        if field[i][j] != '#':
            y = dp[i+1][j][0] if i+1 < h else dp[i][j][0]
            x = dp[i][j+1][1] if j+1 < w else dp[i][j][1]
            dp[i][j] = (max(dp[i][j][0], y), max(dp[i][j][1], x))
            ans = max(x + y - 1, ans)

print(ans)

Submission status: Wrong Answer

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

dp = {}  # [(0, 0), ...]
for i in range(h):
    for j in range(w):  # 2e3 * 2e3
        if field[i][j] == '#':
            x, y = 0, 0
        else:
            if i == j == 0:
               x, y = 1, 1
            else:
                y = (dp[i-1, j][0] + 1) if i-1 >= 0 else 1
                x = (dp[i, j-1][1] + 1) if j-1 >= 0 else 1
        dp[i, j] = (y, x)
ans = 0
#print(dp)
#for i in range(h):
#    hoge = []
#    for j in range(w):
#        hoge.append('/'.join(map(str, dp[(i, j)])))
#    print(', '.join(hoge))
#print('=================')
for i in range(h-1, -1, -1):
    for j in range(w-1, -1, -1):
        if field[i][j] != '#':
            y = dp[(i+1, j)][0] if i+1 < h else dp[(i, j)][0]
            x = dp[(i, j+1)][1] if j+1 < w else dp[(i, j)][1]
            dp[(i, j)] = (max(dp[(i, j)][0], y), max(dp[(i, j)][1], x))
            ans = max(x + y - 1, ans)
#print(dp)
#for i in range(h):
#    hoge = []
#    for j in range(w):
#        hoge.append('/'.join(map(str, dp[(i, j)])))
#    print(', '.join(hoge))
print(ans)

Submission status: Wrong Answer

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

dp = {}  # [(0, 0), ...]
for i in range(h):
    for j in range(w):  # 2e3 * 2e3
        if field[i][j] == '#':
            x, y = 0, 0
        else:
            if i == j == 0:
               x, y = 1, 1
            else:
                x = (dp[i-1, j][0] + 1) if i-1 >= 0 else 1
                y = (dp[i, j-1][1] + 1) if j-1 >= 0 else 1
        dp[i, j] = (x, y)
ans = 0
for i in range(h-1, -1, -1):
    for j in range(w-1, -1, -1):
        if field[i][j] != '#':
            x = dp[(i, j+1)][0] if j+1 < w else dp[(i, j)][0]
            y = dp[(i, j+1)][1] if j+1 < w else dp[(i, j)][1]
            x = max(x, dp[(i+1, j)][0] if i+1 < h else dp[(i, j)][0])
            y = max(y, dp[(i+1, j)][1] if i+1 < h else dp[(i, j)][1])
            dp[(i, j)] = (max(dp[(i, j)][0], x), max(dp[(i, j)][1], y))
            ans = max(x + y - 1, ans)
# print(dp)
# for i in range(h):
#     hoge = []
#     for j in range(w):
#         hoge.append('/'.join(map(str, dp[(i, j)])))
#     print(', '.join(hoge))
print(ans)

Submission status: Wrong Answer

Solution code:
import os, sys, re, math

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

result = 0
for y in range(H):
    for x in range(W):
        if S[y][x] == '#':
            continue
        count = 1
        for xx in range(x + 1, W, 1):
            if S[y][xx] == '#':
                break
            count += 1
        for xx in range(x - 1, -1, -1):
            if S[y][xx] == '#':
                break
            count += 1
        for yy in range(y + 1, H, 1):
            if S[yy][x] == '#':
                break
            count += 1
        for xx in range(y - 1, -1, -1):
            if S[yy][x] == '#':
                break
            count += 1
        result = max(result, count)

print(result)

Submission status: Wrong Answer

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

l = [[0] * w for _ in range(h)]
r = [[0] * w for _ in range(h)]
u = [[0] * w for _ in range(h)]
d = [[0] * w for _ 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
      r[i][w-j-1] = 1
    else:
      l[i][j] = l[i][j-1] + 1
      r[i][w-j-1] = r[i][w-j] + 1

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

maximum = 1
for i in range(h):
  for j in range(w):
    maximum = max(maximum, l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3)
print(maximum)

Submission status: Wrong Answer

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

def main():
    H,W = map(int,input().split())

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

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


    M = 0
    for i in range(H):
        cou2 = 0
        max = 0
        for j in range(W+1):
            if S[i][j] == '#' or S[i][j] == '\n':
                if max < cou2:
                    max = cou2
                    for k in range(j-max,j):
                        cou1 = cou2
                        for n in range(H-i-1):
                            if S[i+n+1][k] == '.':
                                cou1 += 1
                            else:
                                break
                        for n in range(i):
                            if S[i-n-1][k] == '.':
                                cou1 += 1
                            else:
                                break
                        if cou1 > M:
                            M = cou1
                    cou2 = 0
            else:
                cou2 +=1

    print(M)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def rowLight(i, j, S, W):
    max = W
    min = -1
    for x in reversed(range(0, j)):
        if S[i][x] == 35:
            min = x
            break

    for x in range(j, W):
        if S[i][x] == 35:
            max = x
            break
    return (max - min - 1)

def columnLight(i, j, S, H):
    max = H
    min = -1
    for y in reversed(range(0, i)):
        if S[y][j] == 35:
            min = y
            break

    for y in range(j, H):
        if S[y][j] == 35:
            max = y
            break
    return (max - min - 1)


def main():
    H,W = map(int,input().split())
    S = [list(input()) for _ in range(H)]
    max = 0
    for i in range(H):
        for j in range(W):
            if S[i][j] == 46:
                tmp = rowLight(i, j, S, W) + columnLight(i, j, S, H) - 1
                if tmp > max:
                    max = tmp
    print(max)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def main():
    H,W = map(int,input().split())

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

    for i in range(H):
        X = list(input())
        for j in range(W):
            S[i].insert(j,X[j])

    M = 0
    for i in range(H):
        for j in range(W):
            cou = 0
            if S[i][j] == '.':
                for n in range(i):
                    if S[i-n][j] == '.':
                        cou += 1
                    else:
                        break
                for n in range(H-i-1):
                    if S[i+n+1][j] == '.':
                        cou += 1
                    else:
                        break
                for n in range(j):
                    if S[i][j-n] == '.':
                        cou += 1
                    else:
                        break
                for n in range(W-j-1):
                    if S[i][j+n+1] == '.':
                        cou += 1
                    else:
                        break
            if cou > M:
                M = cou

    print(M+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def lightCnt(i, j , obst, max):
    min = -1
    k = 0
    for k in range(len(obst[i])):
        if obst[i][k] < j:
            min = obst[i][k]
        else:
            max = obst[i][k]
    return (max - min -1)

def main():
    H,W = map(int,input().split())
    S = [list(input()) for _ in range(H)]
    rowObst = [[] for _ in range(H)]
    columnObst = [[] for _ in range(W)]
    max = 0

    for i in range(H):
        for j in range(W):
            if S[i][j] == 35:
                rowObst[i].append(j)
                columnObst[j].append(i)

    for i in range(H):
        for j in range(W):
            if S[i][j] == 46:
                tmp = lightCnt(i, j, rowObst, W) + lightCnt(j, i, columnObst, H) - 1
                if tmp > max:
                    max = tmp

    print(max)



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

H, W = map(int, input().split())
S = ["#" * (W + 2)] + ["#" + input() + "#" for _ in range(H)] + ["#" * (W + 2)]

LEFT = [[0 for j in range(W+2)] for i in range(H+2)]
RIGHT = [[0 for j in range(W+2)] for i in range(H+2)]
UP = [[0 for j in range(W+2)] for i in range(H+2)]
DOWN = [[0 for j in range(W+2)] for i in range(H+2)]

for h in range(H+2):
  for w in range(W+2):
    if S[h][w] == ".":
      LEFT[h][w] = LEFT[h][w-1] + 1
    else:
      LEFT[h][w] = 0

for h in range(H+2):
  for w in range(W+2)[::-1]:
    if S[h][w] == ".":
      RIGHT[h][w] = RIGHT[h][w+1] + 1
    else:
      RIGHT[h][w] = 0

for h in range(H+2)[::-1]:
  for w in range(W+2):
    if S[h][w] == ".":
      UP[h][w] = UP[h+1][w] + 1
    else:
      UP[h][w] = 0

for h in range(H+2):
  for w in range(W+2):
    if S[h][w] == ".":
      DOWN[h][w] = DOWN[h-1][w] + 1
    else:
      DOWN[h][w] = 0

ans = -1

for h in range(H+2):
  for w in range(W+2):
    if h == 2 and w == 2:
      print(h, w)
    value = RIGHT[h][w] + LEFT[h][w] + UP[h][w] + DOWN[h][w] - 3
    ans = max(ans, value)

print(ans)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]
rev_graph = [[graph[j][i] for j in range(H - 1, -1, -1)] for i in range(W)]
# print(graph)
# print("---")
# print(rev_graph)
ans = 0
for i in range(H):
    line = graph[i]
    for j in range(W):
        if graph[i][j] == ".":
            n = 0
            left_pos = line[:j][::-1]
            if "#" in left_pos:
                left = left_pos.index("#")
            else:
                left = j
            right_pos = line[j + 1:]
            if "#" in right_pos:
                right = right_pos.index("#")
            else:
                right = W - j - 1
            n = left + right

            line_ = rev_graph[j]
            j = H - i - 1
            left_pos = line_[:j][::-1]
            if "#" in left_pos:
                left = left_pos.index("#")
            else:
                left = j
            right_pos = line_[j + 1:]
            if "#" in right_pos:
                right = right_pos.index("#")
            else:
                right = H - j
            n += left + right
            ans = max(ans, n)
print(ans)

Submission status: Wrong Answer

Solution code:
H, W=map(int, input().split())
S=[]
S.append("".join(["#" for _ in range(W+2)]))
S.extend(["#"+input()+"#" for _ in range(H)])
S.append("".join(["#" for _ in range(W+2)]))
co1=[[0 for _ in range(W+2)] for _ in range(H+2)]
co2=[[0 for _ in range(W+2)] for _ in range(H+2)]
print(S)

for i in range(1, H+2):
    ppos=0
    for j in range(W+2):
        if S[i][j]=="#":
            if S[i][j-1]==".":
                for k in range(ppos, j):
                    co1[i][k]=j-ppos
            ppos=j+1

for j in range(1, W+2):
    ppos=0
    for i in range(H+2):
        if S[i][j]=="#":
            if S[i-1][j]==".":
                for k in range(ppos, i):
                    co2[k][j]=i-ppos
            ppos=i+1

ans=0
for i in range(1, H+2):
    for j in range(1, W+2):
        ans=max(ans, co1[i][j]+co2[i][j]-1)
print(ans)

Submission status: Wrong Answer

Solution code:
H,W=map(int,input().split())
S = []
for _ in range(H):
  S.append(list(input()))
  
Left=[[0]*2100]*2100
for i in range(H):
  cur=0
  for j in range(W):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Left[i][j]=cur
      
Right=[[0]*2100]*2100
for i in range(H):
  cur=0
  for j in range(W-1,-1,-1):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Right[i][j]=cur
      
Up=[[0]*2100]*2100
for j in range(W):
  cur=0
  for i in range(H):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Up[i][j]=cur
      
Down=[[0]*2100]*2100
for j in range(W):
  cur=0
  for i in range(H-1,-1,-1):
    if S[i][j]=='#':
      cur=0
    else:
      cur+=1
      Down[i][j]=cur
      
res=0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    else:
      res=max(res,Left[i][j]+Right[i][j]+Up[i][j]+Down[i][j]-3)
print(res)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np

H, W = list(map(int, input().split()))
s_table = []
total_table = []
c_table = []
for _ in range(H):
    s = list(input())
    s_num = [0 if ch == "#" else 1 for ch in s]
    s_table.append(s_num)

s_table = np.pad(s_table, 1, "constant")

l_table = np.zeros((H + 2, W + 2))
r_table = np.zeros((H + 2, W + 2))
u_table = np.zeros((H + 2, W + 2))
b_table = np.zeros((H + 2, W + 2))

for i in range(1, W):
    l_table[:, i] = (l_table[:, i - 1] + 1) * s_table[:, i]
    r_table[:, -i - 1] = (r_table[:, -i] + 1) * s_table[:, -i - 1]


for i in range(1, H):
    u_table[i] = (u_table[i - 1] + 1) * s_table[i]
    b_table[-i - 1] = (b_table[-i] + 1) * s_table[-i - 1]

total_table = l_table + r_table + u_table + b_table
ans = np.max(total_table)

if H <= 1:
    ans += 2
if W <= 1:
    ans += 2
ans = int(ans) - 3

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np

H, W = list(map(int, input().split()))
s_table = []
total_table = []
c_table = []
for _ in range(H):
    s = list(input())
    s_table.append(s)
    total_table.append([0] * W)
    c_table.append([dict(l=0, r=0, u=0, b=0)] * W)

for i in range(H):
    for j in range(W):
        if j != 0:
            # 左側の数を数える
            if s_table[i][j - 1] == "." and s_table[i][j] == ".":
                c_table[i][j]["l"] = c_table[i][j - 1]["l"] + 1
                total_table[i][j] += c_table[i][j]["l"]
        if j != 0:
            if s_table[i][W - j] == "." and s_table[i][W - j - 1] == ".":
                c_table[i][W - j - 1]["r"] = c_table[i][W - j]["r"] + 1
                total_table[i][W - j - 1] += c_table[i][W - j - 1]["r"]
        if i != 0:
            # 上側の数を数える
            if s_table[i - 1][j] == "." and s_table[i][j] == ".":
                c_table[i][j]["u"] = c_table[i - 1][j]["u"] + 1
                total_table[i][j] += c_table[i][j]["u"]
        if i != 0:
            if s_table[H - i][j] == "." and s_table[H - i - 1][j] == ".":
                c_table[H - i - 1][j]["b"] = c_table[H - i][j]["b"] + 1
                total_table[H - i - 1][j] += c_table[H - i - 1][j]["b"]
ans = np.array(total_table).max()
ans = ans if ans == 0 else ans + 1

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np

H, W = list(map(int, input().split()))
s_table = []
total_table = []
c_table = []
for _ in range(H):
    s = list(input())
    s_table.append(s)
    total_table.append([0] * W)
    c_table.append([dict(l=0, r=0, u=0, b=0)] * W)

for i in range(H):
    for j in range(W):
        if j != 0:
            # 左側の数を数える
            if s_table[i][j - 1] == "." and s_table[i][j] == ".":
                c_table[i][j]["l"] = c_table[i][j - 1]["l"] + 1
                total_table[i][j] += c_table[i][j]["l"]
        if j != 0:
            if s_table[i][W - j] == "." and s_table[i][W - j - 1] == ".":
                c_table[i][W - j - 1]["r"] = c_table[i][W - j]["r"] + 1
                total_table[i][W - j - 1] += c_table[i][W - j - 1]["r"]
        if i != 0:
            # 上側の数を数える
            if s_table[i - 1][j] == "." and s_table[i][j] == ".":
                c_table[i][j]["u"] = c_table[i - 1][j]["u"] + 1
                total_table[i][j] += c_table[i][j]["u"]
        if i != 0:
            if s_table[H - i][j] == "." and s_table[H - i - 1][j] == ".":
                c_table[H - i - 1][j]["b"] = c_table[H - i][j]["b"] + 1
                total_table[H - i - 1][j] += c_table[H - i - 1][j]["b"]
ans = np.array(total_table).max() + 1

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import numpy as np

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

for _ in range(H):
    s = list(input())
    s_table.append(s)

c_table = [[dict(l=0, r=0, u=0, b=0)] * W for _ in range(H)]
total_table = [[0] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if j != 0:
            # 左側の数を数える
            if s_table[i][j - 1] == "." and s_table[i][j] == ".":
                c_table[i][j]["l"] = c_table[i][j - 1]["l"] + 1
                total_table[i][j] += c_table[i][j]["l"]
        if j != 0:
            if s_table[i][W - j] == "." and s_table[i][W - j - 1] == ".":
                c_table[i][W - j - 1]["r"] = c_table[i][W - j]["r"] + 1
                total_table[i][W - j - 1] += c_table[i][W - j - 1]["r"]
        if i != 0:
            # 上側の数を数える
            if s_table[i - 1][j] == "." and s_table[i][j] == ".":
                c_table[i][j]["u"] = c_table[i - 1][j]["u"] + 1
                total_table[i][j] += c_table[i][j]["u"]
        if i != 0:
            if s_table[H - i][j] == "." and s_table[H - i - 1][j] == ".":
                c_table[H - i - 1][j]["b"] = c_table[H - i][j]["b"] + 1
                total_table[H - i - 1][j] += c_table[H - i - 1][j]["b"]
ans = np.array(total_table).max() + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

print(grid)


X,Y = np.where(grid == b'#')

A = np.ones((H,W), np.int32)
B = np.ones((H,W), np.int32)

A[X,Y] = 0
B[X,Y] = 0

for w in range(W-1):
	A[:,w+1] += A[:,w] * (A[:,w+1] != 0)
for w in range(W-2,-1,-1):
	A[:,w] = np.maximum(A[:,w], A[:,w+1]) * (A[:,w] != 0)


for h in range(H-1):
	B[h+1,:] += B[h,:] * (B[h+1,:] != 0)
for h in range(H-2,-1,-1):
	B[h,:] = np.maximum(B[h,:], B[h+1,:]) * (B[h,:] != 0)

C = A+B

print(np.max(C)-1)

Submission status: Wrong Answer

Solution code:
H,W =map(int,input().split())
S=[[] for _ in range(H+2)]
for i in range(H):
    S[i+1]="#"+input()+"#"
S[0]="#"*(W+1)
S[-1]="#"*(W+1)

hori=[[0]*(W+2) for _ in range(H+2)]
ver=[[0]*(W+2) for _ in range(H+2)]


def count(i,j):
    if hori[i][j-1]==0:
        count=0
        for k in range(W):
            if S[i][j+k]==".":
                count+=1
            else:
                break
        hori[i][j]=count
    else:
        hori[i][j]=hori[i][j-1]
        
    if ver[i-1][j]==0:
        count=0
        for k in range(W):
            if S[i+k][j]==".":
                count+=1
            else:
                break
        ver[i][j]=count
    else:
        ver[i][j]=ver[i-1][j]
    return hori[i][j]+ver[i][j]-1
    
ans=0
for i in range(1,H+1):
    for j in range(1,W+1):
        if S[i][j]==".":
            ans=max(ans,count(i,j))
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

tate=[[0]*W for _ in range(H)]
yoko=[[0]*W for _ in range(H)]

for i in range(W):
  j=0
  while j<H:
    x=0
    while j+x<H and S[j+x][i]=='.':
      x+=1
    if x==0:
      tate[j][i]=0
      j+=1
    else:
      for t in range(x):
        tate[j+t][i]=x
      j+=x

for i in range(H):
  j=0
  while j<W:
    x=0
    while j+x<W and S[i][j+x]=='.':
      x+=1
    if x==0:
      yoko[i][j]=0
      j+=1
    else:
      for t in range(x):
        yoko[i][j+t]=x
      j+=x
      
print(np.max(np.array(tate)+np.array(yoko)))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
import sys
input = sys.stdin.readline
def sc(s):
    b = None
    nc = 0
    kk = [0]*len(s)
    for i, c in enumerate(s):
        if c == ".":
            if c == b:
                nc += 1
            else:
                si = i
        else:
            if b == ".":
                for j in range(si, i):
                    kk[j] = i - si
            nc = 0
        b = c
    return kk
d = []
d2 = []
d3 = [[0]*H for _ in range(W)]
for h in range(H):
    s = input().strip() + "#"
    d.append(s)
    d2.append(sc(s))

r = 0
for i in range(H):
    for j in range(W):
        r = max(r, d2[i][j] + d3[j][i]-1)
print(r)

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
def sc(s):
    b = None
    nc = 0
    kk = [0]*len(s)
    for i, c in enumerate(s):
        if c == ".":
            if c == b:
                nc += 1
            else:
                si = i
        else:
            if b == ".":
                for j in range(si, i):
                    kk[j] = i - si
        b = c
    return kk
d = []
d2 = []
d3 = []
for h in range(H):
    s = input().strip() + "#"
    d.append(s)
    d2.append(sc(s))

print(d2)
for i in range(W):
    s = ""
    for j in range(H):
        s += d[j][i]
    s += "#"
    d3.append(sc(s))
r = 0
for i in range(H):
    for j in range(W):
        r = max(r, d2[i][j] + d3[j][i]-1)
print(r)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  s=[S() for _ in range(h)]

  L=[[0 for _ in range(w)]for __ in range(h)]
  R=[[0 for _ in range(w)]for __ in range(h)]
  D=[[0 for _ in range(w)]for __ in range(h)]
  U=[[0 for _ in range(w)]for __ in range(h)]

  for i in range(h):
    for j in range(w):
      if s[i][j]=='#':
        L[i][j]=0
        U[i][j]=0
        continue
      else:
        if i==0:
          U[i][j]=1
  
        if j==0:
          L[i][j]=1
  
        if i!=0 and j!=0:
          L[i][j]=L[i][j-1]+1
          U[i][j]=U[i-1][j]+1

  for i in range(h)[::-1]:
    for j in range(w)[::-1]:
      if s[i][j]=='#':
        R[i][j]=0
        D[i][j]=0
        continue
      else:
        if i==h-1:
          D[i][j]=1
  
        if j==w-1:
          R[i][j]=1
  
        if i!=h-1 and j!=w-1:
          R[i][j]=R[i][j+1]+1
          D[i][j]=D[i+1][j]+1

  ans=0
  for i in range(h):
    for j in range(w):
      ans=max(ans,R[i][j]+L[i][j]+U[i][j]+D[i][j]-3)

  return ans

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  s=[S() for _ in range(h)]

  L=[[0 for _ in range(w)]for __ in range(h)]
  R=[[0 for _ in range(w)]for __ in range(h)]
  D=[[0 for _ in range(w)]for __ in range(h)]
  U=[[0 for _ in range(w)]for __ in range(h)]

  for i in range(h):
    for j in range(w):
      if s[i][j]=='#':
        L[i][j]=0
        U[i][j]=0
        continue

      if i==0:
        U[i][j]=1

      elif j==0:
        L[i][j]=1

      elif i!=0 and j!=0:
        L[i][j]=L[i][j-1]+1
        U[i][j]=U[i-1][j]+1

  for i in range(h)[::-1]:
    for j in range(w)[::-1]:
      if s[i][j]=='#':
        R[i][j]=0
        D[i][j]=0
        continue

      if i==h-1:
        D[i][j]=1

      elif j==w-1:
        R[i][j]=1

      elif i!=h-1 and j!=w-1:
        R[i][j]=R[i][j+1]+1
        D[i][j]=D[i+1][j]+1

  ans=0
  for i in range(h):
    for j in range(w):
      ans=max(ans,R[i][j]+L[i][j]+U[i][j]+D[i][j]-3)

  return ans

# main()
print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  h,w=LI()
  s=[S() for _ in range(h)]

  L=[[0 for _ in range(w)]for __ in range(h)]
  R=[[0 for _ in range(w)]for __ in range(h)]
  D=[[0 for _ in range(w)]for __ in range(h)]
  U=[[0 for _ in range(w)]for __ in range(h)]

  for i in range(h):
    for j in range(w):
      if s[i][j]=='#':
        L[i][j]=0
        U[i][j]=0
        continue

      if i==0:
        U[i][j]=1

      if j==0:
        L[i][j]=1

      if i!=0 and j!=0:
        L[i][j]=L[i][j-1]+1
        U[i][j]=U[i-1][j]+1

  for i in range(h)[::-1]:
    for j in range(w)[::-1]:
      if s[i][j]=='#':
        R[i][j]=0
        D[i][j]=0
        continue

      if i==h-1:
        D[i][j]=1

      if j==w-1:
        R[i][j]=1

      if i!=h-1 and j!=w-1:
        R[i][j]=R[i][j+1]+1
        D[i][j]=D[i+1][j]+1

  ans=0
  for i in range(h):
    for j in range(w):
      ans=max(ans,R[i][j]+L[i][j]+U[i][j]+D[i][j]-3)

  return ans

# main()
print(main())