Buggy python submission (verdict: Time Limit Exceeded):

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c = [[[-1]*2 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c[i][j][0] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c[i+k][j][0] = n
            
        if c[i][j][1] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c[i][j+k][1] = n


        ans = max(ans,c[i][j][0]+c[i][j][1])
print(ans-1)


Fixed submission:

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    
    h,w = map(int,input().split())
    l = [list(input()) for i in range(h)]

    c = [[[-1]*2 for i in range(w)] for i in range(h)]
    ans = 0
    for i in range(h):
        for j in range(w):
            if c[i][j][0] == -1:
                n = 0
                while i+n < h:
                    if l[i+n][j] == ".":
                        n += 1
                    else:
                        break
                for k in range(n):
                    c[i+k][j][0] = n
                
            if c[i][j][1] == -1:
                n = 0
                while j+n < w:
                    if l[i][j+n] == ".":
                        n += 1
                    else:
                        break
                for k in range(n):
                    c[i][j+k][1] = n
    
    
            ans = max(ans,c[i][j][0]+c[i][j][1])
    print(ans-1)
if __name__ == "__main__":
    main()

Fixed submission:

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    
    h,w = map(int,input().split())
    l = [list(input()) for i in range(h)]

    c = [[[-1]*2 for i in range(w)] for i in range(h)]

    for i in range(h):
        for j in range(w):
            if c[i][j][0] == -1:
                n = 0
                while i+n < h and l[i+n][j] == ".":
                    n += 1
                for k in range(n):
                    c[i+k][j][0] = n
                
            if c[i][j][1] == -1:
                n = 0
                while j+n < w and l[i][j+n] == ".":
                    c[i][j+n][1] = 1
                    n += 1
                for k in range(n):
                    c[i][j+k][1] = n


            
    ans = 0
    for i in range(h):
        for j in range(w):
            if l[i][j] == ".":
                ans = max(ans,c[i][j][0]+c[i][j][1])
    print(ans-1)
if __name__ == "__main__":
    main()

Fixed submission:

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    h,w = map(int,input().split())
    l = [list(input()) for i in range(h)]

    c = [[[-1]*2 for i in range(w)] for i in range(h)]

    def count(x,y):

        if c[x][y][0] == -1:
            n = 0
            while x+n < h and l[x+n][y] == ".":
                c[x+n][y][0] = 1
                n += 1
            c[x][y][0] = n
        elif c[x][y][0] == 1:
            c[x][y][0] = c[x-1][y][0]
            
        if c[x][y][1] == -1:
            n = 0
            while y+n < w and l[x][y+n] == ".":
                c[x][y+n][1] = 1
                n += 1
            c[x][y][1] = n
        elif c[x][y][1] == 1:
            c[x][y][1] = c[x][y-1][1]


        return c[x][y][0]+c[x][y][1]-1
    ans = 0
    for i in range(h):
        for j in range(w):
            if l[i][j] == ".":
                ans = max(ans,count(i,j))
    print(ans)
if __name__ == "__main__":
    main()

Fixed submission:

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    h,w = map(int,input().split())
    l = [list(input()) for i in range(h)]

    c = [[[-1]*2 for i in range(w)] for i in range(h)]

    def count(x,y):

        if c[x][y][0] == -1:
            n = 0
            while x+n < h and l[x+n][y] == ".":
                c[x+n][y][0] = 1
                n += 1
            c[x][y][0] = n
        elif c[x][y][0] == 1:
            c[x][y][0] = c[x-1][y][0]
            
        if c[x][y][1] == -1:
            n = 0
            while y+n < w and l[x][y+n] == ".":
                c[x][y+n][1] = 1
                n += 1
            c[x][y][1] = n
        elif c[x][y][1] == 1:
            c[x][y][1] = c[x][y-1][1]


        return c[x][y][0]+c[x][y][1]-1
    ans = 0
    for i in range(h):
        for j in range(w):
            if l[i][j] == ".":
                ans = max(ans,count(i,j))
    print(ans)
if __name__ == "__main__":
    main()

Fixed submission:

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c = [[[-1]*2 for i in range(w)] for i in range(h)]

def count(x,y):

    if c[x][y][0] == -1:
        n = 0
        while x+n < h and l[x+n][y] == ".":
            n += 1
        for i in range(n):
            c[x+i][y][0] = n
        
    if c[x][y][1] == -1:
        n = 0
        while y+n < w and l[x][y+n] == ".":
            n += 1
        for i in range(n):
            c[x][y+i][1] = n

    return c[x][y][0]+c[x][y][1]
ans = 0
for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            ans = max(ans,count(i,j))
print(ans-1)


Fixed submission:

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c = [[[-1]*2 for i in range(w)] for i in range(h)]

def count(x,y):

    if c[x][y][0] == -1:
        n = 0
        while x+n < h and l[x+n][y] == ".":
            n += 1
        for i in range(n):
            c[x+i][y][0] = n
        
    if c[x][y][1] == -1:
        n = 0
        while y+n < w and l[x][y+n] == ".":
            n += 1
        for i in range(n):
            c[x][y+i][1] = n

    return c[x][y][0]+c[x][y][1]
ans = 0
for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            ans = max(ans,count(i,j))
print(ans-1)

Fixed submission:

h,w = map(int,input().split())
l = [list(input()) for i in range(h)]

c1 = [[-1 for i in range(w)] for i in range(h)]
c2 = [[-1 for i in range(w)] for i in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if c1[i][j] == -1:
            n = 0
            while i+n < h:
                if l[i+n][j] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c1[i+k][j] = n
            
        if c2[i][j] == -1:
            n = 0
            while j+n < w:
                if l[i][j+n] == ".":
                    n += 1
                else:
                    break
            for k in range(n):
                c2[i][j+k] = n


        ans = max(ans,c1[i][j]+c2[i][j])
print(ans-1)