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())

x = [0] * N
y = [0] * N
h = [0] * N

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

for i in range(101):
    for j in range(101):
        h1 = h[0] + abs(i - x[0]) + abs(j - y[0])
        flag = True
        for k in range(1, N):
            h2 = h[k] + abs(i - x[k]) + abs(j - y[k])
            if h1 != h2:
                flag = False
                break
        if flag:
            ans = [str(i), str(j), str(h1)]
            break
    if flag:
        break

print(ans[0] + " " + ans[1] + " " + ans[2])

Submission status: Runtime Error

Solution code:
n=int(input())
l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
p=[]
for i in range(n):
    for cx in range(101):
        for cy in range(101):
            if l[i][2]>0:
                H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
                p.append([cx,cy,H])

p.sort()
ans=0
for i in range(101*101*n-1):
    if p[i]==p[i+1]:
        ans+=1
        if ans==n-1:
            print(' '.join(map(str,p[i])))
            break
    else:
        ans=0

Submission status: Runtime Error

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

top = [[] for _ in range(101*101)]

for i in range(101):
    for j in range(101):
        top[i*101+j] = [i, j]

#print(top)

H = 0

for i in range(len(top)):
    topx = top[i][0]
    topy = top[i][1]
    H = 0
    h_list = []
    for j in range(N):
        tmp = abs(topx - x[j]) + abs(topy - y[j]) + h[j]
        h_list.append(tmp)
    if h_list.count(h_list[0]) >= N - h.count(0) :
        ansx = topx
        ansy = topy
        ansH = h_list[0]
        break

print(ansx, ansy, ansH)

Submission status: Runtime Error

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

top = [[] for _ in range(101*101)]

for i in range(101):
    for j in range(101):
        top[i*101+j] = [i, j]

#print(top)

H = 0

for i in range(len(top)):
    topx = top[i][0]
    topy = top[i][1]
    H = 0
    h_list = []
    for j in range(N):
        tmp = abs(topx - x[j]) + abs(topy - y[j]) + h[j]
        h_list.append(tmp)
    if h_list.count(h_list[0]) == N :
        ansx = topx
        ansy = topy
        ansH = h_list[0]
        break

print(topx, topy, ansH)

Submission status: Runtime Error

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

cx,cy = 0,0
for cx in range(101):
    for cy in range(101):
        pro_height = []
        for i in range(n):
            h = lst[i][2] + abs(lst[i][0]-cx) + abs(lst[i][1]-cy)
            pro_height.append(h)
        if len(set(pro_height)) == 1:
            ans_H = pro_height[0]
            ans_cx = cx
            ans_cy = cy
            break
print(ans_cx,ans_cy,ans_H)

Submission status: Runtime Error

Solution code:
N = int(input())
p_x = []
p_y = []
p_h = []
for i in range(N):
    x1,y1,h1 = [int(i) for i in input().split()]
    p_x.append(x1)
    p_y.append(y1)
    p_h.append(h1)


#h = H - |X-CX| - |Y-CY|　⇔　H = h + |X-CX| + |Y-CY|
#方針：上記式から与えられた全座標でHの値が一致する点を見つける。
for x in range(101):
    for y in range(101):
        hantei1 = 0
        count = 0
        hantei = 1
        for i in range(N):
            if i == 0 :
                tmp = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                if tmp < 0:
                   hantei = 0
            else:
                if hantei == 1:
                    tmp1 = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                    if tmp == tmp1:
                        #print(tmp,tmp1,x,y,i)
                        count += 1
                    else :
                        break
                else :
                    break
        if count == N-1:
            Cx = x
            Cy = y
            H = tmp
            hantei1 = 1
            break  
    if hantei1 == 1:
        break

print(Cx,Cy,H)

Submission status: Runtime Error

Solution code:
N = int(input())
p_x = []
p_y = []
p_h = []
for i in range(N):
    x1,y1,h1 = [int(i) for i in input().split()]
    p_x.append(x1)
    p_y.append(y1)
    p_h.append(h1)


#h = H - |X-CX| - |Y-CY|　⇔　H = h + |X-CX| + |Y-CY|
#方針：上記式から与えられた全座標でHの値が一致する点を見つける。
for x in range(101):
    for y in range(101):
        hantei1 = 0
        count = 0
        hantei = 1
        for i in range(N):
            if i == 0 :
                tmp = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                if tmp < 0:
                   hantei = 0
            else:
                if hantei == 1:
                    tmp1 = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                    if tmp == tmp1:
                        #print(tmp,tmp1,x,y,i)
                        count += 1
                    else :
                        break
                else :
                    break
        if count == N-1:
            Cx = x
            Cy = y
            H = tmp
            hantei1 = 1
            break  
    if hantei1 == 1:
        break

print(Cx," ", Cy, " ",H")

Submission status: Runtime Error

Solution code:
N = int(input())
p_x = []
p_y = []
p_h = []
for i in range(N):
    x1,y1,h1 = [int(i) for i in input().split()]
    p_x.append(x1)
    p_y.append(y1)
    p_h.append(h1)


#h = H - |X-CX| - |Y-CY|　⇔　H = h + |X-CX| + |Y-CY|
#方針：上記式から与えられた全座標でHの値が一致する点を見つける。
for x in range(101):
    count = 0
    hantei = 1
    for y in range(101):
        hantei1 = 0
        for i in range(N):
            if i == 0 :
                tmp = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                if tmp < 0:
                   hantei = 0
            else:
                if hantei == 1:
                    tmp1 = p_h[i] + abs(x - p_x[i]) + abs(y - p_y[i])
                    if tmp == tmp1:
                        #print(tmp,tmp1,x,y)
                        count += 1
                    else :
                        break
                else :
                    break
        if count == N-1: 
            #print (x,y,tmp)
            Cx = x
            Cy = y
            H = tmp
            hantei1 = 1
            break  
    if hantei1 == 1:
        break

print(Cx," ", Cy, " ",H)

Submission status: Runtime Error

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

for cx in range(101):
    for cy in range(101):
        mh = 10000000000
        h = []
        for i in range(n):
            x,y,z = xyz[i][0],xyz[i][1],xyz[i][2]
            if z == 0:
                mh = min(mh,abs(x-cx)+abs(y-cy))
            elif len(h) == 0:
                h.append(z+abs(x-cx)+abs(y-cy))
            
            if len(h)>0:
                if h[0] != z+abs(x-cx)+abs(y-cy):
                        h = []
                        break
                if h[0]>mh:
                    h = []
                    break
        if len(h) > 0:
            ans = str(cx)+" "+str(cy)+" "+str(h[0])
print(ans)

Submission status: Runtime Error

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

for cx in range(101):
    for cy in range(101):
        mh = 1000000000
        h = []
        for i in range(n):
            x,y,z = xyz[i][0],xyz[i][1],xyz[i][2]
            if z == 0:
                mh = min(mh,abs(x-cx)+abs(y-cy))
            else:
                if len(h) == 0:
                    h.append(z+abs(x-cx)+abs(y-cy))
                else:
                    if h[0] != z+abs(x-cx)+abs(y-cy):
                        h = []
                        break
                    elif h[0]>mh:
                        h = []
                        break
        if len(h) > 0:
            ans = str(cx)+" "+str(cy)+" "+str(h[0])
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
  if step > n:
    break
print(' '.join(list(map(str,can[0]))))

Submission status: Runtime Error

Solution code:
n = int(input())
can = []
x,y,h = map(int,input().split())
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
while len(can) != 1:
  x,y,h = map(int,input().split())
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del now
      else:
        cnt += 1
print(' '.join(list(map(str,can[0]))))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				if h[i] != 0:
					H = h[i] + abs(x[i]-s) + abs(y[i]-t)
					gr.add(H)
				else:
					for k in gr:
						if k > abs(x[i]-s) + abs(y[i]-t):
							gr.remove(k)

			if len(gr) == 1:
				h = gr.pop()
				if h >= 0:
					print(s, t, h)
					return

if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
n=int(input())
hoge=[]
for i in range(n):
  x,y,z=map(int,input().split())
  if(z!=0):
    hoge.append([x,y,z])
  

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

for i in range(101):
  for j in range(101):
    h=[]
    for k in range(n):
      h.append(hoge[k][2]+abs(hoge[k][0]-i)+abs(hoge[k][1]-j))
      
    if(h.count(h[0])==len(h)):
      print(i,j,h[0])

Submission status: Runtime Error

Solution code:
n=int(input())
hoge=[]
for i in range(n):
  x,y,z=map(int,input().split())
  if(z!=0):
    hoge.append([x,y,z])
  
for i in range(101):
  for j in range(101):
    h=[]
    for k in range(n):
      h.append(hoge[k][2]+abs(hoge[k][0]-i)+abs(hoge[k][1]-j))
      
    if(h.count(h[0])==len(h)):
      print(i,j,h[0])

Submission status: Runtime Error

Solution code:
N = int(input())
old_dl = [list(map(int,input().split())) for _ in range(N)]
dl = []
for k in old_dl:
    if k[2] != 0:
        dl.append(k)
if len(dl) == 1:
    print(dl[2])
else:
    for x in range(101):
        for y in range(101):
            ndl = [l[2]+abs(l[0]-x)+abs(l[1]-y) for l in dl]
            if max(ndl) == min(ndl):
                #print(ndl)
                print(x,y,max(ndl))
                exit(0)

Submission status: Runtime Error

Solution code:
import collections

n = int(input())

x = [0]*n
y = [0]*n
h = [0]*n
H = [0]*n

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  
for cx in range(101):
  for cy in range(101):
    for i in range(n):
      H[i] = max(h[i] + abs(x[i]-cx) + abs(y[i]-cy), 0)
    c = collections.Counter(H)
    if len(c) == 1 && H[0] >= max(h):
      print(cx, cy, H[0])
      exit()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
#ABC112C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0
#peak ga (i,j) to katei
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[0])
		distance+=abs(j-y[0])
		height=distance+h[0]

		for k in range(1,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(height==distance+h[k]!):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()

Submission status: Runtime Error

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

for cx in range(101):
    for cy in range(101):
        for i in li:
            if i[2] != 0:
                ans.append([cx, cy, i[2] + abs(i[0]-cx) + abs(i[1] -cy)])
                break

for i in li:
    if len(ans) ==1:
        break
    for j in reversed (range(len(ans[:]))):
        if ans[j][2] - abs(i[0]-ans[j][0]) - abs(i[1]-ans[j][1]) != i[2]:
            ans.pop(j)


print(" ".join(map(str, ans[0])))

Submission status: Runtime Error

Solution code:
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 pos_x in range(101):
    for pos_y in range(101):
        need_h = -1
        for n in range(N):
            if H[n] > 0:
                tmp = H[n] + abs(X[n]-pos_x) + abs(Y[n]-pos_y)
            if need_h == -1:
                need_h = tmp
            else:
                if need_h != tmp:
                    need_h = -2
                    break
        if need_h == -2:
            continue

        for n in range(N):
            if H[n] == 0:
                tmp = H[n] + abs(X[n]-pos_x) + abs(Y[n]-pos_y)
                if need_h > tmp:
                    need_h = -2
                    break
        if need_h == -2:
            continue

        print(pos_x, pos_y, need_h)
        exit()

Submission status: Runtime Error

Solution code:
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)

C = [[-1 for _ in range(101)] for _ in range(101)]
for i in range(101):
    for j in range(101):

        need = -1
        for n in range(N):
            if H[n] > 0:
                tmp = H[n] + abs(X[n]-i) + abs(Y[n]-j)
            if need == -1:
                need = tmp
            else:
                if need != tmp:
                    need = -2
                    break
        if need == -2:
            continue

        for n in range(N):
            if H[n] == 0:
                tmp = H[n] + abs(X[n] - i) + abs(Y[n] - j)
                if need > tmp:
                    need = -2
                    break
        if need == -2:
            continue

        print(i, j, need)
        exit()

Submission status: Runtime Error

Solution code:
n=int(input())

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

for i in range(101):
	for j in range(101):
		for k in range(n):
			if x[k][2]>0:
				h=x[k][2]+abs(i-x[k][0])+abs(j-x[k][1])
			break
		chk=0
		for k in range(n): 
			if x[k][2]!=max(h-abs(i-x[k][0])-abs(j-x[k][1]),0):
				chk=1
				break
		if chk==0:
			res=[i,j,h]
			break
	if chk==0:
		break

print(*res)

Submission status: Runtime Error

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

v=[]
count=0

#各頂点に対して、中心座標と仮定して検証
for i in range(101):
    for j in range(101):
            x=abs(j-z[0][0])
            y=abs(i-z[0][1])
            h=z[0][2]+abs(x)+abs(y)
                
            #候補があってるか確認
            for k in range(n):
                if z[k][2]==max(h-abs(z[k][0]-j)-abs(z[k][1]-i),0):
                    count+=1
                
            if count==n:
                print(r[0],r[1],h)
            exit()
        count=0

Submission status: Runtime Error

Solution code:
import fractions
n=int(input())
a=list(map(int, input().split()))
ans = a[0]
for i in range(1, n):
    ans = fractions.gcd(ans, a[i])
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
v=[]
r=[]
#各頂点に対して、ピラミッドの頂点(  高さ200 )と仮定して計算 rに座標保存
for i in range(101):
    for j in range(101):
        for k in range(n):
            x=abs(j-z[k][0])
            y=abs(i-z[k][1])
            v.append(200-x-y-z[k][2])
        if v.count(v[0])==n:
            r=[j,i]
        v=[]
#中心座標の高さを求める。
h=z[0][2]+abs(z[0][0]-r[0])+abs(z[0][1]-r[1])
print(r[0],r[1],h)

Submission status: Runtime Error

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

for x in range(101):
    for y in range(101):
        check = []
        for d in xyh:
            ifd0 = False
            if d[2] == 0:
                ifd0 = True
            ch = abs(d[0] - x) + abs(d[1] - y) + d[2]
            check.append([ch, ifd0])
        ifans = True
        for c in check:
            if c[0] - check[0][0] != 0:
                if ifd0:
                    continue
                ifans = False
                break
        if ifans:
            ans = [x, y, ch]
            break

print(' '.join([str(a) for a in ans]))

Submission status: Runtime Error

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

ans = []
c = 0
for x in range(101):
    for y in range(101):
        for i, d in enumerate(xyh):
            if d[2] == 0:
                continue
            ch = abs(d[0] - x) + abs(d[1] - y) + d[2]
            if i == 0:
                chpre = ch
            if chpre != ch:
                break
        if chpre == ch:
            ans = [x, y, ch]
            break
    if ans:
        break

print(' '.join([str(a) for a in ans]))

Submission status: Runtime Error

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

def hight(inp):
    cx,cy,x,y,h=inp
    if h==0:
        return -1
    else:
        return abs(x-cx)+abs(y-cy)+h
    
for cx in range(101):
    for cy in range(101):
        H=set()
        for i in range(n):
            h=hight([cx,cy]+a[i])
            if h!=-1:
                H.add(h)
        if len(H)==1:
            flg=True
            for i in H:
                d=i
            for i in range(n):
                x,y,h=a[i]
                if max(0,abs(x-cx)+abs(y-cy)+h)!=d:
                    flg=False
            if flg:
                ans=cx,cy,d
print(*ans)

Submission status: Runtime Error

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

def hight(inp):
    cx,cy,x,y,h=inp
    if h==0:
        return -1
    else:
        return abs(x-cx)+abs(y-cy)+h
    
for cx in range(101):
    for cy in range(101):
        H=set()
        for i in range(n):
            h=hight([cx,cy]+a[i])
            if h!=-1:
                H.add(h)
        if len(H)==1:
            flg=True
            for i in H:
                d=i
            for i in range(n):
                x,y,h=a[i]
                if abs(x-cx)+abs(y-cy)+h!=d:
                    flg=False
            if flg:
                ans=cx,cy,d
print(*ans)

Submission status: Runtime Error

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

def hight(inp):
    cx,cy,x,y,h=inp
    if h==0:
        return -1
    else:
        return abs(x-cx)+abs(y-cy)+h
    
for cx in range(101):
    for cy in range(101):
        H=set()
        for i in range(n):
            h=hight([cx,cy]+a[i])
            if h!=-1:
                H.add(h)
        if len(H)==1:
            ans=cx,cy,*H
print(*ans)

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
xyhl = [list(map(int, input().split())) for _ in range(n)]

tmaps = np.zeros((101, 101, n), dtype="int64")
for d in range(n) :
    for i in range(101) :
        for j in range(101) :
            x, y, h = xyhl[d]
            tmaps[i, j, d] = abs(x-i)+abs(y-j)+h

dmaps = np.diff(tmaps, axis=2)
xmap = np.logical_or.reduce(dmaps, axis=2)
place = np.where(np.logical_not(xmap))
cx, cy = place[0][0], place[1][0]
h = tmaps[cx, cy, 0]
print("{} {} {}".format(cx, cy, h))

Submission status: Runtime Error

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

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(x[k]-j)
        if max(H-dx-dy)!=h[k]:
          break
        else:
          print(i,j,H)
          exit()
  H +=1

Submission status: Runtime Error

Solution code:
n = int(input())
pyr = []
for i in range(n):
    x, y, h = map(int, input().split())
    if h != 0:
        pyr.append((x, y, h))

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

for i in range(101):
    for j in range(101):
        cx, cy = (i, j)
        h_list = []
        for k in range(n):
            x, y, h = pyr[k]
            h_list.append(h + abs(x - cx) + abs(y - cy))
        if len(set(h_list)) != 1:
            continue
        else:
            print(cx, cy, h_list[0])
            exit()

Submission status: Runtime Error

Solution code:
n = int(input())
pyr = []
for i in range(n):
    x, y, h = map(int, input().split())
    if h != 0:
        pyr.append((x, y, h))

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

for i in range(101):
    for j in range(101):
        cx, cy = (i, j)
        h_list = []
        for k in range(n):
            x, y, h = pyr[k]
            if h != 0:
                h_list.append(h + abs(x - cx) + abs(y - cy))
        if len(set(h_list)) != 1:
            continue
        else:
            print(cx, cy, h_list[0])
            exit()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = [tuple(map(int,input().split())) for _ in range(n)]
for _ in range(n):
  if a[_][2] > 1:
    flag = _
    break
c = 0
for _ in range(101): #x
  for i in range(101): #y
    h = a[flag][2] + abs(a[flag][0]-_) + abs(a[flag][1]-i)
    for j in range(n):
      b = 0
      if a[j][2] != max(h - abs(a[j][0]-_) - abs(a[j][1]-i),0):
        b = 1
        break
      if j == n-1:
        print(_,i,h)
        c = 1
        break
    if c == 1:
      break
  if c == 1:
    break

Submission status: Runtime Error

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh.sort(key=lambda x: -x[2])
for cx in range(101):
    for cy in range(101):
        good = True
        h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
        for i in range(n):
            if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
                good = False
                break
        if good:
            print(cx, cy, h)
            sys.exit()

Submission status: Runtime Error

Solution code:

Copy
Copy
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

Submission status: Runtime Error

Solution code:
N = int(input())

A = []
for i in range(N):
    x,y,h = map(int, input().split())
    A.append([x,y,h])
for i in range(100+1):
    for j in range(100+1):
        lst = {}
        for x,y,h in A:
            if h == 0:
                continue
            tx, ty = abs(x-i), abs(y-j)
            H = h + tx + ty
            if H not in lst:
                lst[H] = 1
            else :
                lst[H] += 1
        if len(lst) == 1 and lst.keys()[0] != 0:
            print(i,j,H)

Submission status: Runtime Error

Solution code:
n = int(input())
def get_h(pos,cx,cy,H):
  r= H - abs(pos[0]-cx) - abs(pos[1]-cy)
  return r

points = []
for i in range(n):
  x,y,h = map(int,input().split())
  if h == 0:
    continue
  points.append([x,y,h])
  
ans = []
if ans == []:
  for i in range(101):
    for j in range(101):
      d = get_h(points[0],i,j,0)- get_h(points[1],i,j,0)
      if points[0][2]- points[1][2] == d:
        ans.append([i,j])
for k in range(len(points)):
  for l in range(k+1,len(points)):
    for elem in ans[:]:
      i = elem[0]
      j = elem[1]
      if points[k][2] - points[l][2] != abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):
        ans.remove(elem)
if len(ans) > 1:
  ans.remove(ans[0])
h = abs(points[0][0]-ans[0][0])+abs(points[0][1]-ans[0][1]) + points[0][2]
print('{} {} {}'.format(ans[0][0],ans[0][1],h))

Submission status: Runtime Error

Solution code:
n = int(input())
def get_h(pos,cx,cy,H):
  r= H - abs(pos[0]-cx) - abs(pos[1]-cy)
  return r

points = []
for i in range(n):
  x,y,h = map(int,input().split())
  points.append([x,y,h])
  
ans = []
if ans == []:
  for i in range(101):
    for j in range(101):
      d = get_h(points[0],i,j,0)- get_h(points[1],i,j,0)
      if points[0][2]- points[1][2] == d:
        ans.append([i,j])
for k in range(len(points)):
  for l in range(k+1,len(points)):
    for elem in ans[:]:
      i = elem[0]
      j = elem[1]
      if points[k][2] - points[l][2] != abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):
        ans.remove(elem)
h = abs(points[0][0]-ans[0][0])+abs(points[0][1]-ans[0][1]) + points[0][2]
print('{} {} {}'.format(ans[0][0],ans[0][1],h))

Submission status: Runtime Error

Solution code:
n = int(input())
def get_h(pos,cx,cy,H):
  r= H - abs(pos[0]-cx) - abs(pos[1]-cy)

  return r

points = []
for i in range(n):
  x,y,h = map(int,input().split())
  if h == 0:
    continue
  points.append([x,y,h])
  
ans = []
if ans == []:
  for i in range(101):
    for j in range(101):
      d = get_h(points[0],i,j,0)- get_h(points[1],i,j,0)
      if points[0][2]- points[1][2] == d:
        ans.append([i,j])
for k in range(len(points)):
  for l in range(k+1,len(points)):
    for elem in ans[:]:
      i = elem[0]
      j = elem[1]
      if points[k][2] - points[l][2] != abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):
        ans.remove(elem)
h = abs(points[0][0]-ans[0][0])+abs(points[0][1]-ans[0][1]) + points[0][2]
print('{} {} {}'.format(ans[0][0],ans[0][1],h))

Submission status: Runtime Error

Solution code:
n = int(input())
def get_h(pos,cx,cy,H):
  r= H - abs(pos[0]-cx) - abs(pos[1]-cy)

  return r

points = []
for i in range(n):
  x,y,h = map(int,input().split())
  if h == 0:
    continue
  points.append([x,y,h])
  
ans = []
q = []
if ans == []:
  for i in range(101):
    for j in range(101):
      d = get_h(points[0],i,j,0)- get_h(points[1],i,j,0)
      if points[0][2]- points[1][2] == d:
        ans.append([i,j])
        q.append([i,j])
for k in range(len(points)):
  for l in range(k+1,len(points)):
    for elem in q:
      i = elem[0]
      j = elem[1]
      if points[k][2] - points[l][2] != abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):
        if elem in ans:
          ans.remove(elem)
h = abs(points[0][0]-ans[0][0])+abs(points[0][1]-ans[0][1]) + points[0][2]
print('{} {} {}'.format(ans[0][0],ans[0][1],h))

Submission status: Runtime Error

Solution code:
n = int(input())
points = []
for i in range(n):
  x,y,h = map(int,input().split())
  if h == 0:
    continue
  points.append(list(x,y,h))
  

for k in range(len(points)):
　for l in range(k+1,len(points)):
　　for i in range(100):
　　　for j in range(100):
        if points[k][2] - points[l][2] == abs(points[l][0]-i) + abs(points[l][1]-j)- abs(points[k][0]-i)-abs(points[k][1]-j):

Submission status: Runtime Error

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

zahyo.sort(key=lambda x:x[2], reverse = 1)
mx,my,mh=zahyo[0]
for Cx in range(101):
    for Cy in range(101):
        H = mh+abs(mx-Cx)+abs(my-Cy)
        if all(h == max(H-abs(x-Cx)+abs(y-Cy),0) for x,y,h in zahyo):
            print(Cx,Cy,h)
            break

Submission status: Runtime Error

Solution code:
import numpy as np
from functools import reduce

def dist(array,xyh):
    return (abs(array.real-xyh[0])+abs(array.imag-xyh[1])+xyh[2])

def dist2(array,xyh,dxyh):
    if xyh[2]>0:
        return dist(array,xyh) == dxyh
    else:
        return dist(array,xyh) <= dxyh

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

a=np.arange(101)+np.arange(101).reshape(101,1)*1j
dxyh=dist(a,xyh[0])

ans=np.where(reduce(lambda a,b:a&b,[dist2(a,xyh[i],dxyh) for i in range(1,N)]) == True)
print(ans[1][0],ans[0][0],int(dxyh[ans[0][0],ans[1][0]]))

Submission status: Runtime Error

Solution code:
import numpy as np
from functools import reduce

def dist(array,xyh):
    return abs(array.real-xyh[0])+abs(array.imag-xyh[1])+xyh[2]

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

a=np.arange(101)+np.arange(101).reshape(101,1)*1j
dxyh=dist(a,xyh[0])

ans=np.where(reduce(lambda a,b:a&b,[dist(a,xyh[i])==dxyh for i in range(1,N)]) == True)
print(ans[1][0],ans[0][0],int(dxyh[ans[0][0],ans[1][0]]))