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:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""


H, W = list(map(int, input().split()))
# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
A = [""]*H 
#INF = np.Inf
INF = 2000

#D = np.zeros((H, W))
D = np.zeros((H+1, W+1))
for h in range(H):
    A[h] = input()
    for w in range(W):
        if A[h][w] == '.':
            D[h][w] = 1           

def main(): 
    G = np.zeros((H+1, W+1))
    T = np.zeros((H+1, W+1))
    Y = np.zeros((H+1, W+1)) 
    
    
    for h in range(H):
        cnt = 0
        for w in range(W):
            if D[h][w] == 0:
                cnt = 0
                continue
            else:
                Y[h][w] += cnt
                cnt+=1    
    W_r = reversed(range(W))
    for h in range(H):
        for w in W_r:
            if D[h][w] == 0:
               continue
            else:
               Y[h][w] = max(Y[h][w], Y[h][w+1])                           
            
    for w in range(W):
        cnt = 0
        for h in range(H):
            if D[h][w] == 0:
                cnt = 0
                continue
            else:
                T[h][w] += cnt
                cnt+=1
    H_r = reversed(range(H))
    for w in range(W):
        for h in H_r:
            if D[h][w] == 0:
                continue
            else:
                T[h][w] = max(T[h][w], T[h+1][w])
            
    G = D+Y+T
    res = np.amax(G)
    print(int(res))
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
temp = list()
inp = [list(input()) for h in range(h)]
c = [[row, col] for col in range(w) for row in range(h)]
for row, col in c:
  if(inp[row][col] == "."):
    d = list()
    for row_down in range(row,h-1):
      if inp[row_down][col] == ".":
        d.append(inp[row_down][col])
      else:
        break;
    for row_up in range(row ,0,-1):
      if inp[row_up-1][col] == ".":
        d.append(inp[row_up-1][col])
      else:
        break;
    for row_left in range(col,w):
      if inp[row][row_left] == ".":
        d.append(inp[row][row_left])
      else:
        break;
    for row_right in range(col ,0,-1):
      if inp[row][row_right-1] == ".":
        d.append(inp[row][row_right-1])
      else:
        break;
    temp.append(d.count("."))
print(max(temp))

Submission status: Wrong Answer

Solution code:
h,w=map(int,input().split())
temp = list()
flat = list()
inp = [list(input()) for h in range(h)]
c = [[row, col] for col in range(w) for row in range(h)]
for row, col in c:
  if(inp[row][col] == "."):
    d = list()
    for row_down in range(row,h-1):
      if inp[row_down][col] == ".":
        d.append(inp[row_down][col])
      else:
        break;
    for row_up in range(row ,0,-1):
      if inp[row_up-1][col] == ".":
        d.append(inp[row_up-1][col])
      else:
        break;
    for row_left in range(col,w):
      if inp[row][row_left] == ".":
        d.append(inp[row][row_left])
      else:
        break;
    for row_right in range(col ,0,-1):
      if inp[row][row_right-1] == ".":
        d.append(inp[row][row_right-1])
      else:
        break;
    temp.append(d.count("."))
print(max(temp))

Submission status: Wrong Answer

Solution code:
import numpy as np
def solve(h, w, s):
    A = np.zeros((h, w), dtype=np.uint8)
    for i in range(h):
        for j in range(w):
            A[i, j] = 1 if (s[i][j] == "#") else 0
    B = np.zeros(A.shape, dtype=np.uint8)
    for i in range(h):
        x = np.append(np.append(-1, np.where(A[i] == 1)), w)
        for j in range(len(x)-1):
            l, r = x[j] + 1, x[j+1]
            B[i,l:r] = r - l
    C = np.zeros(A.shape, dtype=np.uint8)
    for j in range(w):
        y = np.append(np.append(-1, np.where(A[:,j] == 1)), h)
        for i in range(len(y)-1):
            t, b = y[i] + 1, y[i+1]
            C[t:b,j] = b - t
    return np.max(B+C) - 1

h, w = map(int, input().split())
s = [input() for i in range(h)]
print(solve(h, w, s))

Submission status: Wrong Answer

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

def get(x,y):
    try:
        return S[y][x]
    except:
        return '#'
def uoocount(ax,ay):
    ret = 0
    for x in reversed(range(0, ax)):
        if get(x,ay) == '#':
            break
        ret += 1
    for x in range(ax, W):
        if get(x,ay) == '#':
            break
        ret += 1
    for y in reversed(range(0, ay)):
        if get(ax, y) == '#':
            break
        ret += 1
    for y in range(ay, W):
        if get(ax, y) == '#':
            break
        ret += 1
    return ret - 1

ret = 0
for y in range(H):
    for x in range(W):
        m = uoocount(x, y)
        if ret < m:
            ret = m
print(ret)

Submission status: Wrong Answer

Solution code:
h, w = map(int, input().split())
s = [input() for _ in range(h)]
u = [[0] * (w + 2) for _ in range(h + 2)]
d = [[0] * (w + 2) for _ in range(h + 2)]
l = [[0] * (w + 2) for _ in range(h + 2)]
r = [[0] * (w + 2) for _ in range(h + 2)]

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
H, W = map(int,input().split())
S = np.array([list(input()) for _ in range(H)])
horizon = np.zeros((H, W))
vertical = np.zeros((H, W))

# まず横方向に走査
for i in range(H):
  j = 0
  done = np.zeros((1,W))
  while(j < W):
    # ものが置いてあるマスまで移動（inc分移動）
    l = 0
    while(j + l < W):
      if(S[i][j + l] == "#"):
        j += 1
        break
      l += 1
    inc = l
    # 今いる場所からincまで埋める
    horizon[i][j:j+inc] = inc
    j += inc
    
# お行儀悪いけど同じことを縦方向にします
for j in range(W):
  i = 0
  while(i < H):
    # ものが置いてあるマスまで移動（inc分移動）
    l = 0
    while(i + l < H):
      if(S[i + l][j] == "#"):
        i += 1
        break
      l += 1
    inc = l
    # 今いる場所からincまで埋める
    horizon[i:i+inc, j] += inc
    i += inc
      
total = np.max(horizon) - 1
print(int(total))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

h,w=map(int,input().split())

s_lst=[]
for i in range(h):
    s_lst.append(input())
    
matrix_i=[]
for s in s_lst:
    row=[]
    for l in s.split("#"):
        num=len(l)
        for i in range(0,num):
            if num != 0:
                row.append(num)
        row.append(0)
    row.pop(-1)
    matrix_i.append(row)

s_matrix=[]

for s in s_lst:
    s_matrix.append(list(s))
s_lst=[]
for j in range(w):
    s=""
    for i in range(h):
        s+=s_matrix[i][j]
    s_lst.append(s)
matrix_j=[]
for s in s_lst:
    row=[]
    for l in s.split("#"):
        num=len(l)
        for i in range(0,num):
            if num != 0:
                row.append(num)
        row.append(0)
    row.pop(-1)
    matrix_j.append(row)
    
_i=np.array(matrix_i)
_j=np.array(matrix_j)

print(np.max(_i+_j.T))

Submission status: Wrong Answer

Solution code:
H,W = map(int, input().split())
S = [0]*H
for i in range(H):
    S[i] = str(input())
X = [[0 for i in range(H)] for j in range(W)]
for i in range(H):
    s = list(map(str,S[i]))
    for j in range(W):
        if s[j] == ".":
            X[j][i] = 1
        else:
            X[j][i] = 0
M = 4
for i in range(H):
    for j in range(W):
        k = 0
        dx = -1
        dy = -1
        M1 = 1
        if X[j][i] == 1:
            while j + dx >= 0 and X[j + dx +1][i] == 1:
                M1 += 1
                dx -= 1
            dx = 1
            while j + dx <W and X[j + dx - 1][i] == 1:
                M1 += 1
                dx += 1
                
            while i + dy >= 0 and X[j][i + dy +1] == 1:
                M1 += 1
                dy -= 1
            dy = 1
            while i + dy <H  and X[j][i + dy -1] == 1: 
                M1 += 1
                dy += 1
        if M1 > M:
            M = M1
print(M-1)

Submission status: Wrong Answer

Solution code:

h,w=map(int,input().split())
x1=list(input())
x=[x1]
for u in range(1,h):
	aaa=list(input())
	x.append(aaa)

l=[[0 for _ in range(w)]for _ in range(h)]
r=[[0 for _ in range(w)]for _ in range(h)]
p=[[0 for _ in range(w)]for _ in range(h)]
n=[[0 for _ in range(w)]for _ in range(h)]
count=[[0 for _ in range(w)]for _ in range(h)]
num=0




for i in range(h):
	for j in range(w):
			
		if(j==0):
			l[i][j]=0
		elif(x[i][j]=='#'):
			l[i][j]=0
		elif(x[i][j-1]=='#'):
			l[i][j]=0
		else:
			l[i][j]=l[i][j-1]+1
			count[i][j]+=l[i][j]

		if(i==0):
			p[i][j]=0
		elif (x[i][j]=='#'):
			p[i][j]=0
		elif(x[i-1][j]=='#'):
			p[i][j]=0
		else:
			p[i][j]=p[i-1][j]+1
			count[i][j]+=p[i][j]
		
		if(j==0):
			r[h-1-i][w-1-j]=0
		elif(x[h-1-i][w-j-1]=='#'):
			r[h-1-i][w-1-j]=0
		elif(x[h-1-i][w-j]=='#'):
			r[h-1-i][w-1-j]=0
		else:
			r[h-1-i][w-1-j]=r[h-1-i][w-j]+1
			count[h-1-i][w-1-j]+=r[h-1-i][w-1-j]
		
		if(i==0):
			n[h-1-i][w-1-j]=0
		elif(x[h-1-i][w-j-1]=='#'):
			n[h-1-i][w-1-j]=0
		elif(x[h-i][w-1-j]=='#'):
			n[h-1-i][w-1-j]=0
		else:
			n[h-1-i][w-1-j]=n[h-i][w-1-j]+1
			count[h-1-i][w-1-j]+=n[h-1-i][w-1-j]

'''
for a in range(h):
	for b in range(w):
		num=l[a][b]+r[a][b]+p[a][b]+n[a][b]+1

	
		if(count<num):
			count=num
		else:
			pass
'''		

print(max(max(count))+1)

Submission status: Wrong Answer

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

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

print(a)

left = [w*[-1] for _ in range(h)]
right = [(w+1)*[w] for _ in range(h)]
up = [w*[-1] for _ in range(h)]
down = [w*[h] for _ in range(h+1)]

for i in range(h):
    for j in range(w):
        print(a[i][j])
        up[i][j] = up[i-1][j] if a[i][j] == '.' else i
        left[i][j] = left[i][j-1] if a[i][j] == '.' else j

for i in range(h-1, -1, -1):
    for j in range(w-1, -1, -1):
        down[i][j] = down[i+1][j] if a[i][j] == '.' else i
        right[i][j] = right[i][j+1] if a[i][j] == '.' else j

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == '.':
            tmp = down[i][j] - up[i][j] + right[i][j] - left[i][j] - 3
            ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
H,W=map(int, input().split())
M=[input() for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]

MAX=0
for i in range(H):
  for j in range(W):
    tmp=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3
    #if tmp>MAX:
    #  MAX=tmp

print(MAX)

Submission status: Wrong Answer

Solution code:
H,W=map(int, input().split())
M=[input() for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]

MAX=0

print(MAX)

Submission status: Wrong Answer

Solution code:
import copy
H,W=map(int, input().split())
M=[input() for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=copy.deepcopy(L)
D=copy.deepcopy(L)
U=copy.deepcopy(L)

MAX=0
for i in range(H):
  for j in range(W):
    tmp=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3
    if tmp>MAX:
      MAX=tmp

print(MAX)

Submission status: Wrong Answer

Solution code:
H,W=map(int, input().split())
M=[input() for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]

MAX=0
for i in range(H):
  for j in range(W):
    tmp=L[i][j]+R[i][j]+U[i][j]+D[i][j]-3
    if tmp>MAX:
      MAX=tmp

print(MAX)

Submission status: Wrong Answer

Solution code:
from collections import namedtuple
from itertools import chain

h, w = map(int, input().split(" "))

def neighbours(n):
    return sum(n)

nodes = []
lastUp = [0] * w
lastLeft = 0
for i in range(h):
    lastLeft = 0
    nodes.append([])
    for j,c in enumerate(input()):
        good = 1 if c == '.' else 0
        left = 0
        up = 0
        right = w - j - 1
        down = h - i - 1
        if good == 1:
            if j > 0:
                l = nodes[i][j - 1]
                left = l[1] + l[0]
            if i > 0:
                u = nodes[i - 1][j]
                up = u[2] + u[0]
        else:
            right = 0
            down = 0
            for k in range(lastLeft, j):
                nodes[i][k][3] = j - k - 1
            for k in range(lastUp[j], i):
                nodes[k][j][4] = i - k - 1
            lastLeft = j + 1
            lastUp[j] = i + 1
        nodes[i].append([good, left, up, right, down])
print(1)

Submission status: Wrong Answer

Solution code:
from collections import namedtuple

h, w = map(int, input().split(" "))

class Node():
    __slots__ = ['good', 'left', 'up', 'right', 'down']
    def __init__(self, good, left, up, right, down):
        self.good = good
        self.left = left
        self.up = up
        self.right = right
        self.down = down
    def neighbours(self):
        return self.left + self.up + self.right + self.down + int(self.good)
    def __repr__(self):
        return "{} {} {} {} {}".format(self.good, self.left, self.up, self.right, self.down)

nodes = {}
lastUp = [0 for _ in range(w)]
lastLeft = 0
for i in range(h):
    s = input()
    lastLeft = 0
    for j,c in enumerate(s):
        n = Node(c == '.', 0, 0, w - j - 1, h - i - 1)
        if n.good:

            if j > 0:
                l = nodes[(i, j - 1)]
                n.left = l.left + int(l.good)
            if i > 0:
                u = nodes[(i - 1, j)]
                n.up = u.up + int(u.good)
        else:
            for k in range(lastLeft, j):
                nodes[(i, k)].right = j - k - 1
            for k in range(lastUp[j], i):
                nodes[(k, j)].down = i - k - 1
            lastLeft = (j + 1) % w
            lastUp[j] = i + 1
        nodes[(i, j)] = n

# print('\n'.join(map(str, nodes.items())))
print(max(map(lambda x: x.neighbours(), nodes.values())))

Submission status: Wrong Answer

Solution code:
from collections import namedtuple

h, w = map(int, input().split(" "))

class Node():
    __slots__ = ['good', 'left', 'up', 'right', 'down']
    def __init__(self, good, left, up, right, down):
        self.good = good
        self.left = left
        self.up = up
        self.right = right
        self.down = down
    def neighbours(self):
        return self.left + self.up + self.right + self.down
    def __repr__(self):
        return "{} {} {} {} {}".format(self.good, self.left, self.up, self.right, self.down)

nodes = {}
lastUp = [0 for _ in range(w)]
lastLeft = 0
for i in range(h):
    s = input()
    lastLeft = 0
    for j,c in enumerate(s):
        n = Node(c == '.', 0, 0, w - j - 1, h - i - 1)
        if n.good:

            if j > 0:
                l = nodes[(i, j - 1)]
                n.left = l.left + int(l.good)
            if i > 0:
                u = nodes[(i - 1, j)]
                n.up = u.up + int(u.good)
        else:
            for k in range(lastLeft, j - 1):
                nodes[(i, k)].right = j - k - 1
            for k in range(lastUp[j], i - 1):
                nodes[(k, j)].down = i - k - 1
            lastLeft = (j + 1) % w
            lastUp[j] = i + 1
        nodes[(i, j)] = n

# print(nodes[(1, 1)])
print(max(map(lambda x: x.neighbours(), nodes.values())))

Submission status: Wrong Answer

Solution code:
### 解説読んでから書いたコード ###

h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
# for i in range(h):
#     print(''.join(s[i]))

lighted = [[0 for j in range(w)] for i in range(h)]
left = [[0 for j in range(w)] for i in range(h)]
right = [[0 for j in range(w)] for i in range(h)]
up = [[0 for j in range(w)] for i in range(h)]
down = [[0 for j in range(w)] for i in range(h)]
max_lighted = 0

for i, row in enumerate(s[::-1]):
    for j, cell in enumerate(row[::-1]):
        if cell != '#':
            right[i][j] = 1 if j == 0 else right[i][j-1] + 1
            down[i][j] = 1 if i == 0 else down[i-1][j] + 1
    right[i].reverse()
    down[i].reverse()
right.reverse()
down.reverse()

for i, row in enumerate(s):
    for j, cell in enumerate(row):
        if cell != '#':
            left[i][j] = 1 if j == 0 else left[i][j-1] + 1
            up[i][j] = 1 if i == 0 else up[i-1][j] + 1
            lighted[i][j] = left[i][j] + right[i][j] + up[i][j] + down[i][j] - 3
            max_lighted = max(max_lighted, lighted[i][j])

print(max_lighted)

Submission status: Wrong Answer

Solution code:
import numpy as np

h, w = map(int, input().split())

row = np.zeros((h, w, 2))
col = np.zeros((h, w, 2))

for i in range(h):
    tmp = input()
    count_l = 0
    count_r = 0
    for j in range(w):
        if tmp[j] == ".":
            row[i][j][0] = count_l
            count_l += 1
        else:
            count_l = 0
        if tmp[w-1-j] == ".":
            row[i][w-1-j][1] = count_r
            count_r += 1
        else:
            count_r = 0

for j in range(w):
    count_u = 0
    count_d = 0
    for i in range(h):
        if row[i][j][0] >= 0:
            col[i][j][0] = count_u
            count_u += 1
        else:
            count_u = 0
        if row[h-1-i][j][0] >= 0:
            col[h-1-i][j][1] = count_d
            count_d += 1
        else:
            count_d = 0

row = np.reshape(row, (h * w, 2))
col = np.reshape(col, (h * w, 2))

print(int(max(np.sum(row + col, axis=1)) + 1))

Submission status: Wrong Answer

Solution code:
from subprocess import *
call(('pypy3','-C',"""
n,m = map(int,input().split())
ls = [[x for x in input() + '#'] for i in range(n)] + [['#']*(m+1)]
yokodp = [[0 for x in range(m+1)] for i in range(n+1)]
for i in range(n+1):
    yoko = 0
    for j in range(m+1):
        if ls[i][j] == '#':
            yokodp[i][j] = yoko
            yoko = 0
        else:
            yoko += 1
for i in range(n,-1,-1):
    check = 0
    for j in range(m,-1,-1):
        if yokodp[i][j] != 0:
            check = yokodp[i][j]
        if ls[i][j] == '.':
            yokodp[i][j] = check
tatedp = [[0 for x in range(m+1)] for i in range(n+1)]            
for j in range(m+1):
    tate = 0
    for i in range(n+1):
        if ls[i][j] == '#':
            tatedp[i][j] = tate
            tate = 0
        else:
            tate += 1
for j in range(m,-1,-1):
    for i in range(n,-1,-1):
        if tatedp[i][j] != 0:
            check = tatedp[i][j]
        if ls[i][j] == '.':
            tatedp[i][j] = check
ans = 0
for i in range(n):
    for j in range(m):
        if ls[i][j] == '.':
            ans = max(ans,tatedp[i][j] + yokodp[i][j] - 1)
print(ans)
"""))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
buf = sys.stdin.buffer

H,W = map(int,buf.readline().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.zeros((H+2,W+2),dtype=np.bool)
grid[1:-1,1:] = (np.frombuffer(buf.read(H*(W+1)),dtype='S1') == b'.').reshape((H,W+1))

Submission status: Wrong Answer

Solution code:
import numpy as np

Submission status: Wrong Answer

Solution code:
import numpy as np

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

Submission status: Wrong Answer

Solution code:
"""
data取得比較
"""
import numpy as np

H,W = map(int,input().split())
# 周りに壁を、0,1化、壁を0で持つ
grid = np.array([list(input()) for _ in range(H)])

Submission status: Wrong Answer

Solution code:
"""
data取得比較
"""
import numpy as np

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

Submission status: Wrong Answer

Solution code:
"""
data取得比較
"""
import numpy as np
import sys


def get_data(stream):
    buf = b''
    b = stream.buffer.read(1)
    while b != b'\n':
        buf += b
        b = stream.buffer.read(1)
    H, W = map(int, buf.split())
    c = stream.buffer.read(H * (W + 1))
    arr = np.array(c.split())
    arr = np.frombuffer(arr, dtype='S1').reshape((H, W))
    return H, W, arr


def main():
    H, W, arr = get_data(sys.stdin)
    """
    a = arr == b'.'
    L = np.empty((H, W), dtype='i8')
    R = np.empty((H, W), dtype='i8')
    T = np.empty((H, W), dtype='i8')
    B = np.empty((H, W), dtype='i8')
    T[0] = a[0]
    for i in range(1, H):
        T[i] = (T[i - 1] + 1) * a[i]
    B[-1] = a[-1]
    for i in range(H - 2, -1, -1):
        B[i] = (B[i + 1] + 1) * a[i]
    L[:, 0] = a[:, 0]
    for i in range(1, W):
        L[:, i] = (L[:, i - 1] + 1) * a[:, i]
    R[:, -1] = a[:, -1]
    for i in range(W - 2, -1, -1):
        R[:, i] = (R[:, i + 1] + 1) * a[:, i]

    print((T + B + L + R - 3).max())
    """

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

L = grid.size
a = np.arange(L)

# x軸方向の集計
def F(transpose):
  x = grid
  if transpose:
    x = (x.T).copy()
  x = np.ravel(x) # to 1D array
  
  left_zero = -a # 左の壁のindexの-1倍
  left_zero[x] = 0
  np.minimum.accumulate(left_zero, out=left_zero)
  
  right_zero = a # 逆順ソートした上で左の壁のindex
  right_zero[x[::-1]] = 0
  np.maximum.accumulate(right_zero, out=right_zero)
  
  y = left_zero
  y += L-right_zero[::-1]
  
  return y.reshape(grid.T.shape).T if transpose else y.reshape(grid.shape)
  
answer = (F(False) + F(True)).max()-5
print(answer)

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w=map(int,input().split())
a=np.array([[1 if i=="." else 0 for i in list(input())]for _ in range(h)])
for i in range(2):
    b=np.zeros((h, w), dtype = int)
    c=np.zeros((h, w), dtype = int)
    if i==0:
        for i in range(h):
            b[i]=a[i]*(b[i-1]+1)
            c[-i-1]=a[-i]*(c[-i]+1)
        e,f=b[:],c[:]
    else:
        for i in range (w):
            b[:,i]=(b[:,i-1]+1)*a[:,i]
            c[:,-i-1]=(c[:,-i]+1)*a[:,-i-1]
print(np.max(b+c+e+f)-3)

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w=map(int,input().split())
a=np.array([[1 if i=="." else 0 for i in list(input())]for _ in range(h)])
for i in range(2):
    b=np.zeros((h, w), dtype = int)
    c=np.zeros((h, w), dtype = int)
    if i==0:
        for i in range(h):
            b[i]=a[i]*(b[i-1]+1)
            c[-i-1]=a[-i]*(c[-i]+1)
        e,f=b,c
    else:
        for i in range (w):
            b[:,i]=(b[:,i-1]+1)*a[:,i]
            c[:,-i-1]=(c[:,-i]+1)*a[:,-i-1]
print(np.max(b+c+e+f)-3)

Submission status: Wrong Answer

Solution code:
from itertools import takewhile

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

# 各マスについて、横方向に照らすマスの数と縦方向に照らすマスの数を求める
x = [[0 for _ in range(W)] for _ in range(H)]
y = [[0 for _ in range(W)] for _ in range(H)]

for i, j in ((i, j) for i in range(H) for j in range(W) if S[i][j] == '#'):
    if x[i][j] == 0 and S[i][j]:
        w = len(list(takewhile(lambda k: S[i][k] == '.', range(j, W))))
        for k in range(j, j + w):
            x[i][k] = w
    if y[i][j] == 0:
        h = len(list(takewhile(lambda k: S[k][j] == '.', range(i, H))))
        for l in range(i, i + h):
            y[l][j] = h

ans = max(
    x[i][j] + y[i][j] - 1
    for i in range(H)
    for j in range(W)
)
# 出力
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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
t = np.array(table)
print(t.max())

Submission status: Wrong Answer

Solution code:
import numpy as np
h,w = map(int,input().split())
ar = np.array([list(input()) for _ in range(h)]) == '.'
#print(ar)
l = np.zeros((h,w),dtype=int)
r = np.zeros((h,w),dtype=int)
u = np.zeros((h,w),dtype=int)
d = np.zeros((h,w),dtype=int)
 
for j in range(w):
  l[:,j] = (l[:,j-1]+1)*ar[:,j]
  #print(l)
  r[:,-j-1] = (r[:,-j]+1*ar[:,-j-1])
  #print(r)
for i in range(h):
  u[i] = (u[i-1]+1)*ar[i]
  #print(u)
  d[-i-1] = (d[-i]+1*ar[-i-1])
  #print(d)

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

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]
  m = max(seq)
  if m is 2:
    return 1
  else:
    return m

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