Problem p03014 (python)

Fixed submission:
import numpy as np

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

# x軸正方向の集計
def F():
  x = map.copy()
  for row in range(1,H+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x

# y軸
def G():
  x = map.T.copy()
  for row in range(1,W+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x.T

answer = np.zeros_like(map)
# x軸
answer += F()
# 逆順
map = map[:,::-1]
answer += F()[:,::-1]
map = map[:,::-1]

# y軸
answer += G()
# 逆順
map = map[::-1,:]
answer += G()[::-1,:]

answer = np.max(answer) - 3
print(answer)

Buggy submission (verdict: Runtime Error):
def convert(L):
    H=len(L)
    W=len(L[0])
    dp = [[0 for _ in range(W)] for _ in range(H)]
    #dp = np.zeros((L.shape[0],L.shape[1]), dtype='int')
    for i in range(H):
        l=L[i]
        for j in range(W):
            if l[j]:
                if j == 0:
                    dp[i][j] = 1
                else:
                    dp[i][j] = dp[i][j-1] + 1
            else:
                dp[i][j] = 0
    return dp
H,W=map(int,input().split())
L= [[] for _ in range(H)]
for i in range(H):
    L[i]=list(map(lambda x: False if x=="#" else True,list(input()) ))

def rr(matrix):
    return list(map(list, zip(*matrix)))[::-1]

def mir(L):
    return [list(l[::-1]) for l in L]
def flip(L):
    H=len(L)
    W=len(L[0])
    return [[L[i][j] for i in range(H)] for j in range(W)]
A=rr(L)
B=rr(rr(L))
C=rr(rr(rr(L)))
LL=convert(L)
#AA=rr(rr(rr(convert(A))))
#BB=rr(rr(convert(B)))
#CC=rr(convert(C))
#K=flip(L)
ans = -1
M=[[0for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        t = LL[i][j]+#AA[i][j]+BB[i][j]+CC[i][j]-3 
        ans = max(ans,t)
        M[i][j] = t
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
def convert(L):
    H=len(L)
    W=len(L[0])
    dp = [[0 for _ in range(W)] for _ in range(H)]
    #dp = np.zeros((L.shape[0],L.shape[1]), dtype='int')
    for i in range(H):
        l=L[i]
        for j in range(W):
            if l[j]:
                if j == 0:
                    dp[i][j] = 1
                else:
                    dp[i][j] = dp[i][j-1] + 1
            else:
                dp[i][j] = 0
    return dp
H,W=map(int,input().split())
L= [[] for _ in range(H)]
for i in range(H):
    L[i]=list(map(lambda x: False if x=="#" else True,list(input()) ))

def rr(matrix):
    return list(map(list, zip(*matrix)))[::-1]

def mir(L):
    return [list(l[::-1]) for l in L]
def flip(L):
    H=len(L)
    W=len(L[0])
    return [[L[i][j] for i in range(H)] for j in range(W)]
A=rr(L)
B=rr(rr(L))
C=rr(rr(rr(L)))
LL=convert(L)
AA=rr(rr(rr(convert(A))))
BB=rr(rr(convert(B)))
CC=rr(convert(C))
#K=flip(L)
ans = -1
M=[[0for j in range(W)] for i in range(H)]
for i in range(H):
    for j in range(W):
        t = LL[i][j]+AA[i][j]+BB[i][j]+CC[i][j]-3 
        ans = max(ans,t)
        M[i][j] = T
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
def convert(L):
    dp = np.zeros((L.shape[0],L.shape[1]), dtype='int')
    for i in range(L.shape[0]):
        l=L[i]
        for j in range(L.shape[1]):
            if l[j]:
                if j == 0:
                    dp[i][j] = 1
                else:
                    dp[i][j] = dp[i][j-1] + 1
            else:
                dp[i][j] = 0
    return dp
H,W=map(int,input().split())
L= np.zeros((H,W),dtype='bool')
for i in range(H):
    L[i]=list(map(lambda x: False if x=="#" else True,list(input()) ))
 
ans = convert(L) #+ np.fliplr(convert(np.fliplr(L))) + convert(L.T).T + np.flipud(convert(np.flipud(L).T).T) - 3
print(np.max(ans))

Buggy submission (verdict: Runtime Error):
import numpy as np

def convert(L):
    dp = np.empty_like(L)
    for i in range(L.shape[0]):
        l=L[i]
        start=0
        end=0
        sum_=0
        for j in range(L.shape[1]):
            if l[j] == 1:
                end += 1
                sum_ += 1
            elif l[j] == 0 and sum_ !=0:
                dp[i][start:end] = sum_
                sum_= 0
                start = end + 1
            elif l[j] == 0 and sum_ ==0:
                start += 1
                end += 1
            #print(i,j,start,end,sum_,l[j])
        if sum_!=0:
            dp[i][start:end+1] = sum_  
    return dp

H,W=map(int,input().split())
L= np.zeros((H,W))
for i in range(H):
    L[i]=list(map(lambda x: 0 if x=="#" else 1,list(input()) ))

dp1 = convert(L).astype('int')
dp2 = convert(L.T).T.astype('int')
ans = dp1+dp2-1
print(ans.max())