Problem p03014 (python)

Fixed submission:
import numpy as np

H,W = map(int, input().split())
s = [list(input()) for j in range(H)]
s = (np.array(s) == ".") * 1

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):
    if j == 0:
        L[:,j] = s[:,j]
    else:
        L[:,j] = (L[:,j-1] + 1) * s[:,j]
        

for j in reversed(range(W)):
    if j == W-1:
        R[:,j] = s[:,j]
    else:
        R[:,j] = (R[:,j+1] + 1) * s[:,j]


for i in range(H):
    if i == 0:
        U[i,:] = s[i,:]
    else:
        U[i,:] = (U[i-1,:] + 1) * s[i,:]

for i in reversed(range(H)):
    if i == H-1:
        D[i,:] = s[i,:]
    else:
        D[i,:] = (D[i+1,:] + 1) * s[i,:]

print(np.max(L + R + U + D - 3))

Buggy submission (verdict: Runtime Error):
# import numpy as np
h,w = map(int,input().split())
field = []
accum=[[0 for i in range(w)] for j in range(h)]
accumrev=[[0 for i in range(w)] for j in range(h)]
stack = [[0 for i in range(w)] for j in range(h)]
stackrev = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    field.append(list(input()))
field = np.array(field)

for i in range(h):
    s = field[i]
    temp = 0
    for j in range(w):
        if s[j] == "#":
            accum[i][j] = 0
            temp = 0
        else:
            temp += 1
            accum[i][j] = temp
    accum[i][-1] = temp
for i in range(h):
    s = field[i]
    temp = 0
    for j in range(1,w+1):
        if s[-j] == "#":
            accumrev[i][-j] = 0
            temp = 0
        else:
            temp += 1
            accumrev[i][-j] = temp
    accumrev[i][0] = temp
# print(field)
# print(np.array(accum))
# print(np.array(accumrev))

nf = list(zip(*field))

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

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

# print(field)
# print(np.array(stack))
# print(np.array(stackrev))

# accum = np.array(accum)
# accumrev = np.array(accumrev)
# stack = np.array(stack)
# stackrev = np.array(stackrev)



ans = 0

for i in range(h):
    for j in range (w):
        temp = accum[i][j] + accumrev[i][j] + stackrev[i][j] + stack[i][j]-3
        if temp > ans:
            ans = temp
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
h,w = map(int,input().split())
field = []
accum=[[0 for i in range(w)] for j in range(h)]
accumrev=[[0 for i in range(w)] for j in range(h)]
stack = [[0 for i in range(w)] for j in range(h)]
stackrev = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
    field.append(list(input()))
field = np.array(field)

for i in range(h):
    s = field[i]
    temp = 0
    for j in range(w):
        if s[j] == "#":
            accum[i][j] = 0
            temp = 0
        else:
            temp += 1
            accum[i][j] = temp
    accum[i][-1] = temp
for i in range(h):
    s = field[i]
    temp = 0
    for j in range(1,w+1):
        if s[-j] == "#":
            accumrev[i][-j] = 0
            temp = 0
        else:
            temp += 1
            accumrev[i][-j] = temp
    accumrev[i][0] = temp
# print(field)
# print(np.array(accum))
# print(np.array(accumrev))

nf = list(zip(*field))

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

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

# print(field)
# print(np.array(stack))
# print(np.array(stackrev))

# accum = np.array(accum)
# accumrev = np.array(accumrev)
# stack = np.array(stack)
# stackrev = np.array(stackrev)



ans = 0

for i in range(h):
    for j in range (w):
        temp = accum[i][j] + accumrev[i][j] + stackrev[i][j] + stack[i][j]-3
        if temp > ans:
            ans = temp
print(ans)

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

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

field = []

l = np.zeros((h+2,w+2),dtype=np.int64)
r = np.zeros((h+2,w+2),dtype=np.int64)
u = np.zeros((h+2,w+2),dtype=np.int64)
d = np.zeros((h+2,w+2),dtype=np.int64)
tot = np.zeros((h,w),dtype=np.int64)

for i in range(h):
    field.append(list(input()))

field = np.pad(field,(1,1),"constant",constant_values="#")

# print(field)

for i in range(h+2):
    for j in range(w+1):
        if field[i][j+1] == ".":
            l[i][j+1] = l[i][j] + 1
        else:
            continue

for i in range(h+2):
    for j in range(1,w+1):
        if field[i][-j-1] == ".":
            r[i][-j-1] = r[i][-j] + 1
        else:
            continue

for i in range(w+2):
    for j in range(h+1):
        if field[j+1][i] == ".":
            u[j+1][i] = u[j][i] + 1
        else:
            continue

for i in range(w+2):
    for j in range(1,h+1):
        if field[-j-1][i] == ".":
            d[-j-1][i] = d[-j][i] + 1
        else:
            continue

# print(l)
# print(r)
# print(u)
# print(d)

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

# print(tot)

print(np.max(tot))

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

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

field = []

l = np.zeros((h+2,w+2))
r = np.zeros((h+2,w+2))
u = np.zeros((h+2,w+2))
d = np.zeros((h+2,w+2))
tot = np.zeros((h,w))

for i in range(h):
    field.append(list(input()))

field = np.pad(field,(1,1),"constant",constant_values="#")

# print(field)

for i in range(h+2):
    for j in range(w+1):
        if field[i][j+1] == ".":
            l[i][j+1] = l[i][j] + 1
        else:
            continue

for i in range(h+2):
    for j in range(1,w+1):
        if field[i][-j-1] == ".":
            r[i][-j-1] = r[i][-j] + 1
        else:
            continue

for i in range(w+2):
    for j in range(h+1):
        if field[j+1][i] == ".":
            u[j+1][i] = u[j][i] + 1
        else:
            continue

for i in range(w+2):
    for j in range(1,h+1):
        if field[-j-1][i] == ".":
            d[-j-1][i] = d[-j][i] + 1
        else:
            continue

# print(l)
# print(r)
# print(u)
# print(d)

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

# print(tot)

print(int(np.max(tot)))

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

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

field = []

l = np.zeros((h+2,w+2))
r = np.zeros((h+2,w+2))
u = np.zeros((h+2,w+2))
d = np.zeros((h+2,w+2))
tot = np.zeros((h,w))

for i in range(h):
    field.append(list(input()))

field = np.pad(field,(1,1),"constant",constant_values="#")

# print(field)

for i in range(h+2):
    for j in range(w+1):
        if field[i][j+1] == ".":
            l[i][j+1] = l[i][j] + 1
        else:
            continue

for i in range(h+2):
    for j in range(1,w+1):
        if field[i][-j-1] == ".":
            r[i][-j-1] = r[i][-j] + 1
        else:
            continue

for i in range(w+2):
    for j in range(h+1):
        if field[j+1][i] == ".":
            u[j+1][i] = u[j][i] + 1
        else:
            continue

for i in range(w+2):
    for j in range(1,h+1):
        if field[-j-1][i] == ".":
            d[-j-1][i] = d[-j][i] + 1
        else:
            continue
l = l

# print(l)
# print(r)
# print(u)
# print(d)

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

# print(tot)

print(int(np.max(tot)))