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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())

Info = [[] for T in range(0,N)]
for I in range(0,N):
    Info[I] = [int(T) for T in input().split()]
Info = sorted(Info,reverse=True,key=lambda X:X[2])

for CX in range(0,101):
    for CY in range(0,101):
        Flag  = True
        BaseH = abs(Info[0][0]-CX)+abs(Info[0][1]-CY)+Info[0][2]
        for I in range(1,N):
            if BaseH-abs(Info[I][0]-CX)-abs(Info[I][1]-CY)!=Info[I][2]:
                Flag = False
                break
        if Flag:
            Ans = [str(CX),str(CY),str(BaseH)]
            break
    if Flag:
        break
print(' '.join(Ans))

Submission status: Runtime Error

Solution code:
N=int(input())
coor = [tuple(map(int,input().split())) for _ in range(N)]
coor = sorted(coor, key=lambda x:x[2])

def binary_search(func, array, left=0, right=-1):
    if right==-1:right=len(array)-1
    y_left, y_right = func(array[left]), func(array[right])
    while True:
        middle = (left+right)//2
        y_middle = func(array[middle])
        if y_left==y_middle: left=middle
        else: right=middle
        if right-left==1:break

    return left

idx = binary_search(lambda x:x[2]<1,coor)
if idx <= N-3:
  coor = coor[idx+1:]

def dist(coor1,coor2):
  return abs(coor2[0]-coor1[0])+abs(coor2[1]-coor1[1])

hs = []
for x in range(101):
  for y in range(101):
    h = [coor[i][2]+dist((x,y),(coor[i][0],coor[i][1])) for i in range(N)]
    if len(set(h))==1 and h[0] != 0:
      hs.append((x,y,h[0]))
      
hs = sorted(hs,key=lambda x:x[2])
print(*(hs[-1]))

Submission status: Runtime Error

Solution code:
N=int(input())
coor = [tuple(map(int,input().split())) for _ in range(N)]
coor = sorted(coor, key=lambda x:x[2])

def dist(coor1,coor2):
  return abs(coor2[0]-coor1[0])+abs(coor2[1]-coor1[1])

hs = []
for x in range(101):
  for y in range(101):
    h = [coor[i][2]+dist((x,y),(coor[i][0],coor[i][1])) for i in range(N)]
    if len(set(h))==1 and h[0] != 0:
      hs.append((x,y,h[0]))
      
hs = sorted(hs,key=lambda x:x[2])
print(*(hs[-1]))

Submission status: Runtime Error

Solution code:
N=int(input())
coor = [tuple(map(int,input().split())) for _ in range(N)]
coor = sorted(coor, key=lambda x:x[2])

def dist(coor1,coor2):
  return abs(coor2[0]-coor1[0])+abs(coor2[1]-coor1[1])

hs = []
for x in range(101):
  for y in range(101):
    h = [coor[i][2]+dist((x,y),coor[i]) for i in range(N)]
    if len(set(h))==1 and h[0] != 0:
      hs.append((x,y,h[0]))
      
hs = sorted(hs,key=lambda x:x[2])
print(*(hs[-1]))

Submission status: Runtime Error

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

for cx in range(101):
    for cy in range(101):
        flag = True
        tmpH = 0
        for i in range(N):
            X = xyh[i][0]
            Y = xyh[i][1]
            h = xyh[i][2]
            if i == 0:
                tmpH = abs(X-cx) + abs(Y-cy) + h
            else:
                if tmpH != abs(X-cx) + abs(Y-cy) + h:
                    flag = False
        if flag:
            answer_cx = cx
            answer_cy = cy
            answer_h = tmpH
            answer_string = str(cx) + " " + str(cy) + " " + str(tmpH)
            break
print(answer_string)

Submission status: Runtime Error

Solution code:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
x1, y1, h1 = XYH[0]
# print(x1, y1, h1)

for Cx in range(101):
    for Cy in range(101):
        H = h1 + abs(x1-Cx) + abs(y1-Cy)
        # print(Cx, Cy, H)
        if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in XYH:
            print(Cx, Cy, H)
            exit()

Submission status: Runtime Error

Solution code:
# abc112_c.py
# https://atcoder.jp/contests/abc112/tasks/abc112_c

# C - Pyramid /
# 実行時間制限: 3 sec / メモリ制限: 1024 MB
# 配点: 300点

# 問題文
# 古代すぬけ国では, AtCoder 社長「高橋君」の権威を高めるために, ピラミッドが建てられていた.
# ピラミッドには 中心座標 (CX,CY)と 高さ H が定まっており, 座標 (X,Y) の高度は max(H−|X−CX|−|Y−CY|,0)であった.
# 探検家の青木君は, このピラミッドの中心座標と高さを求めるために調査を行った. その結果, 次のような情報が得られた.
#     CX,CYは 0 以上 100 以下の整数で, H は 1以上の整数であった.
#     上記と別に N個の情報が得られた. そのうち i 個目の情報は, 「座標 (xi,yi) の高度は hiである」
# この情報は, ピラミッドの中心座標と高さを特定するのに十分であった. 情報を手掛かりに, これらの値を求めなさい.

# 制約
#     Nは 1 以上 100以下の整数
#     xi, yi は 0 以上 100以下の整数
#     hiは 0 以上 109以下の整数
#     N個の座標 (x1,y1),(x2,y2),(x3,y3),...,(xN,yN)はすべて異なる
#     ピラミッドの中心座標と高さをちょうど 1つに特定することができる

# 入力
# 入力は以下の形式で標準入力から与えられる.
# N
# x1 y1 h1
# x2 y2 h2
# x3 y3 h3
# :
# xN yN hN

# 出力
# 特定した中心座標と高さを表す整数 CX,CY,Hを空白区切りで, 1 行に出力しなさい.

# 入力例 1
# 4
# 2 3 5
# 2 1 5
# 1 2 5
# 3 2 5

# 出力例 1
# 2 2 6

# この場合, 中心座標は (2,2), 高さは 6と特定することができる.

# 入力例 2
# 2
# 0 0 100
# 1 1 98

# 出力例 2
# 0 0 100

# この場合, 中心座標は (0,0), 高さは 100 と特定することができる.
# CX,CY が 0 以上 100以下の整数であると分かっていることに注意せよ.

# 入力例 3
# 3
# 99 1 191
# 100 1 192
# 99 0 192

# 出力例 3
# 100 0 193

# この場合, 中心座標は (100,0), 高さは 193 と特定することができる.


def calculation(lines):
    N = int(lines[0])
    # N, T = list(map(int, lines[0].split()))
    # n = lines[0]

    points = list()
    highest = 0
    for i in range(1, N+1):
        point = list(map(int, lines[i].split()))
        # print(point)
        points.append(point)
        if highest < point[2]:
            highest = point[2]
        # print(f'points=[{points}]')

    for x in range(101):
        for y in range(101):
            for h in range(highest, highest+200):
                # print(f'x=[{x}], y=[{y}], h=[{h}]')
                flag = True
                for point in points:
                    # print(f'point=[{point}]')
                    calc_h = max(h - abs(point[0]-x) - abs(point[1]-y), 0)
                    if point[2] != calc_h:
                        flag = False
                        break
                if flag:
                    result = str(x) + ' ' + str(y) + ' ' + str(h)
                    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4', '2 3 5', '2 1 5', '1 2 5', '3 2 5']
        lines_export = ['2 2 6']
    if pattern == 2:
        lines_input = ['2', '0 0 100', '1 1 98']
        lines_export = ['0 0 100']
    if pattern == 3:
        lines_input = ['3', '99 1 191', '100 1 192', '99 0 192']
        lines_export = ['100 0 193']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = l[k][2] + abs(i - l[k][0]) + abs(j - l[k][1])
            if tmp != h:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)

Submission status: Runtime Error

Solution code:
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
xyh =[0]*N
for i in range(N):
    xyh[i] = tuple(int(i) for i in input().split())

from collections import defaultdict
H =defaultdict(set)
for x,y,h in xyh:
    for cx in range(101):
        for cy in range(101):
            xx =x -cx
            yy =y -cy
            if cx <=x and cy <=y:
                H[(cx,cy)].add( (h +xx +yy) )
            elif cx >x and cy <=y:
                 H[(cx,cy)].add( (h -xx +yy) )
            elif cx <=x and cy >y:
                 H[(cx,cy)].add( (h +xx -yy) )
            elif cx >x and cy >y:
                 H[(cx,cy)].add( (h -xx -yy) )
            
#print(xyh)
#H.sort(key =lambda x:x[1])
for k,v in H.items():
    if len(v)==1:
        if 0 <= v[0] <=10**9:
            print(*k,*v)
        elif v[0] <0:
            print(*k,0)
        elif 10**9 <v[0]:
            print(*k,10**9)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x, y, h])


"""

C_x C_y H

XYの高度はmax(H - abs(X - C_x) - abs(Y - C_y), 0)
"""
xyh = sorted(xyh, key=lambda xyh: xyh[2], reverse=True)


ans = 0
for c_x in range(101):
    for c_y in range(101):
        H = -1
        for i, (x, y, h) in enumerate(xyh):
            if H == -1:
                H = h + abs(x - c_x) + abs(y - c_y)
            if H != h + abs(x - c_x) + abs(y - c_y):
                break
        else:
            ans = (c_x, c_y, H)
    
X, Y, H = ans
print(X, Y, H)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x, y, h])


"""

C_x C_y H

XYの高度はmax(H - abs(X - C_x) - abs(Y - C_y), 0)
"""
xyh = sorted(xyh, key=lambda xyh: xyh[2])


ans = 0
for c_x in range(101):
    for c_y in range(101):
        H = -1
        for i, (x, y, h) in enumerate(xyh):
            if H == -1:
                H = h + abs(x - c_x) + abs(y - c_y)
            if H != h + abs(x - c_x) + abs(y - c_y):
                break
        else:
            ans = (c_x, c_y, H)
    
X, Y, H = ans
print(X, Y, H)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x, y, h])


"""

C_x C_y H

XYの高度はmax(H - abs(X - C_x) - abs(Y - C_y), 0)
"""

ans = 0
for c_x in range(101):
    for c_y in range(101):
        H = -1
        for i, (x, y, h) in enumerate(xyh):
            if H == -1 and h != 0:
                H = h + abs(x - c_x) + abs(y - c_y)
            if H != h + abs(x - c_x) + abs(y - c_y):
                break
        else:
            ans = (c_x, c_y, H)
    
X, Y, H = ans
print(X, Y, H)

Submission status: Runtime Error

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

for i in range(0, 101):
    for j in range(0, 101):
        tmpH = 0
        tmpI = i
        tmpJ = j
        for k, xyh in enumerate(XYH_list):
            if k == 0:
                tmpH = xyh[2] + abs(xyh[0] - i) + abs(xyh[1] - j)
                continue
            if xyh[2] == max((tmpH - abs(xyh[0] - i) - abs(xyh[1] - j)), 0):
                if k == N - 1:
                    ans = [str(tmpI), str(tmpJ), str(tmpH)]
                continue
            else:
                break
print(' '.join(ans))

Submission status: Runtime Error

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

for i in range(1, 101):
    for j in range(1, 101):
        tmpH = 0
        tmpI = i
        tmpJ = j
        for k, xyh in enumerate(XYH_list):
            if k == 0:
                for l in range(1, 201):
                    if xyh[2] == max((l - abs(xyh[0] - i) - abs(xyh[1] - j)), 0):
                        tmpH = l
                        break
            if xyh[2] == max((tmpH - abs(xyh[0] - i) - abs(xyh[1] - j)), 0):
                if k == N - 1:
                    ans = [str(tmpI), str(tmpJ), str(tmpH)]
                continue
            else:
                break
print(' '.join(ans))

Submission status: Runtime Error

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

for i in range(1, 101):
    for j in range(1, 101):
        tmpH = 0
        tmpI = i
        tmpJ = j
        for k, xyh in enumerate(XYH_list):
            if k == 0:
                for l in range(1, 100000):
                    if xyh[2] == max(l - abs(xyh[0] - i) - abs(xyh[1] - j), 0):
                        tmpH = l
                        break
            if xyh[2] == max(tmpH - abs(xyh[0] - i) - abs(xyh[1] - j), 0):
                if k == N - 1:
                    ans = [str(tmpI), str(tmpJ), str(tmpH)]
                continue
            else:
                break
print(' '.join(ans))

Submission status: Runtime Error

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[]
for i in range(n):
  x,y,h=nii()
  l.append([x,y,h])
  if h!=0:
    ini_x=x
    ini_y=y
    ini_h=h

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    n_h=abs(tx-ini_x)+abs(ty-ini_y)+ini_h
    for x,y,h in l:
      t_h=max(abs(tx-x)+abs(ty-y)+h,0)
      if n_h!=t_h:
        break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      if [tx,ty,0] in l:
        ans_h.append(0)
      else:
        ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Submission status: Runtime Error

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[]
for i in range(n):
  x,y,h=nii()
  l.append([x,y,h])
  if h!=0:
    ini_x=x
    ini_y=y
    ini_h=h

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    n_h=abs(tx-ini_x)+abs(ty-ini_y)+ini_h
    for x,y,h in l:
      t_h=abs(tx-x)+abs(ty-y)+h
      if n_h!=t_h:
        break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      if [tx,ty,0] in l:
        ans_h.append(0)
      else:
        ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Submission status: Runtime Error

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[lnii() for i in range(n)]

if n==1:
  print(*l[0])
  exit()

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    t_h=-1
    for x,y,h in l:
      dist=abs(tx-x)+abs(ty-y)
      if t_h==-1:
        t_h=h+dist
      else:
        if t_h!=h+dist:
          break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Submission status: Runtime Error

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[lnii() for i in range(n)]

if n==1:
  print(*l[0])
  exit()

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    t_h=0
    for x,y,h in l:
      dist=abs(tx-x)+abs(ty-y)
      if t_h==0:
        t_h=h+dist
      else:
        if t_h!=h+dist:
          break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Submission status: Runtime Error

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[lnii() for i in range(n)]

for tx in range(101):
  for ty in range(101):
    t_h=0
    for x,y,h in l:
      dist=abs(tx-x)+abs(ty-y)
      if t_h==0:
        t_h=h+dist
      else:
        if t_h!=h+dist:
          break
    else:
      ans_x=tx
      ans_y=ty
      ans_h=t_h
      break

print(ans_x,ans_y,ans_h)

Submission status: Runtime Error

Solution code:
import numpy as np

def solve():
    n = int(input())
    val = []
    for i in range(min(n, 3)):
        x, y, h = map(int, input().split())
        val.append([x+y+h, -x+y+h, x-y+h, -x-y+h])
    base = [[1, 1, 1], [1, -1, 1], [1, 1, -1], [1, -1, -1]]
    ans = []
    for i, xx in enumerate(base):
        for j, yy in enumerate(base):
            for k, zz in enumerate(base):
                A = np.array([xx, yy, zz])
                Y = np.array([[val[0][i]], [val[1][j]], [val[2][k]]])
                try:
                    AA = np.linalg.inv(A)
                except np.linalg.LinAlgError as e:
                    if 'Singular matrix' in str(e):
                        continue
                    else:
                        raise
                ans.append(np.dot(AA, Y).tolist())
    print(int(*ans[5][1]), int(*ans[5][2]), int(*ans[5][0]))

solve()

Submission status: Runtime Error

Solution code:
n=int(input())
if n==2:
  a=3/0
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)

Submission status: Runtime Error

Solution code:
n = int(input())

xyh = [list(map(int, input().split())) for i in range(n)]
if xyh[0][2]:
    x,y,h = xyh[0]
if xyh[1][2]:
    x,y,h = xyh[1]
for i in range(101):
    for j in range(101):
        k = h + abs(i - x) + abs(j - y)
        if all(h == max(k - abs(i - x) - abs(j - y), 0) for x, y, h in xyh):
            print(i, j, k)

Submission status: Runtime Error

Solution code:
n = int(input())

xyh = [list(map(int, input().split())) for i in range(n)]
if xyh[0][2]:
    x,y,h = xyh[0]
for i in range(101):
    for j in range(101):
        k = h + abs(i - x) + abs(j - y)
        if all(h == max(k - abs(i - x) - abs(j - y), 0) for x, y, h in xyh):
            print(i, j, k)

Submission status: Runtime Error

Solution code:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]

def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = min([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [10 ** 9])
		
		cc = collections.Counter()
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h > 0:
				Y = h + q
				if 1<=Y <= H:
					cc[Y]+=1
				else:
					cc[10 ** 9 + 2] += 1
		if len(cc) == 1:
			for k in cc:
				if 1<=k <= 10 ** 9:
					return k,cx,cy

h,x,y = f(pts)

print x,y,h

Submission status: Runtime Error

Solution code:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [-float('inf')])
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				#Y  - q = h
				Y = h + q
				if Y >= H:
					cc[Y]+=1
				else:
					cc[10 ** 9 + 1] += 1
		if len(cc) == 1:
			for k in cc:
				return k,cx,cy

h,x,y = f(pts)

print x,y,h

Submission status: Runtime Error

Solution code:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = 10 ** 9 + 1
		cc = collections.Counter()
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [-float('inf')])
	
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				Y = h + q
				if Y >= H:
					cc[Y]+=1
		if len(cc) == 1:
			for k in cc:
				return k,cx,cy

h,x,y = f(pts)

print x,y,h

Submission status: Runtime Error

Solution code:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = 10 ** 9 + 1
		cc = collections.Counter()
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [-float('inf')])
	
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				Y = h + q
				if Y >= H:
					cc[Y]+=1
		if len(cc) == 1:
			for k in cc:
				return Y,cx,cy

h,x,y = f(pts)

print x,y,h

Submission status: Runtime Error

Solution code:
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
sx,sy,sh=a[0][0],a[0][1],a[0][2]
for y in range(101):
    for x in range(101):
        h=sh+abs(x-sx)+abs(y-sy)
        f=1
        #一つでも条件に合致していなかったらフラグを折る
        for i in range(n):
            if max(abs(x-a[i][0])+abs(y-a[i][1])+a[i][2]!,0)=h:
                f=0
        #立ってたら終わり
        if f==1:
            print(x,y,h)
            exit()

Submission status: Runtime Error

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
xyh = [None]*n
for i in range(n):
    x,y,h = map(int, input().split())
    xyh[i] = (x,y,h)
    
for i in range(101):
    for j in range(101):
        x,y,h = xyh[0]
        H = h + abs(x-i) + abs(y-j)
        bad = False
        for x,y,h in xyh:
            if max(0, H - abs(x-i) - abs(y-j))!=h:
                bad = True
                break
        if bad:
            pass
        else:
            ans = (i,j,H)
            break
    if not bad:
        break
print(" ".join(map(str, ans)))

Submission status: Runtime Error

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
xyh = [None]*n
for i in range(n):
    x,y,h = map(int, input().split())
    xyh[i] = (x,y,h)
    
minh = min(item[2] for item in xyh) - 200
minh = max(minh, 1)
minh = max(item[2] for item in xyh) + 200
for i in range(101):
    for j in range(101):
        x,y,h = xyh[0]
        H = h + abs(x-i) + abs(y-j)
        bad = False
        for x,y,h in xyh:
            if max(0, H - abs(x-i) - abs(y-j))!=h:
                bad = True
                break
        if bad:
            continue
        else:
            ans = (i,j,H)
            break
    if not bad:
        break
print(" ".join(map(str, ans)))

Submission status: Runtime Error

Solution code:
def calc_ch(cx, cy, i):
    x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
    ch = max(abs(cx-x) + abs(cy-y) + h, 0)
    if h == 0 or ch == 0:
        if i == n-1:
            ch, i = -1, -1
        else:
            ch, i = calc_ch(cx, cy, i+1)
    return ch, i


n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
# xyh = sorted(xyh, key=lambda x:(x[2]))

for cx in range(101):
    for cy in range(101):
        flg = False
        ch0, s = calc_ch(cx, cy, 0)
        # print(cx, cy, ch0)
        if ch0 == -1:
            continue
        for i in range(s,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            if h == 0:
                continue
            ch = max(abs(cx-x) + abs(cy-y) + h, 0)
            if ch != ch0:
                break
            if i == n-1:
                flg = True
        if flg:
            anscx, anscy = cx, cy
            ansh = ch0
            break
    if flg:
        break
# print(cx, cy)
print(anscx, anscy, ch0)

Submission status: Runtime Error

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh = sorted(xyh, key=lambda x:(x[2]), reverse=True)

for cx in range(101):
    for cy in range(101):
        flg = True
        x, y, h = xyh[0][0], xyh[0][1], xyh[0][2]
        ch0 = max(abs(cx-x) + abs(cy-y) + h, 0)
        for i in range(1,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            ch = max(abs(cx-x) + abs(cy-y) + h, 0)
            if ch > 0 and ch != ch0:
                flg = False
                break
        if flg:
            anscx, anscy = cx, cy
            ansh = ch0
            break
    if flg:
        break

print(anscx, anscy, ch0)

Submission status: Runtime Error

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

for cx in range(101):
    for cy in range(101):
        flg = True
        x, y, h = xyh[0][0], xyh[0][1], xyh[0][2]
        ch0 = max(abs(cx-x) + abs(cy-y) + h, 0)
        for i in range(1,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            ch = max(abs(cx-x) + abs(cy-y) + h, 0)
            if ch != ch0:
                flg = False
                break
        if flg:
            anscx, anscy = cx, cy
            ansh = ch0
            break
    if flg:
        break

print(anscx, anscy, ch0)

Submission status: Runtime Error

Solution code:
n = int(input())
coord = []

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

flag = False

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        H = coord[0][0] + abs(coord[0][1] - cx) + abs(coord[0][2] - cy)

        for i in range(1, n):
            if coord[i][0] > 0 and H != coord[i][0] + abs(coord[i][1] - cx) + abs(
                coord[i][2] - cy
            ):
                flag = False

            if coord[i][0] == 0 and H > abs(coord[i][1] - cx) + abs(coord[i][2] - cy):
                flag = False

        if flag is True:
            res_x = cx
            res_y = cy
            res_h = H

print(res_x, res_y, res_h)

Submission status: Runtime Error

Solution code:
points=[]
n=int(input())
for _ in range(n):
    data=map(int,input().split())
    points.append(data)
for i in range(101):
    for j in range(101):
        temp=-1
        check=True
        for point in points:
            x,y,h=point
            if temp==-1:
                temp=abs(x-i)+abs(y-j)+h
            if temp!=abs(x-i)+abs(y-j)+h:
                check=False
                break
        if check:
            print(i,j,temp)
            exit()

Submission status: Runtime Error

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

for i in range(101):
  for j in range(101):

    hmax = h[0][2] + abs(i-h[0][0]) + abs(j-h[0][1])
    for k in range(1,n):
      if h[k][2] + abs(i-h[k][0]) + abs(j-h[k][1]) != hmax:
        break
    else:
      ans = [i,j,hmax]
      break
  else:
    continue
  break

ans = map(str,ans)
print(' '.join(ans))