Problem p03240 (python)

Fixed submission:
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

for _ in range(0,n):
    if ab[_][2] !=0:
        x = ab[_][0]
        y = ab[_][1]
        h = ab[_][2]
        break

for i in range(101):
    for j in range(101):
        f = True
        l = abs(i-x)+abs(j-y)+h
        for k in range(0,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            if max(l-abs(i-dx)-abs(j-dy),0) ==dh:
                pass
            else:
                f = False
        if f:
            ansx =i
            ansy =j
            ansr = l
            break
print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Buggy submission (verdict: Runtime Error):
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

for _ in range(0,n):
    if ab[_][2] !=0:
        x = ab[_][0]
        y = ab[_][1]
        h = ab[_][2]

for i in range(101):
    for j in range(101):
        f = True
        l = abs(i-x)+abs(i-y)+h
        for k in range(0,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            if max(l-abs(i-dx)-abs(j-dy),0) ==dh:
                pass
            else:
                f = False
                break
        if f:
            ansx =i
            ansy =j
            ansr = l
            break
print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Buggy submission (verdict: Runtime Error):
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
 
for i in range(101):
    for j in range(101):
        res = []
        zero = []
        f = True
        for k in range(0,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            if dh ==0:
                zero.append([dx,dy])
            else:
                res.append(abs(i-dx)+abs(j-dy)+dh)
        if len(set(res)) == 1:
            for l in zero:
                if res[0] - (abs(i-l[0])+abs(f-l[1])) <=0:
                    pass
                else:
                    f = False
            if f == True:
                ansx =i
                ansy =j
                ansr = res[0]

print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Buggy submission (verdict: Runtime Error):

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
 
for i in range(101):
    for j in range(101):
        res = []
        zero = []
        f = True
        for k in range(0,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            if dh ==0:
                zero.append([dx,dy])
            else:
                res.append(abs(i-dx)+abs(j-dy)+dh)
        if len(set(res)) == 1:
            for l in zero:
                if res[0] - (abs(i-l[0])+abs(f-l[1])) <=0:
                    pass
                else:
                    f = False
                    break
            if f:
                ansx =i
                ansy =j
                ansr = res[0]

print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Buggy submission (verdict: Runtime Error):
n = int(input())

ab = [list(map(int, input().split())) for _ in range(n)]

for i in range(101):
    for j in range(101):
        res = [abs(i-ab[0][0])+abs(j-ab[0][1])+ab[0][2]]
        f = False
        for k in range(1,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            res.append(abs(i-dx)+abs(j-dy)+dh)
        if len(set(res)) == 1:
            ansx =i
            ansy =j
            ansr = res[0]
            break
        
print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Buggy submission (verdict: Runtime Error):
n = int(input())
x,y,h = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(101):
    for j in range(101):
        res = [abs(i-x)+abs(j-y)+h]
        f = False
        for k in range(n-1):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            res.append(abs(i-dx)+abs(j-dy)+dh)
        if len(set(res)) == 1:
            ansx =i
            ansy =j
            ansr = res[0]
            break
        
print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Buggy submission (verdict: Runtime Error):
n = int(input())
x,y,h = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(101):
    for j in range(101):
        res = abs(i-x)+abs(j-y)+h
        f = False
        for k in range(n-1):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            ress = abs(i-dx)+abs(j-dy)+dh
            if res == ress:
                pass
            else:
                f = True
        if f ==False:
            ansx =i
            ansy =j
            ansr = res
            break
print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Buggy submission (verdict: Runtime Error):
n = int(input())

x,y,h = map(int, input().split())

ab = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(101):
    for j in range(101):
        res = abs(i-x)+abs(j-y)+h
        f = False
        for k in range(n-1):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            ress = abs(i-dx)+abs(j-dy)+dh
            if res == ress:
                pass
            else:
                f = True
                break
        if f ==False:
            ansx =i
            ansy =j
            ansr = res
            break
print(str(ansx)+" "+str(ansy)+" "+str(ansr))