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:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  else:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Runtime Error

Solution code:
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]

ans = ''
not0_points = [p for p in points if p[2]!=0]
if len(not0_points)==1:
    ans = map(str, not0_points[0])

for cx in range(101):
    if ans: break
    for cy in range(101):
        if ans: break
        H = h+abs(x-cx)+abs(y-cy)
        if all([max(H-abs(p[0]-cx)-abs(p[1]-cy),0)==p[2] for p in points]):
            ans = map(str, [cx,cy,H])

print(' '.join(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]

def peak_height(x,y,h,cx,cy):
    peak = max(h + abs(x-cx) + abs(y-cy), 0)
    return peak

not0_points = [p for p in points if p[2]!=0]
if len(not0_points)==1:
    ans = map(str, not0_points[0])

for cx in range(101):
    if ans: break
    for cy in range(101):
        if ans: break
        peaks = []
        ans = ''
        for x,y,h in points:
            peaks.append(peak_height(x,y,h,cx,cy))
        if len(set(peaks)-set([0]))==1:
            ans = map(str, [cx,cy,max(peaks)])

print(' '.join(ans))

Submission status: Runtime Error

Solution code:

def peak_height(x,y,h,cx,cy):
    peak = max(h + abs(x-cx) + abs(y-cy), 0)
    return peak

for cx in range(3):
    for cy in range(3):
        peaks = []
        ans = ''
        for x,y,h in points:
            peaks.append(peak_height(x,y,h,cx,cy))
        if len(set(peaks)-set([0]))==1:
            ans = map(str, [cx,cy,max(peaks)])
        if ans: break
    if ans: break

print(' '.join(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]

def peak_height(x,y,h,cx,cy):
    peak = max(h + abs(x-cx) + abs(y-cy), 0)
    return peak

for cx in range(3):
    for cy in range(3):
        peaks = []
        ans = ''
        for x,y,h in points:
            peaks.append(peak_height(x,y,h,cx,cy))
        if len(set(peaks)-set([0]))==1:
            ans = f'{cx} {cy} {max(peaks)}'
        if ans: break
    if ans: break
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1 and max(h0) <= max(hc):
            print(x, y, list(hc)[0])
            break

Submission status: Runtime Error

Solution code:
N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi in range(101):
    for cyi in range(101):
        for k in range(N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

        for k in range(N):
            if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0)
                break
        
        else:
            print(cxi, cyi, hight)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for (cxi, cyi) in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for k in range(N):
        if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0)
            break
    
    else:
        print(cxi, cyi, hight)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi, cyi in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for k in range(N):
        if params[k][2] != max((hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi)), 0)
            break
    
    else:
        print(cxi, cyi, hight)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi, cyi in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for k in range(N):
        if params[k][2] != max(hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi), 0)
            break
    
    else:
        print(cxi, cyi, hight)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi, cyi in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for k in range(N):
        if params[k][2] != max(h - abs(params[k][0] - cxi) - abs(params[k][1] - cyi), 0)
            break
    
    else:
        print(cxi, cyi, hight)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi, cyi in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for i in range(N):
        if params[i][2] != max(h - abs(params[k][0] - cxi) - abs(params[k][1] - cyi), 0)
            break
    
    else:
        print(cxi, cyi, hight)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi, cyi in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for i in range(N):
        if params[i][2] != max(h - abs(params[k][0] - cxi) - abs(params[k][1] - cyi), 0)
            break
    
    else:
        Cx = cxi
        Cy = cyi
        H = hight
        print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

#if len(params) == 1:
#    print(*params[0])

#else:

#Cx, Cy, H = 0, 0, 0
for cxi, cyi in itertools.product(range(101), range(101)):
    hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)

    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

            if hight < 1:
                break
            else:
                if hight != hight_:
                    break
                else:
                    hight_ = hight
                    continue

        #elif params[k][2] == 0:
        #    if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
        #        break
    
    else:
        Cx = cxi
        Cy = cyi
        H = hight
    
    continue

print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

#if len(params) == 1:
#    print(*params[0])

#else:

#Cx, Cy, H = 0, 0, 0
for cxi, cyi in itertools.product(range(101), range(101)):
    hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)

    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

            if hight < 1:
                break
            else:
                if hight != hight_:
                    break
                else:
                    hight_ = hight

        elif params[k][2] == 0:
            if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
                break
    
    else:
        Cx = cxi
        Cy = cyi
        H = hight
    continue

print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

#if len(params) == 1:
#    print(*params[0])

#else:

#Cx, Cy, H = 0, 0, 0
for cxi, cyi in itertools.product(range(101), range(101)):
    hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)

    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

            if hight < 1:
                break
            else:
                if hight != hight_:
                    break
                else:
                    hight_ = hight

        #elif params[k][2] == 0:
        #    if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
        #        break
    
    else:
        Cx = cxi
        Cy = cyi
        H = hight
    continue

print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

#if len(params) == 1:
#    print(*params[0])

#else:

#Cx, Cy, H = 0, 0, 0
for cxi, cyi in itertools.product(range(101), range(101)):
    hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)

    for k in range(1, N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

            if hight < 1:
                break
            else:
                if hight != hight_:
                    break
                else:
                    hight_ = hight

        #elif params[k][2] == 0:
        #    if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
        #        break
    
    else:
        Cx = cxi
        Cy = cyi
        H = hight
    continue

print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

if len(params) == 1:
    print(*params[0])

else:

    #Cx, Cy, H = 0, 0, 0
    for cxi, cyi in itertools.product(range(101), range(101)):
        hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)

        for k in range(1, N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

                if hight < 1:
                    break
                else:
                    if hight != hight_:
                        break
                    else:
                        hight_ = hight

            #elif params[k][2] == 0:
            #    if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
            #        break

        else:
            Cx = cxi
            Cy = cyi
            H = hight
        continue

    print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

if len(params) == 1:
    print(*params[0])

else:

    #Cx, Cy, H = 0, 0, 0
    for cxi, cyi in itertools.product(range(101), range(101)):
        hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)

        #counter = 0
        for k in range(1, N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)
                #if counter == 0:
                #    hight_ = hight
                #counter += 1

                if hight < 1:
                    break
                else:
                    if hight != hight_:
                        break
                    else:
                        hight_ = hight
            elif params[k][2] == 0:
                if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
                    break

        else:
            Cx = cxi
            Cy = cyi
            H = hight
        continue

    print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

import itertools

for cxi, cyi in itertools.product(range(101), range(101)):
    counter = 0
    for x, y, h in params:
        hight = h + abs(x - cxi) + abs(y - cyi)
        if counter == 0:
            hight_ = hight
        counter += 1

        if hight < 1:
            break
        else:
            if hight != hight_:
                break
            else:
                hight_ = hight

    else:
        Cx = cxi
        Cy = cyi
        H = hight
    continue

print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())


def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[0])+abs(yy-y[0])+h[0]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) != h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Submission status: Runtime Error

Solution code:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())


def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[0])+abs(yy-y[0])+h[0]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) is not h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Submission status: Runtime Error

Solution code:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
hi = 0
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())
  if h[n] > 0:
    hi = n

def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[hi])+abs(yy-y[hi])+h[hi]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) is not h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Submission status: Runtime Error

Solution code:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())
  if h[n] > 0:
    hi = n

def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[hi])+abs(yy-y[hi])+h[hi]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) is not h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Submission status: Runtime Error

Solution code:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())

def f():
  for xx in range(101):
    for yy in range(101):
      height = []
      for n in range(N):
        height.append(abs(x[n]-xx)+abs(y[n]-yy)+h[n])
      if len(set(height)) == 1:
        return [xx, yy, height[0]]
print(*f())

Submission status: Runtime Error

Solution code:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())

def f():
  for xx in range(101):
    for yy in range(101):
      height = [-1 for _ in range(N)]
      for n in range(N):
        height[n]= abs(x[n]-xx)+abs(y[n]-yy)+h[n]
        if set(height[:n+1]) == {}:
          break
      if len(set(height)) == 1:
        return [xx, yy, height[0]]
print(*f())

Submission status: Runtime Error

Solution code:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())

def f():
  for xx in range(101):
    for yy in range(101):
      height = [0 for _ in range(N)]
      for n in range(N):
        height[n]= abs(x[n]-xx)+abs(y[n]-yy)+h[n]
      if len(set(height)) == 1:
        return [xx, yy,height[0]]
print(*f())

Submission status: Runtime Error

Solution code:
N=int(input())
xyh=[]
for i in range(N):
  xyh.append(list(map(int,input().split())))
def height(x,y,h,Cx,Cy,):
  height=h+abs(x-Cx)+abs(y-Cy)
  return height
def find(N):
  for Cx in range(101):
    for Cy in range(101):
      Height=height(xyh[0][0],xyh[0][1],xyh[0][2],Cx,Cy)
      for i in range(1,N):
        Height_=height(xyh[i][0],xyh[i][1],xyh[i][2],Cx,Cy)
        if Height==Height_:
          if i==N-1:
            return (Cx,Cy,Height)
          continue
        else:
          break
Cx,Cy,H=find(N)
print(Cx,"",Cy," ",H)

Submission status: Runtime Error

Solution code:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

Submission status: Runtime Error

Solution code:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]


for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
      
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

Submission status: Runtime Error

Solution code:
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]
print(xyh)

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        print(height)
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

Submission status: Runtime Error

Solution code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]


for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) < 0:
                    flag = 0
                    break
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)

Submission status: Runtime Error

Solution code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

L.sort(key=lambda x:x[2])

for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) < 0:
                    flag = 0
                    break
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)

Submission status: Runtime Error

Solution code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

L.sort(key=lambda x:x[2])

for x in range(101):
    for y in range(101):
        h = L[-1][2] + abs(x-L[-1][0]) + abs(y-L[-1][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) > 0:
                    flag = 0
                    break
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)

Submission status: Runtime Error

Solution code:
from operator import itemgetter

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

L.sort(key=itemgetter(2))

for x in range(101):
    for y in range(101):
        h = L[0][2] + abs(x-L[0][0]) + abs(y-L[0][1])
        for l in L: 
            if l[2] == 0:
                if h - (abs(x-l[0]) + abs(y-l[1])) > 0:
                    flag = 0
                    break
            else:
                if h == -1:
                    tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
                h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
                if tmp == h:
                    flag = 1
                    tmp = h
                else:
                    flag = 0
                    break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
print(gx, gy, gh)

Submission status: Runtime Error

Solution code:
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

for x in range(101):
    for y in range(101):
        h = -1
        for l in L:

            if h == -1:
                tmp = l[2] + abs(x-l[0]) + abs(y-l[1])
            h = l[2] + abs(x-l[0]) + abs(y-l[1])
                
            if tmp == h:
                flag = 1
                tmp = h
            else:
                flag = 0
                break
                
                
        if flag == 1:
            gx = x
            gy = y
            gh = h
            break
                
                    
    if flag == 1:
        break
        
if h == -1:
    print(L[0][0], L[0][1], 0)
else:
    print(gx, gy, gh)

Submission status: Runtime Error

Solution code:
#prdさんから参照
N = int(input())
#これが唯一の事実データ
src = [tuple(map(int,input().split())) for i in range(N)]
 
INF = float('inf')
#ここ以降でかかれてあるcx,cyはあくまで頂上であると仮定しているだけで条件と合わない場合に不適切な座標となる。
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
#                 if tmph > maxh:
#                     break
            else:
                #ここでmaxhがtmphよりも小さくなってしまった場合、hは0だから頂点からのxとyの差の和がtmphはなければならないのに、それを下回っているため
                #データx,yは絶対的な値なのでcx,cyが間違っていることになる。それを判定するのが上のtmph > maxh の時となり
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
                #最低でも1つはピラミッド内の座標がないと解けないのでここはいらない？
#                 if maxh == 1:
#                     tmph = 1
                if tmph > maxh:
                    break
        else:
            for x,y,h in src:
                if max(tmph - abs(x-cx) - abs(y-cy), 0) != h:
                    break
            else:
                print(cx,cy,tmph)
                exit()

Submission status: Runtime Error

Solution code:
#prdさんから参照
N = int(input())
#これが唯一の事実データ
src = [tuple(map(int,input().split())) for i in range(N)]
 
INF = float('inf')
#ここ以降でかかれてあるcx,cyはあくまで頂上であると仮定しているだけで条件と合わない場合に不適切な座標となる。
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
#                 if tmph > maxh:
#                     break
            else:
                #ここでmaxhがtmphよりも小さくなってしまった場合、hは0だから頂点からのxとyの差の和がtmphはなければならないのに、それを下回っているため
                #データx,yは絶対的な値なのでcx,cyが間違っていることになる。それを判定するのが上のtmph > maxh の時となり
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
                #最低でも1つはピラミッド内の座標がないと解けないのでここはいらない？
#                 if maxh == 1:
#                     tmph = 1
                if tmph > maxh:
                    break
        else:
            
#             for x,y,h in src:
#                 if max(tmph - abs(x-cx) - abs(y-cy), 0) != h:
#                     break
#             else:
            print(cx,cy,tmph)
            exit()

Submission status: Runtime Error

Solution code:
#prdさんから参照
N = int(input())
#これが唯一の事実データ
src = [tuple(map(int,input().split())) for i in range(N)]
 
INF = float('inf')
#ここ以降でかかれてあるcx,cyはあくまで頂上であると仮定しているだけで条件と合わない場合に不適切な座標となる。
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
#                 if tmph > maxh:
#                     break
            else:
                #ここでmaxhがtmphよりも小さくなってしまった場合、hは0だから頂点からのxとyの差の和がtmphはなければならないのに、それを下回っているため
                #データx,yは絶対的な値なのでcx,cyが間違っていることになる。それを判定するのが上のtmph > maxh の時となり
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
                #最低でも1つはピラミッド内の座標がないと解けないのでここはいらない？
#                 if maxh == 1:
#                     tmph = 1
                 if tmph > maxh:
                    break
        else:
#             for x,y,h in src:
#                 if max(tmph - abs(x-cx) - abs(y-cy), 0) != h:
#                     break
#             else:
            print(cx,cy,tmph)
            exit()

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
x = []
y = []
h = []
for i in range(n):
    tx, ty, th = map(int, input().split())
    if th != 0:
        x.append(tx)
        y.append(ty)
        h.append(th)
x = np.array(x)
y = np.array(y)
h = np.array(h)
else:
    for cx in range(0,101):
        for cy in range(0,101):
            tmp = h + np.abs(x - cx) + np.abs(y - cy)
            if np.max(tmp) == np.min(tmp):
                print(cx, cy, np.max(tmp))

Submission status: Runtime Error

Solution code:
n=int(input())
xyh=[]
for i in range(n):
    xyh.append(list(map(int,input().split(" "))))
for i in range(n):
    if xyh[i][2]==0:
        xyh.remove(xyh[i])
    else:
        pass
    
if len(xyh)==1:
    print("{} {} {}".format(xyh[0][0],xyh[0][1],xyh[0][2]))
else:
    cx=0
    while cx<=100:
        cy=0
        while cy<=100:
            i=0
            while  i<=len(xyh)-2:
                if abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2]-abs(cx-xyh[i+1][0])-abs(cy-xyh[i+1][1])-xyh[i+1][2]==0:
                    i+=1
                else:
                    break
                
                if i==len(xyh)-1:
                    print("{} {} {}".format(cx,cy,abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]))
            cy+=1
        cx+=1

Submission status: Runtime Error

Solution code:
n=int(input())
xyh=[]
for i in range(n):
    xyh.append(list(map(int,input().split(" "))))
for i in range(n):
    if xyh[i][2]==0:
        xyh.remove(xyh[i])
    else:
        pass
    
if len(xyh)==1:
    print("{} {} {}".format(cx,cy,abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]))
else:
    cx=0
    while cx<=100:
        cy=0
        while cy<=100:
            i=0
            while  i<=len(xyh)-2:
                if abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2]-abs(cx-xyh[i+1][0])-abs(cy-xyh[i+1][1])-xyh[i+1][2]==0:
                    i+=1
                else:
                    break
                
                if i==len(xyh)-1:
                    print("{} {} {}".format(cx,cy,abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]))
            cy+=1
        cx+=1