Problem p03014 (python)

Fixed submission:
def examC():
    N, M = LI()
    A = [I() for _ in range(M)]
    A.append(N+1)
    fib = [1]*(N+2)
    for i in range(1,N):
        fib[i+2] = fib[i+1] + fib[i]
    fib[0] = 0
#    print(fib)
    ans = fib[A[0]]%mod
    for i in range(M):
        ans *= fib[A[i+1]-A[i]-1]
        ans %=mod
    print(ans)
    return

def examD():
    H, W = LI()
    S = [SI() for _ in range(H)]
    width = [[0]*W for _ in range(H)]
    height = [[0]*W for _ in range(H)]
    for i in range(H):
        cur = 0; keep = []
        for j in range(W):
            if S[i][j]==".":
                cur +=1
                keep.append(j)
            else:
                for k in keep:
                    width[i][k] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                width[i][k] = cur
    for j in range(W):
        cur = 0; keep = []
        for i in range(H):
            if S[i][j]==".":
                cur +=1
                keep.append(i)
            else:
                for k in keep:
                    height[k][j] = cur
                cur = 0; keep = []
        if keep:
            for k in keep:
                height[k][j] = cur
    ans = 0
    for i in range(H):
        for j in range(W):
            cur = width[i][j] + height[i][j]
            if ans<cur:
                ans = cur
    print(ans-1)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()

Buggy submission (verdict: Runtime Error):
def dpWcount(a,b,dpW,k):
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       return k
def dpHcount(a,b,dpH,k):
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       return k

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
ans = int(1)
ansC = int(0)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans = max(ansC,ans)
print(ans-1)

Buggy submission (verdict: Runtime Error):
def dpWcount(a,b,dpW,k):
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       return k
def dpHcount(a,b,dpH,k):
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       return k

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
ans = int(1)
ansC = int(0)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans = max(ansC,ans)
print(ans-1)

Buggy submission (verdict: Runtime Error):
def dpWcount(a,b,dpW,k):
    count = int(0)
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
            k = int(0)
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       count = k
       k = int(0)
       return count
def dpHcount(a,b,dpH,k):
    count = int(0)
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
            k = int(0)
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       count = k
       k = int(0)
       return count

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
ans = int(1)
ansC = int(0)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

Buggy submission (verdict: Runtime Error):
def dpWcount(a,b,dpW,k):
    count = int(0)
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
            k = int(0)
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       count = k
       k = int(0)
       return count
def dpHcount(a,b,dpH,k):
    count = int(0)
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
            k = int(0)
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       count = k
       k = int(0)
       return count


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
ans = int(1)
ansC = int(0)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans = max(ansC,ans)
print(ans-1)

Buggy submission (verdict: Runtime Error):
def dpWcount(a,b,dpW,k):
    count = int(0)
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
            k = int(0)
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       count = k
       k = int(0)
       return count
def dpHcount(a,b,dpH,k):
    count = int(0)
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
            k = int(0)
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       count = k
       k = int(0)
       return count


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
ans = int(1)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans = max(ansC,ans)
print(ans-1)

Buggy submission (verdict: Runtime Error):
def dpWcount(a,b,dpW,k):
    count = int(0)
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
            k = int(0)
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       count = k
       k = int(0)
       return count
def dpHcount(a,b,dpH,k):
    count = int(0)
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
            k = int(0)
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       count = k
       k = int(0)
       return count


import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(1)

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans = max(ansC,ans)
print(ans-1)

Buggy submission (verdict: Runtime Error):
def dpWcount(a,b,dpW,k):
    count = int(0)
    if S[a][b]==".":
        if b<W-1:
            k +=1
            dpW[a][b] = dpWcount(a,b+1,dpW,k)
        else:
            dpW[a][b] = k+1
            k = int(0)
        return dpW[a][b]
    else:
       dpW[a][b] = 0
       count = k
       k = int(0)
       return count
def dpHcount(a,b,dpH,k):
    count = int(0)
    if S[a][b]==".":
        if a<H-1:
            k +=1
            dpH[a][b] = dpHcount(a+1,b,dpH,k)
        else:
            dpH[a][b] = k+1
            k = int(0)
        return dpH[a][b]
    else:
       dpH[a][b] = 0
       count = k
       k = int(0)
       return count


import heapq
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIS(): return list(map(str,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = []

H, W = LI()
S = [str(input()) for _ in range(H)]
dpW = [[0]*W for _ in range(H)]
dpH = [[0]*W for _ in range(H)]

for i in range(H):
    w = int(0)
    while w<W:
        k = int(0)
        w += max(dpWcount(i,w, dpW, k),1)

#print(dpW)

for i in range(W):
    h = int(0)
    while h<H:
        k = int(0)
        h += max(dpHcount(h,i, dpH, k),1)

#print(dpH)

for i in range(H):
    for j in range(W):
        ansC = dpW[i][j] + dpH[i][j]
        ans.append(ansC)
print(max(ans)-1)

Buggy submission (verdict: Runtime Error):
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][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)-3
ans = max(ans)

print(ans)