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:
W = 101

def solve(N, xyh):
    for yy in range(W):
        for xx in range(W):
            H = set()
            Z = 1e9
            for x, y, h in xyh:
                d = abs(xx - x) + abs(yy - y)
                if h > 0:
                    H.add(d + h)
                else:
                    Z = min(Z, d)
            if len(H) == 1:
                h = H.pop()
                if 0 < h <= Z:
                    return (xx, yy, h)

N = int(input())
xyh = [tuple(map(int, input().split())) for i in range(N)]
print(*solve(N, xyh))

Submission status: Runtime Error

Solution code:
W = 101

def solve(N, xyh):
    for yy in range(W):
        for xx in range(W):
            H = set()
            Z = W ** 2 # INF
            for x, y, h in xyh:
                d = abs(xx - x) + abs(yy - y)
                if h > 0:
                    H.add(d + h)
                else:
                    Z = min(Z, d)
            if len(H) == 1:
                h = H.pop()
                if h <= Z:
                    return (xx, yy, h)

N = int(input())
xyh = [tuple(map(int, input().split())) for i in range(N)]
print(*solve(N, xyh))

Submission status: Runtime Error

Solution code:
import sys
import itertools

cols = []
for line in sys.stdin:
  col = line.strip().split(' ')
  col = [int(c) for c in col]
  cols.append(col)

cols = cols[1:]
for cx,cy in itertools.product(list(range(101)), list(range(101))):
  H, H_max, flag = None, None, True
  for x,y,h in cols:
    if h <= 0:
      tmp_H_max = abs(x-cs) + abs(y-cy)
      if tmp_H_max < 1:
        flag = False
        break
      else:
        H_max = tmp_H_max if not H_max else min(H_max, tmp_H_max)
    else:
      tmp_H = h + abs(x-cx) + abs(y-cy)
      if not H:
        H = tmp_H
      if H and H != tmp_H:
        flag = False
        break
      if H_max and H_max < tmp_H:
        flag = False
        break
  if flag:
    print(cx,cy,H)

Submission status: Runtime Error

Solution code:
import sys
import itertools

cols = []
for line in sys.stdin:
  col = line.strip().split(' ')
  col = [int(c) for c in col]
  cols.append(col)

def calcH(cx, cy, x, y, h):
  if h > 0:
  	return h + abs(x-cx) + abs(y-cy)
  else:
    return h - abs(x-cs) - abs(y-cy) <= 0

cols = cols[1:]
for cx,cy in itertools.product(list(range(101)), list(range(101))):
  H = None
  flag = True
  for x,y,h in cols:
    now_H = calcH(cx, cy, x, y, h)
    if not H:
      flag = False
      break
    if H is None:
      H = now_H
    else:
      if not H == now_H:
        flag = False
        break
  if flag:
    print(cx,cy,H)

Submission status: Runtime Error

Solution code:
import sys
import itertools

def calcH(cx, cy, x, y, h):
  if h > 0:
  	return h - abs(x-cx) + abs(y-cy)
  else:
    return h - abs(x-cs) + abs(y-cy) <= 0

cols = []
for line in sys.stdin:
  col = line.strip().split(' ')
  col = [int(c) for c in col]
  cols.append(col)

cols = cols[1:]
for cx,cy in itertools.product(list(range(101)), list(range(101))):
  H = None
  flag = True
  for x,y,h in cols:
    now_H = calcH(cx, cy, x, y, h)
    if H is False:
      flag = False
      break
    if H is None:
      H = now_H
    else:
      if not H == now_H:
        flag = False
        break
  if flag:
    print(cx,cy,H)

Submission status: Runtime Error

Solution code:
N = int(input())
x=[]
y=[]
h=[]

for i in range(N):
    xb,yb,hb=map(int,input().split())
    if hb!=0:
        x.append(xb)
        y.append(yb)
        h.append(hb)

for cx in range(101):
    for cy in range(101):
        top=h[0]+abs(cx-x[0])+abs(cy-y[0])
        isTop=True
        for i in range(1,N):
            if top-abs(cx-x[i])-abs(cy-y[i])!=h[i]:
                isTop=False
                break
        if isTop:
            print(cx,cy,top)

Submission status: Runtime Error

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        continue
    XYHA.append([x,y,h])
    
for i in range(101):
    for j in range(101):
        HC = XYHA[0][2] + abs(XYHA[0][0] - i) + abs(XYHA[0][1] - j)
        for k in range(1, len(XYHA)):

            H = XYHA[k][2] + abs(XYHA[k][0] - i) + abs(XYHA[k][1] - j)

            if HC != H:
                break
            elif k == len(XYHA) - 1:
                print(i,j,HC)
                exit()
print(info[0][0],info[0][1],info[0][2])

Submission status: Runtime Error

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):

    BBBB = input().split(" ")

    if BBBB[2] == '0':
        continue

    XYHA.append(BBBB)

HC = 0

for i in range(101):
    for j in range(101):
        OKFLG = True
        HC = 0
        for k in range(len(XYHA)):

            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

Submission status: Runtime Error

Solution code:
N = int(input())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

HC = 0
CX = 0
CY = 0
OKFLG = True

for i in range(101):
    for j in range(101):
        HC = 0
        OKFLG = True
        for k in range(N+1):
            XYH = XYHA[k]
            H = int(XYH[2]) + abs(int(XYH[0]) - i) + abs(int(XYH[1]) - j)
            if HC == 0:
                HC = H
                CX = i
                CY = j
                continue
            
            if HC == H:
                continue
            else:
                OKFLG = False
                break

        if OKFLG:
            break
    if OKFLG:
        break


print(CX,CY,HC)

Submission status: Runtime Error

Solution code:
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                print(i,j,H_0)
                exit()
print(info[0],info[1],info[2])

Submission status: Runtime Error

Solution code:
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                print(i,j,H_0)
                exit()
print(e[0],e[1],e[2])

Submission status: Runtime Error

Solution code:
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            if info[k][2] == 0:
                continue
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                ans = [i,j,H_0]
print(" ".join([str(e) for e in ans]))

Submission status: Runtime Error

Solution code:
N = int(input().strip())

xyh = []
for _ in range(N):
  x, y, h = map(int, input().strip().split())
  if h != 0:
    xyh.append((x, y, h))

for k in range(N):
  for i in range(101):
    for j in range(101):
      H = xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1])
      is_h = True
      for _xyh in xyh:
        if H != _xyh[2] + abs(i-_xyh[0]) + abs(j-_xyh[1]):
          is_h = False
          break
      if is_h:
        mx, my, mh = i, j, H

print(mx, my, mh)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
X, Y, H_m = zip(*[tuple(map(int,input().split())) for _  in range(N)])
X, Y, H_m = map(np.array,[X,Y,H])

def height(X,Y,Cx,Cy,H):
    tmp = H - np.abs(X - Cx) - np.abs(Y - Cy)
    tmp[tmp <= 0] = 0
    return tmp

break_flg = False
for cx in range(1,101):
    for cy in range(1,101):
        H_c = 0
        while True:
            diff = H_m - height(X,Y,cx,cy,H_c)
            flgs_n = diff < 0
            flgs_e = diff == 0
            if all(flgs_e):
                break_flg = True
                break
            if any(flgs_n): break
            H_c += 1
        if break_flg:
            break
    if break_flg:
        break

print(" ".join(map(str,[cx,cy,H_c])))

Submission status: Runtime Error

Solution code:
N = int(input())
X, Y, H_m = zip(*[tuple(map(int,input().split())) for _  in range(N)])
X, Y, H_m = map(np.array,[X,Y,H])

def height(X,Y,Cx,Cy,H):
    tmp = H - np.abs(X - Cx) - np.abs(Y - Cy)
    tmp[tmp <= 0] = 0
    return tmp

break_flg = False
for cx in range(1,101):
    for cy in range(1,101):
        H_c = 0
        while True:
            diff = H_m - height(X,Y,cx,cy,H_c)
            flgs_n = diff < 0
            flgs_e = diff == 0
            if all(flgs_e):
                break_flg = True
                break
            if any(flgs_n): break
            H_c += 1
        if break_flg:
            break
    if break_flg:
        break

print(" ".join(map(str,[cx,cy,H_c])))

Submission status: Runtime Error

Solution code:
import sys
import itertools

def calcH(cx, cy, x, y, h):
  if h > 0:
  	return h + abs(x-cx) + abs(y-cy)
  else:
    return h - abs(x-cs) + abs(y-cy) <= 0

cols = []
for line in sys.stdin:
  col = line.strip().split(' ')
  col = [int(c) for c in col]
  cols.append(col)

cols = cols[1:]
for cx,cy in itertools.product(list(range(101)), list(range(101))):
  H = None
  flag = True
  for x,y,h in cols:
    now_H = calcH(cx, cy, x, y, h)
    if H is False:
      flag = False
      break
    if H is None:
      H = now_H
    else:
      if not H == now_H:
        flag = False
        break
  if flag:
    print(cx,cy,H)

Submission status: Runtime Error

Solution code:
n = (int)(input())

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        tmp.remove(0)
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()

Submission status: Runtime Error

Solution code:
n = (int)(input())

x = []
y = []
h = []

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        tmp.rempe(0)
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()

Submission status: Runtime Error

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
for i in range(n):
  if x[i][2]> 0:
    y=x

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,y[0][0],y[0][1],y[0][2])==hight(k,l,y[i][0],y[i][1],y[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,y[0][0],y[0][1],y[0][2])

print(ans1,ans2,ans3)

Submission status: Runtime Error

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
for i in range(n):
  if x[i][2]> 0:
    y=x

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[0][0],x[0][1],x[0][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[0][0],x[0][1],x[0][2])

print(ans1,ans2,ans3)

Submission status: Runtime Error

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)

x.reverse()

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[0][0],x[0][1],x[0][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[0][0],x[0][1],x[0][2])

print(ans1,ans2,ans3)

Submission status: Runtime Error

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[-1][0],x[-1][1],x[-1][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[-1][0],x[-1][1],x[-1][2])

print(ans1,ans2,ans3)

Submission status: Runtime Error

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
      
#print(x)

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[0][0],x[0][1],x[0][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[0][0],x[0][1],x[0][2])

print(ans1,ans2,ans3)

Submission status: Runtime Error

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

N = int(input())
x = [None] * N
y = [None] * N
h = [None] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())


def distance(a,b):
    a_x = a[0]
    a_y = a[1]
    b_x = b[0]
    b_y = b[1]

    return abs(a_x - b_x) + abs(a_y - b_y)


for cx in range(101):
    for cy in range(101):
        ans = True
        c = [cx, cy]
        for i in range(N):
            if h[i] != 0:
                ch = distance(c, [x[i], y[i]]) + h[i]
                break
        x.pop(i)
        y.pop(i)
        h.pop(i)
        # ch = distance(c, [x[0], y[0]]) + h[0]  # cx, cyを仮定するとchが定まる
        for i in range(1, N):
            if ch - distance(c, [x[i], y[i]]) != h[i]:
                ans = False
                break
        if ans:
            break
    if ans:
        break

print(" ".join(list(map(str, [cx, cy, ch]))))

Submission status: Runtime Error

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


def isvalid(i, j):
    p, q, h = query[0]
    H = h + abs(p - i) + abs(q - j)
    if H < 1:
        return -1
    for que in query[1:]:
        p, q, h = que
        if h != max(H - abs(p - i) - abs(q - j)):
            return -1
    return H


for i in range(101):
    for j in range(101):
        H = isvalid(i, j)
        if H != -1:
            print(i, j, H)
            exit()

Submission status: Runtime Error

Solution code:
i = lambda: list(map(int, input().split()))
N, = i()
M = [i() for j in range(N)]
H = 0
for k in range(101):
    if M[i][2] != 0:
        H = abs(M[0][0] - Cx) + abs(M[0][1] - Cy) + M[0][2]
        break
for Cx in range(101):
    for Cy in range(101):
        if all([False for d in M if H != abs(d[0] - Cx) + abs(d[1] - Cy) + d[2]]):
            print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

t = []

for x in range(101):
    for y in range(101):
        H = []
        for i in array:
            if i[2] > 0:
                H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            t.append([x,y,H])

t = []

if len(t) >=2:
    for x in range(101):
        for y in range(101):
            H = []
            for i in array:
                if True:
                    H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                    H.append(H_i)
            Hset = set(H)
            H = list(Hset)[0]
            if(len(Hset)==1 and H>=0):
                t.append([x,y,H])
            
print("{0[0]} {0[1]} {0[2]}".format(t[0]))

Submission status: Runtime Error

Solution code:
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

t = []

for x in range(101):
    for y in range(101):
        H = []
        for i in array:
            if i[2] > 0:
                H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            t.append([x,y,H])

if len(t) >=2:
    x = 15/0
            
print("{0[0]} {0[1]} {0[2]}".format(t[0]))

Submission status: Runtime Error

Solution code:
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

t = []

for x in range(101):
    for y in range(101):
        H = []
        for i in array:
            if i[2] > 0:
                H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
                H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            t.append([x,y,H])

if len(t) >=2:
    x = 15/0
            
print("{0[0]} {0[1]} {0[2]}".format(t))

Submission status: Runtime Error

Solution code:
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

for x in range(101):
    for y in range(101):
        H=[]
        for i in array:
            H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
            H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            test.append(H)
            # print(x,y,H)
            
if(len(test)==0):
    print(5/0)
else:
    print(x,y,H)

Submission status: Runtime Error

Solution code:
N = int(input())

array = []

for i in range(N):
    array.append(list(map(int,input().split())))

test = []

for x in range(101):
    for y in range(101):
        H=[]
        for i in array:
            H_i = max(abs(i[0]-x)+abs(i[1]-y)+i[2],0)
            H.append(H_i)
        Hset = set(H)
        H = list(Hset)[0]
        if(len(Hset)==1 and H>=0):
            test.append(H)
            # print(x,y,H)
            
if(len(test)!=1):
    print(5/0)
else:
    print(x,y,H)

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 2:
	c_x, c_y, H = map(int, input().split())
	x_2, y_2, h_2 = map(int, input().split())
	if H < h_2:
		c_x = x_2
		c_y = y_2

else:
	temp_list = []
	for i in range(N):
		x_i, y_i, h_i = map(int, input().split())

		temp_list.append([x_i, y_i, h_i])

	c_x = -1
	c_y = -1

	c_list = []
	for i in range(101):
		for j in range(101):
			if max(temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)), 0) == max(temp_list[1][2] + (abs(temp_list[1][0]-i) + abs(temp_list[1][1]-j)), 0):
				c_list.append([i, j, max(temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)), 0)])

	for a in range(2, len(temp_list)):
		del_list = []
		for i, j, H in c_list:
			if H != max(temp_list[a][2] + (abs(temp_list[a][0]-i) + abs(temp_list[a][1]-j)), 0):
				del_list.append([i, j, H])
		for i in range(len(del_list)):
			c_list.remove(del_list[i])
		if len(c_list)==1:
			c_x = c_list[0][0]
			c_y = c_list[0][1]
			H = c_list[0][2]
			break

print("{0} {1} {2}".format(c_x, c_y, H))

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 1:
	c_x = -1
	c_y = -1
	H = 0

elif N == 2:
	c_x, c_y, H = map(int, input().split())
	x_2, y_2, h_2 = map(int, input().split())
	if H < h_2:
		c_x = x_2
		c_y = y_2

else:
	temp_list = []
	for i in range(N):
		x_i, y_i, h_i = map(int, input().split())

		if h_i != 0:
			temp_list.append([x_i, y_i, h_i])

		if len(temp_list)>3:
			break

	c_x = -1
	c_y = -1

	for i in range(101):
		for j in range(101):
			if temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)) == temp_list[1][2] + (abs(temp_list[1][0]-i) + abs(temp_list[1][1]-j)):
				if temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)) == temp_list[2][2] + (abs(temp_list[2][0]-i) + abs(temp_list[2][1]-j)):
					c_x = i
					c_y = j
					H = temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j))
					break
		if c_x >= 0:
			break

print("{0} {1} {2}".format(c_x, c_y, H))

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 2:
	c_x, c_y, H = map(int, input().split())
	x_2, y_2, h_2 = map(int, input().split())
	if H < h_2:
		c_x = x_2
		c_y = y_2

else:
	temp_list = []
	for i in range(N):
		x_i, y_i, h_i = map(int, input().split())

		if h_i != 0:
			temp_list.append([x_i, y_i, h_i])

		if len(temp_list)>3:
			break

	c_x = -1
	c_y = -1

	for i in range(101):
		for j in range(101):
			if temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)) == temp_list[1][2] + (abs(temp_list[1][0]-i) + abs(temp_list[1][1]-j)):
				if temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)) == temp_list[2][2] + (abs(temp_list[2][0]-i) + abs(temp_list[2][1]-j)):
					c_x = i
					c_y = j
					H = temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j))
					break
		if c_x >= 0:
			break

print("{0} {1} {2}".format(c_x, c_y, H))

Submission status: Runtime Error

Solution code:
N = int(input())

if N == 2:
	c_x, c_y, H = map(int, input().split())
	x_2, y_2, h_2 = map(int, input().split())
	if H < h_2:
		c_x = x_2
		c_y = y_2

else:
	temp_list = []
	for i in range(N):
		x_i, y_i, h_i = map(int, input().split())

		if h_i != 0:
			temp_list.append([x_i, y_i, h_i])

		if len(temp_list)>2:
			break

	c_x = -1
	c_y = -1

	for i in range(101):
		for j in range(101):
			if temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)) == temp_list[1][2] + (abs(temp_list[1][0]-i) + abs(temp_list[1][1]-j)):
				if temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j)) == temp_list[2][2] + (abs(temp_list[2][0]-i) + abs(temp_list[2][1]-j)):
					c_x = i
					c_y = j
					H = temp_list[0][2] + (abs(temp_list[0][0]-i) + abs(temp_list[0][1]-j))
					break
		if c_x >= 0:
			break

print("{0} {1} {2}".format(c_x, c_y, H))

Submission status: Runtime Error

Solution code:
data = [map(int, raw_input().split()) for _ in range(input())]
 
for cx, cy in ((cx, cy) for cx in range(101) for cy in range(101)):
    s = set(abs(cx - x) + abs(cy - y) + h for x, y, h in data if h != 0)
    if len(s) == 1:
        ch = s.pop()
        if cx == 0 or cx == 100 or cy == 0 or cy == 100:
            raise Exception
        print cx, cy, ch
        break

Submission status: Runtime Error

Solution code:
raise Exception

Submission status: Runtime Error

Solution code:
n = int(input())

l = []
for i in range(n):
    x,y,h = map(int,input().split())
    if h > 0 :
        l.append([x,y,h])

for cx in range(100+1):
    for cy in range(100+1):
              
        count = 0
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for i in range(n):            
            height = abs(l[i][0]-cx) + abs(l[i][1]-cy) + l[i][2] 
            if preheight != height:
                break

            count = count + 1

        if count >= len(l) :
            print(cx,cy,preheight)
            exit(0)

Submission status: Runtime Error

Solution code:
N = int(input())

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

if n == 1:
	x, y, h = xyhs[0]
	print(cx, cy, h)
	exit()

for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)

		for xyh in xyhs[1:]:
			x, y, h = xyh
			if H != h + abs(x - cx) + abs(y - cy):
				break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

Submission status: Runtime Error

Solution code:
N = int(input())

xyhs = []
for n in range(N):
	x, y, h = map(int, input().split())
	xyhs.append((x,y,h))

if n == 1:
	x, y, h = xyhs[0]
	print(cx, cy, H)
	exit()
			
for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)

		for xyh in xyhs[1:]:
			x, y, h = xyh
			if H != h + abs(x - cx) + abs(y - cy):
				break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

Submission status: Runtime Error

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

if N == 1:
    Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]

elif N == 2:
    if xyh[0][2] > xyh[1][2]:
        Cx, Cy, H = xyh[0][0], xyh[0][1], xyh[0][2]
    else:
        Cx, Cy, H = xyh[1][0], xyh[1][1], xyh[1][2]

else:
    flag = False
    for i in range(101):
        for j in range(101):
            sampleH = xyh[0][2] + abs(i-xyh[0][0]) + abs(j-xyh[0][1])
            for k in range(1, N):
                flag = True
                if xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1]) != sampleH:
                    flag = False
                    break
            if flag:
                Cx, Cy, H = i, j, sampleH
                break
        if flag:
            break

print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            ll = []
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h == 0:
                    ll.append(list(x,y,h))
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == len(l) - 1:
                    for xx,yy,hh, in ll:
                        if hh != max((H - abs(xx-cx) - abs(yy-cy)), 0):
                            break
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            ll = []
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h == 0:
                    ll.append(list(x,y,h))
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == len(l) - 1:
                    for x,y,h in ll:
                        if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                            break
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())

    l = []
    for i in range(n):
        l.append(list(map(int, input().split())))

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h < 0:
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    continue
                if H < 1 or H != int(H) or (h > 0 and h != H - abs(x-cx) - abs(y-cy) or (h = 0 and h > H - abs(x-cx) - abs(y-cy))):
                    break
                if i == len(l) - 1:
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from math import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = sorted(all_input_list, key=lambda x: x[2])[-1]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(1)

Submission status: Runtime Error

Solution code:
from math import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
all_input_list.sort(key=lambda x: x[2])
x,y,h = all_input_list[-1]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(1)