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
def cal(S, xx):
    S1 = []
    for s in S:
        indexes = [i for i, x in enumerate(s) if x == "#"]
        indexes.append(xx+1)
        
        cnt = 0
        ret = []
        b_index = 0
        for cnt, index in enumerate(indexes):
            if cnt == 0:
                ret.extend( [index-b_index for _ in range(index-b_index)])
            elif cnt == len(indexes):
                ret.extend( [index-b_index-2 for _ in range(index-b_index-1)])
            else :
                ret.extend( [index-b_index-1 for _ in range(index-b_index-1)])
            ret.append(0)
            b_index = index
        ret.pop()
        ret.pop()
        S1.append(ret)
    return np.array(S1)

H, W  = list(map(int, input().split(" ")))

S = []
for i in range(H):
    S.append(list(input()))
    
A = np.array(S)
B = A.T

S1 = cal(A, W)
S2 = cal(B, H)
print(S1)

XX = S1 + S2.T
print(np.max(XX) - 1)

Submission status: Wrong Answer

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

m = []
for _ in range(H * W):
    m.append(([0, H - 1], [0, W - 1]))

for h in range(H):
    s = input()
    for w in range(W):
        if s[w] == "#":
            pos = h * W + w
            m[pos] = ([None, None], [None, None])

            to_w = None if w == 0 else w - 1
            for i in range(h * W, pos):
                m[i][1][1] = to_w

            from_w = None if w == W - 1 else w + 1
            for i in range(pos, (h + 1) * W):
                m[i][1][0] = from_w

            to_h = None if h == 0 else h - 1
            for i in range(h):
                m[(i * W) + w][0][1] = to_h

            from_h = None if h == H - 1 else h + 1
            for i in range(h + 1, H):
                m[(i * W) + w][0][0] = from_h

ans = 0
for h, w in m:
    s = 0
    if h[0] is not None and h[1] is not None:
        s += h[1] - h[0] + 1
    if w[0] is not None and w[1] is not None:
        s += w[1] - w[0] + 1
    s -= 1
    ans = max(s, ans)
print(ans)

Submission status: Wrong Answer

Solution code:
#import numpy as np

input = raw_input
H, W = map(int, input().split(" "))

S = [list(input()) for i in range(H)]
#print("S", S)

#map_yoko = np.zeros((H, W), dtype=int)
map_yoko = [ [0 for __ in range(W)] for _ in range(H)]
map_tate = [ [0 for __ in range(W)]  for _ in range(H)]
#map_tate = np.zeros((H, W), dtype=int)

# yoko
for i in range(H):
    count = 0
    kabe = True
    start = None
    end = None
    for j in range(W):
        if S[i][j] == "#":
            end = j-1
            kabe = True
            
            #print(i, j, start, end, count)
            #if start is not None:
            if count >= 1:
                for k in range(start, end):
                    map_yoko[i][k] = count
            count = 0

        else:
            count += 1
            if kabe:
                kabe = False
                start = j

            if j == W-1:
                end = j
                for k in range(start, end):
                    map_yoko[i][k] = count


# tate
for j in range(W):
    count = 0
    kabe = True
    start = None
    end = None
    for i in range(H):
        if S[i][j] == "#":
            end = i-1
            kabe = True
            
            if count >= 1:
                for k in range(start, end):
                    map_tate[k][j] = count
            count = 0

        else:
            count += 1
            if kabe:
                kabe = False
                start = i

            if i == H-1:
                end = i
                for k in range(start, end):
                    map_tate[k][j] = count

#import numpy as np
#print("yoko\n", np.asarray(map_yoko))
#print("tate\n", np.asarray(map_tate))


out = -1
max_i = -1
max_j = -1
for i in range(H):
    for j in range(W):
        out = max(out, map_yoko[i][j] + map_tate[i][j])

#map_ = map_yoko + map_tate
#out = max(map_) - 1

if H == 1 or W == 1:
    pass
else:
    #out = max(0, out - 1)
    cond1 = max_i >= 1 and S[max_i-1][max_j] == "."
    cond2 = max_i <= H-2 and S[max_i+1][max_j] == "."
    cond3 = max_j >= 1 and S[max_i][max_j-1] == "."
    cond4 = max_j <= W-2 and S[max_i][max_j+1] == "."
    if cond1 or cond2 or cond3 or cond4:
        out -= 1

print(out)

Submission status: Wrong Answer

Solution code:
inp = input()
split_input = inp.split()
h = int(split_input[0])
w = int(split_input[1])
matrix = []
for _ in range(h):
    inp = input()
    # split_input = inp.split()
    row = []
    for st in inp:
        row.append(st)
    matrix.append(row)
max_lamp = 0
for i, row in enumerate(matrix):
    for j, st in enumerate(row):
        # right
        count = 1
        for k in range(j+1, w):
            if row[k] == '#':
                break
            count += 1
        # left
        for k in range(j):
            if row[j - (1+k)] == '#':
                break
            count += 1
        # down
        for k in range(i+1, h):
            if matrix[k][j] == '#':
                break
            count += 1
        # up
        for k in range(i):
            if matrix[i - (k + 1)][j] == '#':
                break
            count += 1
        if max_lamp < count:
            max_lamp = count
print(max_lamp)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
H,W = input().split()
H = int(H)
W = int(W)
S = []

for i in range(H):

    sp = input()
    S.append(sp)

maxi = 0
now = 0

for i in range(H):

    for j in range(W):

        if ( S[i][j] != "#"):

            now = 1

            for k in range(j - 1):
                k = j - 2 - k

                if (S[i][k] == "."):
                    now += 1

                else:
                    break

            for k in range(W - j -1):
                k = j + k + 1

                if (S[i][k] == "."):
                    now += 1

                else:
                    break

            for k in range(i - 1):
                k = i - 2 - k

                if (S[k][j] == "."):
                    now += 1

                else:
                    break

            for k in range(H - i - 1):
                k = i + k + 1

                if (S[k][j] == "."):
                    now += 1

                else:
                    break


            if (maxi < now):
                maxi = now
            

print (maxi)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    h, w = im.inputMultiple()
    s = []
    for _ in range(h):
        s.append(line_to_int(im.inputSingle(dtype=str)))
    # Logic ############################################################################################################
    print(s)
    # Output ###########################################################################################################
    vertical = [[-1] * h for _ in range(w)]
    horizontal = [[-1] * w for _ in range(h)]
    # Vertical
    for x in range(w):
        temp_y = 0
        for y in range(h):
            if s[y][x] == 0:
                if y > temp_y:
                    vertical[x][temp_y:y] = [y - temp_y] * (y - temp_y)
                temp_y = y + 1
    # Horizontal
    for y in range(h):
        temp_x = 0
        for x in range(w):
            if s[y][x] == 0:
                if x > temp_x:
                    horizontal[y][temp_x:x] = [x - temp_x] * (x - temp_x)
                temp_x = x + 1
    
    maxim = 0
    for y in range(h):
        for x in range(w):
            if vertical[x][y] + horizontal[y][x] > maxim:
                maxim = vertical[x][y] + horizontal[y][x]
    print(maxim)
    # Return ###########################################################################################################
    return

def line_to_int(line):
    line_int = []
    for idx in range(len(line)):
        if line[idx] == '#':
            line_int.append(0)
        else:
            line_int.append(1)
    return line_int

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
s=[input() for i in range(h)]
c=[[[0,0] for i in range(w)] for i in range(h)]
t=0
for H in range(h):
    for W in range(w):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                c[H][W-l][0]=t
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        c[H][-l][0]=t
    t=0
ans=0
for W in range(w):
    for H in range(h):
        if(s[H][W]=="#"):
            for l in range(1,t+1):
                ans=max(c[-l][W][0]+t,ans)
            t=0
        else:
            t+=1
    for l in range(1,t+1):
        ans=max(c[-l][W][0]+t,ans)
    t=0
print(max(ans-1,0))

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
  HW = list(map(int,input().split(" ")))
  
  H = HW[0]
  W = HW[1]
  
  List = [""for i in range(H)]
  
  for a in range(H):
    List[a]= input()
  
  max = 0
  for A in range(H):
    for B in range(W):
      i = A-4 if A-4 > 0 else 0
      j = A+4 if A+4 < H else H-1
      k = B-4 if B-4 > 0 else 0
      l = B+4 if B+4 < W else W-1
      Count = 0
      for AA in range(i,j):
        if List[AA][B] == ".":
          Count += 1
      Count += List[A][k:l].count('.')

      if max < Count:
        max = Count
        
  print(max)

Submission status: Wrong Answer

Solution code:
H,W = map(int, input().split())
a = []
for_at = []
at = []
for i in range(H):
  new_a = str(input())
  for_at.append(list(new_a))
  a.append(new_a)

for i in range(W):
  ai = ''
  for j in range(H):
    ai = ai+for_at[j][i]
  at.append(ai)
tate=0
yoko=0
max_len = '.'*W
max_j = -1
for i in range(W):
  max_len = '.'*(W-i)
  for j in range(H):
    if max_len in a[j]:
      max_j = j
      tate=W-i
      break
  if max_j != -1:
    break


max_len = '.'*W
max_j = -1
for i in range(W):
  max_len = '.'*(W-i)
  for j in range(H):
    if max_len in at[j]:
      max_j = j
      yoko=W-i
      break
  if max_j != -1:
    break
print(tate+yoko-1)

Submission status: Wrong Answer

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

dL = [[0 for _ in range(W)] for _ in range(H)]

for h in range(H):
    ml = -1
    for w in range(W):
        if S[h][w]=='.':
            dL[h][w] += w-ml
        else:
            ml=w
            
    mr = W
    for w in range(W-1, -1, -1):
        if S[h][w]=='.':
            dL[h][w] += mr-w
        else:
            mr=w

for w in range(W):
    mu = -1
    for h in range(H):
        if S[h][w]=='.':
            dL[h][w] += h-mu
        else:
            mu=h
            
    md = H
    for h in range(H-1, -1, -1):
        if S[h][w]=='.':
            dL[h][w] += md-h
        else:
            mr=h

max_lite = -1
for h in range(H):
    max_lite = max(max_lite, max(dL[h])-3)

print(max_lite)

Submission status: Wrong Answer

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

T = [[-1]*W]*H    

counter = 0
flag = 0
for h in range(H):
    for w in range(W):
        if w == 0 and S[h][w] == '#':
            pass
        elif  S[h][w-1] == '#' and  S[h][w] == '.':
            flag = w
            counter += 1
        elif w == W and S[h][w] == '.':
            counter += 1
            for i in range(flag,w):
                T[h][i] += counter
                counter = 0
        elif S[h][w] == '.':
            counter += 1
        else:
            for i in range(flag,w):
                T[h][i] += counter
                counter = 0
    flag = 0

counter = 0
flag = 0
for w in range(W):
    for h in range(H):
        if h == 0 and S[h][w] == '#':
            pass
        elif  S[h-1][w] == '#' and  S[h][w] == '.':
            flag = h
            counter += 1
        elif h == H and S[h][w] == '.':
            counter += 1
            for i in range(flag,h):
                T[i][w] += counter
                counter = 0    
        elif S[h][w] == '.':
            counter += 1
        else:
            for i in range(flag,h):
                T[i][w] += counter
                counter = 0    
print(T)
ans = 0
for w in range(W):
    for h in range(H):
        ans = max(ans, T[h][w])

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

def solve():
    H, W = [int(_) for _ in raw_input().split()]
    S = []
    for i in range(H):
        Si = [_ for _ in raw_input()]
        S.append(Si)
    rowm = [None] * H
    for i in range(H):
        start = -1
        end = 0
        save = (start, end, i)
        for j in range(W):
            if S[i][j] == '.':
                end = j
            else:
                start = j
                end = j
            if end - start > save[1] - save[0]:
                save = (start, end, i)
        rowm[i] = save
    colm = [None] * W
    for j in range(W):
        start = -1
        end = 0
        save = (start, end, j)
        for i in range(H):
            if S[i][j] == '.':
                end = i
            else:
                start = i
                end = i
            if end - start > save[1] - save[0]:
                save = (start, end, j)
        colm[j] = save
    rowm.sort(key = lambda x: x[1] - x[0], reverse = True)
    colm.sort(key = lambda x: x[1] - x[0], reverse = True)
    # priority queue
    queue = deque()
    queue.append((0,0))
    ret = 0
    while len(queue) > 0:
        def max_ans(i,j):
            s1, e1, row = rowm[i]
            s2, e2, col = colm[j]
            return e1 - s1 + e2 - s2 - 1

        i, j = queue.popleft()
        s1, e1, row = rowm[i]
        s2, e2, col = colm[j]
        tmp = max_ans(i,j)
        if tmp == 0:
            ret = tmp
            break
        if row >= s2 and row <=e2 and col >= s1 and col <= e1:
            ret = tmp
            break
        if i + 1 < H and j + 1 < W:
            if max_ans(i + 1, j) >= max_ans(i, j + 1):
                queue.append((i+1, j))
                queue.append((i, j+1))
            else:
                queue.append((i, j+1))
                queue.append((i+1, j))
        else:
            if i + 1 < H:
                queue.append((i+1, j))
            if j + 1 < W:
                queue.append((i, j+1))
    print ret

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]
X = [[-10**2 for __ in range(W)] for _ in range(H)]
Y = [[-10**2 for __ in range(W)] for _ in range(H)]
last_ys = [-1] * W
for y in range(H):
  last_x = -1
  for x in range(W):
    if S[y][x] == "#":
      for t in range(last_x+1,x):
        X[y][t] = x-1-last_x
      for t in range(last_ys[x]+1,y):
        Y[t][x] = y-1-last_ys[x]
      last_x = x
      last_ys[x] = y
  for t in range(last_x+1,W):
    X[y][t] = W-1-last_x
for x in range(W):
  for t in range(last_ys[x]+1,H):
    Y[t][x] = H-1-last_ys[x]
ans = 0
for y in range(H):
  for x in range(W):
    ans = max(ans, Y[y][x]+X[y][x])
print(ans)

Submission status: Wrong Answer

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

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

Y = [0 for i in range(H)]
X = [0 for i in range(W)]

for i in range(H) :
    S = L[i]
    cnt = 0
    for j in range(W) :
        if S[j] == "." :
            cnt += 1
        else :
            Y[i] = max(Y[i],cnt)
            cnt = 0
    Y[i] = max(Y[i],cnt)

for j in range(W) :
    cnt = 0
    for i in range(H) :
        if L[i][j] == "." :
            cnt += 1
        else :
            X[j] = max(X[j],cnt)
            cnt = 0
    X[j] = max(X[j],cnt)

ans = 0

for i in range(len(Y)) :
    for j in range(len(X)) :
        if L[i][j] == "." :
            calc = max(0,Y[i] + X[j] - 1)
        else :
            calc = max(Y[i], X[j])
        ans = max(ans,calc)
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
h,w = map(int,input().split())
ll = [[] for i in range(w)]
l = []
dpl = [[0]*h for i in range(w)]
dml= [[0]*w for i in range(h)]

for i in range(h):
    tl = input()
    l.append(tl)
    for n,j in enumerate(tl):
        ll[n].append(j)

for n,i in enumerate(l):
    s = 0
    t = 0
    for m,j, in enumerate(i):
        if s == 0 and j ==".":
            s+=1
            t = m
        elif j == ".":
            s+=1
        else:
            for r in range(t,m):
                dml[n][r] = s
            s = 0
    if i[-1] == ".":
        for r in range(t,w):
            dml[n][r] = s
for n,i in enumerate(ll):
    s = 0
    t = 0
    for m,j, in enumerate(i):
        if s == 0 and j ==".":
            s+=1
            t = m
        elif j == ".":
            s+=1
        else:
            for r in range(t,m):
                dpl[n][r] = s
            s = 0
    if i[-1] == ".":
        for r in range(t,h):
            dpl[n][r] = s


a = -1
# for i in dml:
#     print(i)
# print(0)
# for i in dpl:
#     print(i)
for n,i in enumerate(dml):
    for k,j in enumerate(i):
        # print(j,dpl[k][n])
        a = max(a,j+dpl[k][n])
print(a-1)

Submission status: Wrong Answer

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

li =[["#"] * w] +  [list(input().replace(".","1")) for i in range(h)] + [["#"] * w]

for i in range(1,h):
    for j in range(1,w):
        if li[i][j] == "#":
            continue
        
print(li)

Submission status: Wrong Answer

Solution code:
H, W = [int(x) for x in input().split(' ')]
squares = []
for _ in range(H):
  squares.append(input().strip())

tr_squares = list([''.join(x) for x in zip(*squares)])

import numpy as np

def count_seq(s):
  w = [len(x) for x in s.split('#')]
  return max(w)

def find_max_seq(square):
  seq = [count_seq(x) for x in square]
  return max(seq)

print(find_max_seq(squares) + find_max_seq(tr_squares) - 1)

Submission status: Wrong Answer

Solution code:
L = input()
print(3**len(L)-2*L.count('0'))

Submission status: Wrong Answer

Solution code:
H, W = map(int, input().split())
S = []
for i in range(H):
    s = input()
    a = []
    for j in range(W):
        if s[j] == '.':
            a.append(1)
        else:
            a.append(0)
    S.append(a)

ST = [list(s) for s in zip(*S)]

wmap = [[0 for i in range(W)] for j in range(H)]
hmap = [[0 for i in range(H)] for j in range(W)]


for h in range(H):
    c = 0
    for w in range(W):
        if S[h][w] == 0:
            if c > 0:
                wmap[h][w-c:w] = [c for _ in range(c)]
            c = 0
        else:
            c += 1

    if c > 0:
        wmap[h][w-c+1:] = [c for _ in range(c)]

for w in range(W):
    c = 0
    for h in range(H):
        if ST[w][h] == 0:
            if c > 0:
                hmap[w][h-c+1:h] = [c for _ in range(c)]
            c = 0
        else:
            c += 1

    if c > 0:
        hmap[w][h-c+1:] = [c for _ in range(c)]



max_s = 1
hmap = [list(h) for h in zip(*hmap)]

for w in range(W):
    for h in range(H):
        if S[h][w] == 0:
            continue
        max_s = max(max_s, hmap[h][w] + wmap[h][w] - S[h][w])

print(max_s)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np
H, W = map(int, input().split())

grid= []
for i in range(H):
    grid.append(list(input()))
grid = np.array(grid)
#print("g ", grid)

out = 0
for i in range(W):
    for j in range(H):
        # Search for grid[j][i].
        if grid[j][i] == ".":
            h = grid[:,i]
            w = grid[j,:]
            
            # count up process...

print(out)

Submission status: Wrong Answer

Solution code:
#import numpy as np

input = raw_input
H, W = map(int, input().split(" "))

S = [list(input()) for i in range(H)]
#print("S", S)

#map_yoko = np.zeros((H, W), dtype=int)
map_yoko = [ [0]*W for _ in range(H)]
map_tate = [ [0]*W for _ in range(H)]
#map_tate = np.zeros((H, W), dtype=int)

# yoko
for i in range(H):
    count = 0
    kabe = True
    start = None
    end = None
    for j in range(W):
        if S[i][j] == "#":
            end = j-1
            kabe = True
            
            #print(i, j, start, end, count)
            #if start is not None:
            if count >= 1:
                for k in range(start, end):
                    map_yoko[i][k] = count
            count = 0

        else:
            count += 1
            if kabe:
                kabe = False
                start = j

            if j == W-1:
                end = j
                for k in range(start, end):
                    map_yoko[i][k] = count


# tate
for j in range(W):
    count = 0
    kabe = True
    start = None
    end = None
    for i in range(H):
        if S[i][j] == "#":
            end = i-1
            kabe = True
            
            if count >= 1:
                for k in range(start, end):
                    map_tate[k][j] = count
            count = 0

        else:
            count += 1
            if kabe:
                kabe = False
                start = i

            if i == H-1:
                end = i
                for k in range(start, end):
                    map_tate[k][j] = count

#import numpy as np
#print("yoko\n", np.asarray(map_yoko))
#print("tate\n", np.asarray(map_tate))


out = -1
max_i = -1
max_j = -1
for i in range(H):
    for j in range(W):
        out = max(out, map_yoko[i][j] + map_tate[i][j])

#map_ = map_yoko + map_tate
#out = max(map_) - 1

if H == 1 or W == 1:
    pass
else:
    #out = max(0, out - 1)
    cond1 = max_i >= 1 and S[max_i-1][max_j] == "."
    cond2 = max_i <= H-2 and S[max_i+1][max_j] == "."
    cond3 = max_j >= 1 and S[max_i][max_j-1] == "."
    cond4 = max_j <= W-2 and S[max_i][max_j+1] == "."
    if cond1 or cond2 or cond3 or cond4:
        out -= 1

print(out)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = []
for i in range(h):
    s.append(list(input()))
    
def dfs(i, j):
    num = 1
    n = 1
    while i + n < h and s[i+n][j] != '#':
        n += 1
        num += 1
    n = 1
    while 0 <= i - n and s[i-n][j] != '#':
        n += 1
        num += 1
    n = 1
    while j + n < w and s[i][j+n] != '#':
        n += 1
        num += 1
    n = 1
    while 0 <= j - n and s[i][j-n] != '#':
        n += 1
        num += 1
    return num

max_ = 0
for i in range(h):
    for j in range(w):  
        if s[i][j] != '#':
            ans = dfs(i, j)
            if ans > max_:
                max_ = ans

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


R, C = map(int, input().split())
F = []
R_light = np.zeros((R, C), np.int)
C_light = np.zeros((R, C), np.int)
count_row_dot = [0] * C
row_above = [0] * C
one = np.ones((max(R, C)), np.int)


for i in range(R):
    s = input()
    F.append(s)
    count_col_dot = 0
    j = 0
    col_left = 0
    while j < C:
        if s[j] == ".":
            count_col_dot += 1
            count_row_dot[j] += 1
            j += 1
        else:
            R_light[i,col_left:j] = count_col_dot * one[col_left:j]
            count_col_dot = 0

            if i != 0:
                C_light[row_above[j]:i, j] = one[row_above[j]:i] * count_row_dot[j]
            row_above[j] = i+1
            j += 1

    if s[-1] == ".":
        R_light[i, C-count_col_dot:] = count_col_dot * one[C-count_col_dot: C]

for j in range(C):
    if s[j] == ".":
        C_light[row_above[j]:, j] = count_row_dot[j] * one[row_above[j]:R]



F = R_light + C_light
print(np.max(F) - 1)

Submission status: Wrong Answer

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

field = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
    field[i] = str(input());

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

for i in range(H):
    for j in range(W):
        if field[i][j] == ".":
            ii = i
            jj = j
            while (ii < H and field[ii][jj] == "."):
                L[i][j] += 1
                ii += 1
            ii = i
            jj = j
            while (ii >= 0 and field[ii - 1][jj] == "."):
                L[i][j] += 1
                ii -= 1
            ii = i
            jj = j
            while (jj < W and field[ii][jj] == "."):
                L[i][j] += 1
                jj += 1
            ii = i
            jj = j
            while (jj >= 0 and field[ii][jj] == "."):
                L[i][j] += 1
                jj -= 1


ans = max(L)
ans = max(ans)

print(ans)