Problem p03240 (python)

Fixed submission:
N = int(input())
xyz = []

for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)


if N == 1:
    ans = [str(xyz[0][0]), str(xyz[0][1]), str(xyz[0][2])]
else:
    for i in range(101):
        for j in range(101):
            for k in range(N):
                if xyz[k][2] >= 1:      
                    h = max(xyz[k][2] + abs(xyz[k][0] - i) + abs(xyz[k][1] - j),0)

                    count = N
                    for n in range(0,N):
                        g = max(h - abs(i - xyz[n][0]) - abs(j - xyz[n][1]),0)
                        if g == xyz[n][2]:
                            count -= 1
                    
                    if count == 0:
                        ans = [str(i), str(j), str(h)]
                        break
                    break

ans_s = ' '.join(ans)
print(ans_s)

Buggy submission (verdict: Runtime Error):
N = int(input())
xyz = []

for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)

if N == 1:
    ans = [str(xyz[0][0]), str(xyz[0][1]), str(xyz[0][2])]
else:
    for i in range(101):
        for j in range(101):
            h = max(xyz[0][2] + abs(xyz[0][0] - i) + abs(xyz[0][1] - j),0)

            count = N
            for n in range(0,N):
                g = max(h - abs(i - xyz[n][0]) - abs(j - xyz[n][1]),0)
                if g == xyz[n][2]:
                    count -= 1
            
            if count == 0:
                ans = [str(i), str(j), str(h)]
                break

ans_s = ' '.join(ans)
print(ans_s)

Buggy submission (verdict: Runtime Error):
N = int(input())
xyz = []

for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)

if N == 1:
    ans = [str(xyz[0][0]), str(xyz[0][1]), str(xyz[0][2])]
else:
    for i in range(101):
        for j in range(101):
            h = xyz[0][2] + abs(xyz[0][0] - i) + abs(xyz[0][1] - j)

            count = N
            for n in range(0,N):
                g = max(h - abs(i - xyz[n][0]) - abs(j - xyz[n][1]),0)
                if g == xyz[n][2]:
                    count -= 1
            
            if count == 0:
                ans = [str(i), str(j), str(h)]
                break

ans_s = ' '.join(ans)
print(ans_s)

Buggy submission (verdict: Runtime Error):
N = int(input())
xyz = []

for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)

for i in range(101):
    for j in range(101):
        h = xyz[0][2] + abs(xyz[0][0] - i) + abs(xyz[0][1] - j)

        count = N
        for n in range(0,N):
            g = max(h - abs(i - xyz[n][0]) - abs(j - xyz[n][1]),0)
            if g == xyz[n][2]:
                count -= 1
        
        if count == 0:
            ans = [str(i), str(j), str(h)]
            break

ans_s = ' '.join(ans)
print(ans_s)

Buggy submission (verdict: Runtime Error):
N = int(input())
xyz = []
r = 0

for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)

for n in range(N):
    if xyz[n][2] == 10**9:
        ans = [str(xyz[n][0]), str(xyz[n][1]), str(xyz[n][2])]
        r = 1

if r == 1:
    pass
else:
    for i in range(101):
        for j in range(101):
            h = xyz[0][2] + abs(xyz[0][0] - i) + abs(xyz[0][1] - j)

            count = N
            for n in range(0,N):
                g = h - abs(i - xyz[n][0]) - abs(j - xyz[n][1])
                if g == xyz[n][2]:
                    count -= 1
            
            if count == 0:
                ans = [str(i), str(j), str(h)]
                break

ans_s = ' '.join(ans)
print(ans_s)

Buggy submission (verdict: Runtime Error):
N = int(input())
xyz = []
for _ in range(N):
    temp = list(map(int, input().split()))
    xyz.append(temp)

for i in range(101):
    for j in range(101):
        h = xyz[0][2] + abs(xyz[0][0] - i) + abs(xyz[0][1] - j)

        count = N-1
        for n in range(1,N):
            g = h - abs(i - xyz[n][0]) - abs(j - xyz[n][1])
            if g == xyz[n][2]:
                count -= 1
        
        if count == 0:
            ans = [str(i), str(j), str(h)]
            break

ans_s = ' '.join(ans)
print(ans_s)