Problem p03240 (python)

Fixed submission:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        count=0
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if count==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                    count+=1
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
                for k in range(N):
                    if a[k][2]!=max(H-abs(x-a[k][0])-abs(y-a[k][1]),0):
                        flag=False
print(x,y,H)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
H=0
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if H==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
                for k in range(N):
                    if a[k][2]!=max(H-abs(x-a[k][0])-abs(y-a[k][1]),0):
                        flag=False
print(x,y,H)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if i==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
                for k in range(N):
                    if a[k][2]!=max(H-abs(x-a[k][0])-abs(y-a[k][1]),0):
                        flag=False
print(x,y,H)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if i==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
print(x,y,H)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if a[i][0]!=0:
                if i==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
print(x,y,H)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        for i in range(N):
            if i==0 or H==0:
                H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
            if a[i][2]!=0 and H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]) and H!=0:
                break
            if i==N-1:
                x=cx
                y=cy
                flag=True
print(x,y,H)