Problem p03240 (python)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
a = sorted(a, key=lambda x:x[2],reverse = True)

check = False
    
for i in range(101):
    for j in range(101):
        b = 0
        while b < n:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = max(h - abs(i - a[b][0]) - abs(j - a[b][1]),0)
                if de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)

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

check = False
    
for i in range(500):
    for j in range(500):
        b = 0
        while b < n:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = max(h - abs(i - a[b][0]) - abs(j - a[b][1]),0)
                if de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
if n == 1:
    print(str(a[0][0]) + ' ' + str(a[0][1]) + ' ' + str(a[0][2])) 
else:    
    check = False
    for i in range(101):
        for j in range(101):
            h = []
            for k in range(n):
                c = abs(i - a[k][0]) + abs(j -a[k][1]) + a[k][2]
                h.append(c)
            count = h.count(h[0])
            if len(h) == count:
                ans = str(i) + ' ' + str(j) + ' ' +str(h[0])
                check = True
            if check:
                break
        if check:
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
if n == 1:
    print(str(a[0][0]) + ' ' + str(a[0][1]) + ' ' + str(a[0][2])) 
else:    
    check = False
    for i in range(101):
        for j in range(101):
            b = 0
            while b < n:
                if b == 0:
                    h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                    b +=1
                else:
                    de = max(h - abs(i - a[b][0]) - abs(j - a[b][1]),0)
                    if de == a[b][2]:
                        b+=1
                    else:
                        break
            if b == n:
                ans = str(i) + ' ' + str(j) + ' ' +str(h)
                check = True
            if check:
                break
        if check:
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
if n == 1:
    print(str(a[0][0]) + ' ' + str(a[0][1]) + ' ' + str(a[0][2])) 
else:    
    check = False
    for i in range(101):
        for j in range(101):
            b = 0
            while b < n-1:
                if b == 0:
                    h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                    b +=1
                else:
                    de = max(h - abs(i - a[b][0]) - abs(j - a[b][1]),0)
                    if de == a[b][2]:
                        b+=1
                    else:
                        break
            if b == n-1:
                ans = str(i) + ' ' + str(j) + ' ' +str(h)
                check = True
            if check:
                break
        if check:
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
check = False
for i in range(101):
    for j in range(101):
        b = 0
        while b < n-1:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = max(h - abs(i - a[b][0]) - abs(j - a[b][1]),0)
                if de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n-1:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
check = False
for i in range(110):
    for j in range(110):
        b = 0
        while b < n-1:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                if h  == de:
                    b+=1
                else:
                    break
        if b == n-1:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
check = False
for i in range(110):
    for j in range(110):
        b = 0
        while b < n-1:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = abs(i - a[b][0]) + abs(j - a[b][1])
                if h -de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n-1:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for i in range(n):
    _ = list(map(int, input().split()))
    a.append(_)
check = False
for i in range(101):
    for j in range(101):
        b = 0
        while b < n-1:
            if b == 0:
                h = abs(i - a[b][0]) + abs(j - a[b][1]) + a[b][2]
                b +=1
            else:
                de = abs(i - a[b][0]) + abs(j - a[b][1])
                if h -de == a[b][2]:
                    b+=1
                else:
                    break
        if b == n-1:
            ans = str(i) + ' ' + str(j) + ' ' +str(h)
            check = True
        if check:
            break
    if check:
        break
print(ans)