Problem:


Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).  

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:  

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.  

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."  

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.  

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:  

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.  

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.  

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.  



Sample input:
4
2 3 5
2 1 5
1 2 5
3 2 5


Sample output:
2 2 6

Submission status: Runtime Error

Solution code:

n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for k in range(n):
                xx = int(map_list[k][0])
                yy = int(map_list[k][1])
                hh = int(map_list[k][2])

                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():

    for i in range(101):
        for j in range(101):
            x = int(map_list[-1][0])
            y = int(map_list[-1][1])
            h = int(map_list[-1][2])
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for data in map_list:
                xx, yy, hh = map(int, data)
                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for data in map_list:
                xx, yy, hh = map(int, data)
                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
        
            for data in map_list:
                x, y, h = map(int, data)
                if h != max(H - abs(x - i) - abs(y - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())
map_list.sort(key=lambda x:x[2])

def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(i - x) + abs(j - y) + h
        
            for data in map_list:
                x, y, h = map(int, data)
                if h != max(H - abs(x - i) - abs(y - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H
        if cont_check:
            return i, j, H

i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())


def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(i - x) + abs(j - y) + h
        
            for data in map_list:
                x, y, h = map(int, data)
                if h != max(H - abs(x - i) - abs(y - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H
        if cont_check:
            return i, j, H

i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())


def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(i - x) + abs(j - y) + h
        
            for data in map_list:
                x, y, h = map(int, data)
                if h != max(H - abs(i - x) - abs(j - y), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H
        if cont_check:
            return i, j, H
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())


def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(i - x) + abs(j - y) + h
            #print('base:',i, j, H)
        
            for data in map_list:
                x, y, h = map(int, data)
                #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
                if h != max(H - abs(i - x) - abs(j - y), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H
            
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())


def function():
    x = int(map_list[-1][0])
    y = int(map_list[-1][1])
    h = int(map_list[-1][2])

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(i - x) + abs(j - y) + h
            #print('base:',i, j, H)
        
            for data in map_list:
                x, y, h = map(int, data)
                #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
                if h != max(H - abs(i - x) - abs(j - y), 0):
                    cont_check = False
                    break
            if cont_check and H >= 1:
                return i, j, H
            
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())


def function():
    x = map_list[-1][0]
    y = map_list[-1][1]
    h = map_list[-1][2]

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(i - int(x)) + abs(j - int(y)) + int(h)
            #print('base:',i, j, H)
        
            for data in map_list[:-1]:
                x, y, h = data
                h = max(int(h), 0)
                #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
                if int(h) != max(H - abs(i - int(x)) - abs(j - int(y)), 0):
                    cont_check = False
                    break
            if cont_check and H >= 1:
                return i, j, H
            
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())


def function():
    x = map_list[-1][0]
    y = map_list[-1][1]
    h = map_list[-1][2]

    for i in range(101):
        for j in range(101):
            c = 0
            H = abs(i - int(x)) + abs(j - int(y)) + int(h)
            #print('base:',i, j, H)
        
            for data in map_list[:-1]:
                x, y, h = data
                h = max(int(h), 0)
                #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
                if int(h) != max(H - abs(i - int(x)) - abs(j - int(y)), 0):
                    break
                c += 1
            if c >= n - 1:
                return i, j, H
            
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:

n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
for i in range(101):
    for j in range(101):
        c = 0
        x = map_list[0][0]
        y = map_list[0][1]
        h = map_list[0][2]
        h = max(int(h), 0)
        val = abs(i - int(x)) + abs(j - int(y)) + int(h)
        #print('base:',i, j, val)
        
        for data in map_list[1:]:
            x, y, h = data
            h = max(int(h), 0)
            #print('check:',i, j, val, abs(i - int(x)) + abs(j - int(y) + int(h)))
            if int(h) != max(H - abs(i - int(x)) - abs(j - int(y)), 0):
                break
            c += 1
        if c >= n - 1:
            found_data = True
            break
    if found_data:
        break

h = abs(i - int(x)) + abs(j - int(y)) + int(h)
print(i, j, h)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
def function():
    for i in range(101):
        for j in range(101):
            c = 0
            x = map_list[0][0]
            y = map_list[0][1]
            h = map_list[0][2]
            h = max(int(h), 0)
            H = abs(i - int(x)) + abs(j - int(y)) + int(h)
            #print('base:',i, j, H)
        
            for data in map_list[1:]:
                x, y, h = data
                h = max(int(h), 0)
                #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
                if int(h) != max(H - abs(i - int(x)) - abs(j - int(y)), 0):
                    break
                c += 1
            if c >= n - 1:
                return i, j, H
            
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
def function():
    for i in range(101):
        for j in range(101):
            c = 0
            x = map_list[0][0]
            y = map_list[0][1]
            h = max(int(map_list[0][2]), 0)
            H = abs(i - int(x)) + abs(j - int(y)) + int(h)
            #print('base:',i, j, H)
        
            for data in map_list[1:]:
                x, y, h = data
                h = max(int(h), 0)
                #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
                if H != abs(i - int(x)) + abs(j - int(y)) + int(h):
                    break
                c += 1
            if c >= n - 1:
                return i, j, H
            
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:
n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
def function():
    for i in range(101):
        for j in range(101):
            c = 0
            x = map_list[0][0]
            y = map_list[0][1]
            h = map_list[0][2]
            H = abs(i - int(x)) + abs(j - int(y)) + int(h)
            #print('base:',i, j, H)
        
            for data in map_list[1:]:
                x, y, h = data
                #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
                if H != abs(i - int(x)) + abs(j - int(y)) + int(h):
                    break
                c += 1
            if c >= n - 1:
                return i, j, H
            
i, j, H = function()
print(i, j, H)

Submission status: Runtime Error

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    idxes = []

    for i in range(N):
        X[i], Y[i], H[i] = MI()
        idxes.append((H[i], i))

    idxes.sort(reverse=True)

    for cx in range(101):
        for cy in range(101):
            ans = None
            zero_arr = []
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            else:
                tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                zero_arr.append(tmp)
            counter = 1
            for _, i in idxes:
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    zero_arr.append(tmp)
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                if ans is None and ans == min(zero_arr):
                    print(zero_arr, ans)
                    a = X[0] + Y[0]
                    for i in range(1, N):
                        a = min(a, X[i] + Y[i])
                    print(cx, cy, a)
                    return
                elif ans == min(zero_arr):
                    print(cx, cy, ans)
                    return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    idxes = []

    for i in range(N):
        X[i], Y[i], H[i] = MI()
        idxes.append((H[i], i))

    idxes.sort(reverse=True)

    for cx in range(101):
        for cy in range(101):
            ans = None
            minzero = None
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            else:
                minzero = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
            counter = 1
            for _, i in idxes:
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    minzero = min(minzero, tmp)
                    if ans is not None and tmp < ans:
                        break
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                if ans is None:
                    print(cx, cy, minzero)
                else:
                    print(cx, cy, ans)
                return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
d=[0,0]
f=0
if n==1:
    
else:
    n=len(XYH)
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Runtime Error

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
d=[0,0]
f=0
if n==1:
    k
else:
    n=len(XYH)
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Runtime Error

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
if n==1:
    #この時どうなるか
    if xyh[0][2]==0:
        k
        d=[xyh[0][0],xyh[0][1],xyh[0][2]]
        print(" ".join(map(str,d)))
else:
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[-1][0]-i)+abs(XYH[-1][1]-j)+XYH[-1][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Runtime Error

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
if n==1:
    k
    d=[xyh[0][0],xyh[0][1],xyh[0][0]+xyh[0][1]+xyh[0][2]]
    print(" ".join(map(str,d)))
else:
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[-1][0]-i)+abs(XYH[-1][1]-j)+XYH[-1][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Runtime Error

Solution code:
N = int(input())
P = [[int(i) for i in input().split()] for _ in range(N)]

P.sort(key=lambda x: x[2])
array = []
p = P.pop()

for x in range(0, 101):
    for y in range(0, 101):
        H = p[2]+abs(p[0]-x)+abs(p[1]-y)
        if H > 0:
            array.append((x, y, H))

for x, y, h in P:
    ary = []
    for cx, cy, H in array:
        if h == (H-abs(x-cx)-abs(y-cy)):
            ary.append((cx, cy, H))
    array = ary

print(*array[0])

Submission status: Runtime Error

Solution code:
n=int(input())
li=[]
cnt=[]
for i in range(n):
    x,y,h=map(int,input().split())
    li.append([x,y,h])
for j in range(0,101):
    for k in range(0,101):
        for l in range(n):
            if li[l][2]!=0:
                cnt.append(li[l][2]+abs(li[l][0]-j)+abs(li[l][1]-k))
            elif l!=0 and li[l][2]==0:
                if cnt[0]-abs(li[l][0]-j)-abs(li[l][1]-k)>0:
                    cnt.append(0)               
        if len(set(cnt))==1 and max(cnt[0]-abs(li[0][0]-j)-abs(li[0][1]-k),0)==li[0][2]:
            ans=[j,k,cnt[0]]
            break
        else:
            cnt=[]

print(ans[0],ans[1],ans[2])

Submission status: Runtime Error

Solution code:
n=int(input())
li=[]
cnt=[]
for i in range(n):
    x,y,h=map(int,input().split())
    li.append([x,y,h])
for j in range(0,101):
    for k in range(0,101):
        for l in range(n):
            if li[l][2]!=0:
                cnt.append(li[l][2]+abs(li[l][0]-j)+abs(li[l][1]-k))
            elif l!=0 and li[l][2]==0:
                if cnt[0]-abs(li[l][0]-j)-abs(li[l][1]-k)>0:
                    cnt.append(0)               
        if len(set(cnt))==1 and cnt[0]-abs(li[0][0]-j)-abs(li[0][1]-k)==li[0][2]:
            ans=[j,k,cnt[0]]
            break
        else:
            cnt=[]

print(ans[0],ans[1],ans[2])

Submission status: Runtime Error

Solution code:
n=int(input())
li=[]
for i in range(n):
    x,y,h=map(int,input().split())
    li.append([x,y,h])
for j in range(0,101):
    for k in range(0,101):
        H=li[0][2]+abs(li[0][0]-j)+abs(li[0][1]-k)
        for l in range(1,n):
            if H!=li[l][2]+abs(li[l][0]-j)+abs(li[l][1]-k):
                break
            elif H==li[l][2]+abs(li[l][0]-j)+abs(li[l][1]-k) and l==n-1:
                ans=[j,k,H]

print(ans[0],ans[1],ans[2])

Submission status: Runtime Error

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    x=[]
    y=[]
    h=[]
    ans=[0,0,0]
    for _ in range(n):
        xx,yy,hh=inpm()
        x.append(xx)
        y.append(yy)
        h.append(hh)
    for xc in range(101):
        for yc in range(101):
            a=[]
            H=0
            for i in range(n):
                if i==n-1:
                    if h[i]==0:
                        if len(a)==0:
                            break
                        ans=[str(xc),str(yc),str(a[0])]
                        print(' '.join(ans))
                        return
                    d = abs(xc-x[i]) + abs(yc-y[i])
                    H = h[i]+d
                    if len(a)>0:
                        if H!=a[0]:
                            break
                        else:
                            print(' '.join(ans))
                            return
                    else:
                        ans=[str(xc),str(yc),str(H)]
                        print(' '.join(ans))
                        return
                if h[i]==0:
                    continue
                d = abs(xc-x[i]) + abs(yc-y[i])
                H=h[i]+d
                if len(a)>=1:
                    if H!=a[0]:
                        break
                else:
                    a.append(H)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    x=[]
    y=[]
    h=[]
    ans=[0,0,0]
    for _ in range(n):
        xx,yy,hh=inpm()
        x.append(xx)
        y.append(yy)
        h.append(hh)
    for xc in range(101):
        for yc in range(101):
            a=[]
            H=0
            for i in range(n):
                d = abs(xc-x[i]) + abs(yc-y[i])
                if h[i]==0:
                    continue
                H=h[i]+d
                if len(a)>=1:
                    if H!=a[0]:
                        break
                    elif i==n-1:
                        ans=[str(xc),str(yc),str(H)]
                        break
                else:
                    a.append(H)
    print(' '.join(ans))
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          center = False
          break
        k+=1
      if center==True:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      if temph<0:
        temph = 0
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2] and temph>0:
          center = False
          break
        k+=1
      if center==False:
        continue
      else:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==False:
        continue
      else:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
for i in range(0, 101):
  for j in range(0, 101):
    center = True
    temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
    k = 1
    while k<len(points):
      if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
        if points[k][2]==0:
          k+=1
          continue
        center = False
        break
      k+=1
    if center==False:
      continue
    else:
      cx = i
      cy = j
      h = temph
      break
print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Runtime Error

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
for i in range(1, 101):
  for j in range(1, 101):
    center = True
    temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
    k = 1
    while k<len(points):
      if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
        center = False
        break
      k+=1
    if center==False:
      continue
    else:
      cx = i
      cy = j
      h = temph
      break
print(str(cx) + ' ' + str(cy) + ' ' + str(h))