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: Wrong Answer

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

def main():
    n = int(input())
    arrys = []
    for _ in range(n):
        x, y, h = map(int, input().split())
        if h != 0:
            arrys.append((x, y, h))
    if len(arrys) % 2 != 0:
        arrys.append(arrys[-1])
    h_tmp = 0
    e = ''
    for i in range(len(arrys)):
        x, y, h = arrys[i]
        if i % 2 == 0:
            h_tmp += h
            e += '-abs(' + str(x) + ' - j) -abs(' + str(y) + '-k)'
        else:
            h_tmp -= h
            e += '+abs(' + str(x) + '-j) +abs(' + str(y) + '-k)'
    #print(h_tmp)
    #print(e)
    for j in range(101):
        for k in range(101):
            if h_tmp == eval(e):
                x, y, h = arrys[0]
                H = h + abs(x - j) + abs(y - k)
                flag = 1
                for arry in arrys:
                    x_t, y_t, h_t = arry
                    if h_t == H - abs(x_t - j) - abs(y_t - k):
                        flag *= 1
                    else:
                        flag *= 0
                if flag == 1:
                    print(j, k, H)
                    exit()
                    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
index = 0
dataL = []
xyData =[]
xData=[]
yData=[]
while index < n:
    x, y, h = map(int, input().split())
    dataL.append([h, x, y])
    xyData.append([x, y])
    xData.append(x)
    yData.append(y)
    index += 1
dataL.sort()
dataL.reverse()

dataI = []
max = dataL[0][0]
index2 = 0
while index2 < len(dataL):
    if dataL[index2][0] == max:
        dataI.append(dataL[index2])
        index2 += 1
    else:
        break

if len(dataI) == 4:
    index3 = 0
    sumX = 0
    sumY = 0
    while index3 < len(dataI):
        sumX += dataI[index3][1]
        sumY += dataI[index3][2]
        index3 += 1
    cx = sumX//4
    cy = sumY//4
    ansH = dataI[0][0]+abs(dataI[0][1]-cx)+abs(dataI[0][2]-cy)
    print(str(cx)+" "+str(cy)+" "+str(ansH))

elif len(dataI) == 1:
    print(str(dataI[0][2])+" "+str(dataI[0][1])+" "+str(dataI[0][0]))
else:
    if not [dataI[0][1]+1, dataI[0][2]] in xyData:
        if dataI[0][1]+1 < 101:
            if dataI[0][1]+1 in xData and dataI[0][2] in yData:
                print(str(dataI[0][1]+1)+" "+str(dataI[0][2])+" "+str(dataI[0][0]+1))
    if not [dataI[0][1], dataI[0][2]+1] in xyData:
        if dataI[0][1] in xData and dataI[0][2]+1 in yData:
            if dataI[0][2]+1 < 101:
                print(str(dataI[0][1])+" " +
                    str(dataI[0][2]+1)+" "+str(dataI[0][0]+1))
    if not [dataI[0][1]-1, dataI[0][2]] in xyData:
        if dataI[0][1]-1 in xData and dataI[0][2] in yData:
            if dataI[0][1]-1 > -1:
                print(str(dataI[0][1]-1)+" " +
                    str(dataI[0][2])+" "+str(dataI[0][0]+1))
    if not [dataI[0][1], dataI[0][2]-1] in xyData:
        if dataI[0][1] in xData and dataI[0][2]-1 in yData:
            if dataI[0][2]-1 > -1:
                print(str(dataI[0][1])+" " +
                    str(dataI[0][2]-1)+" "+str(dataI[0][0]+1))

Submission status: Wrong Answer

Solution code:
def check():
    for i in range(0,101):
        for j in range(0,101):
            if h[0]==1000000000:
                print(x[0],y[0],h[0])
                return
            test=True
            h1=abs(i-x[0])+abs(j-y[0])+h[0]
            for k in range(1,n):
                if h[k]==1000000000:
                    print(x[k],y[k],h[k])
                    return
                if h1!=abs(i-x[k])+abs(j-y[k])+h[k]:
                    test=False
                    break;
            if test==True:
                print(i,j,h1)
                return
            
n=int(input())
x=[0 for i in range(0,n)]
y=[0 for i in range(0,n)]
h=[0 for i in range(0,n)]
for i in range(0,n):
    x[i],y[i],h[i]=map(int,input().split())
check()

Submission status: Wrong Answer

Solution code:
N = int(input())

X = []
Y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())

    X.append(a)
    Y.append(b)
    h.append(c)

for Cx in range(101):
    p = False
    for Cy in range(101):
        w = True
        previous = None
        for i in range(0,N):
            H = h[i] + abs(X[i] - Cx) + abs(Y[i] - Cy)
            if H - abs(X[i] - Cx) - abs(Y[i] - Cy) >= 1:
                if previous == None:
                    previous = H
                elif H != previous:
                    w = False
                    break
            elif H < 1:
                w = False
                break
        
        if w:
            answer = [Cx,Cy,H]
            p = True
            break

    if p:
        break

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

Submission status: Wrong Answer

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

LEN = 101

field = [[0 for _ in range(LEN)] for __ in range(LEN)]

def predict_h(info,xy):
    return info[2] + abs(info[0] - xy[0]) + abs(info[1] - xy[1])

def distance(xy,info):
    return abs(xy[0] - info[0]) + abs(xy[1] - info[1])


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

        flag = True
        height = predict_h(infos[0],[i,j])
        for info in infos:
            if height - distance(info,(i,j)) == info[2] :
                continue
            else:
                flag = False
                break
            

        
        
        if flag:
            print(i,j,height)

Submission status: Wrong Answer

Solution code:
n = input()
l = []
isz = 0
for i in xrange(n):
    x, y, h = map(int, raw_input().strip().split())
    if h == 0: isz += 1
    l.append([x, y, h])

assert isz != n

for cx in xrange(101):
    for cy in xrange(101):
        H = 0
        poss = True
        for xyh in l:
            x, y, h = xyh
            tx = abs(cx - x) + abs(cy - y)
            if h != 0:
                nH = tx + h
                if H != 0 and nH != H:
                    poss = False
                    break
                elif H == 0: H = nH
                
        if poss:
            print cx, cy, H
            break
        
    if poss: break

Submission status: Wrong Answer

Solution code:
n = int(input())
X_list = []
Y_list = []
H_list = []
for i in range(n):
    tmp1, tmp2, tmp3 = map(int, input().split())
    X_list.append(tmp1)
    Y_list.append(tmp2)
    H_list.append(tmp3)

X_max = max(X_list)
X_min = min(X_list)
Y_max = max(Y_list)
Y_min = min(Y_list)
flag = False
for x in range(X_min, X_max+1):
    for y in range(Y_min, Y_max+1):
        tmp = []
        for i in range(n):
            if H_list[i] != 0:
                tmp.append(abs(X_list[i]-x) + abs(Y_list[i]-y)+H_list[i])
        if max(tmp) == min(tmp):
            flag = True
        if flag:
            break
    if flag:
        break
print(x, y, max(tmp))

Submission status: Wrong Answer

Solution code:
N = int(input())

X = [None] * N
Y = [None] * N
H = [None] * N

for n in range(N):
    X[n], Y[n], H[n] = map(int, input().split())

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True
        for n in range(N):
            if n == 0:
                ch = H[n] + abs(X[n] - cx) + abs(Y[n] - cy)
            if max(ch - abs(X[n] - cx) - abs(Y[n] - cy), 0) != H[n]:
                flag = False
                break
        if flag == True:
            break
    if flag == True:
        break

print(cx, cy, ch)

Submission status: Wrong Answer

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

xs = tmp[0::3]
ys = tmp[1::3]
hs = tmp[2::3]

for H in range(max(hs), 10**9+1):
    for cx in range(101):
        for cy in range(101):
            for x,y,h in zip(xs,ys,hs):
                if h != max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print('{} {} {}'.format(cx,cy,H))
                break

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h_must = -1
        h_min = -1
        for k in range(N):
            h_tmp = xyh[k][2]+abs(x-xyh[k][0])+abs(y-xyh[k][1])
            if h_must == -1:
                if xyh[k][2] != 0:
                    h_must = h_tmp
                else:
                    h_min = max(h_min,h_tmp)
            else:
                if xyh[k][2] != 0:
                    if h_must != h_tmp:
                        break
                else:
                    if h_must < h_tmp:
                        break
        else:
            print("{} {} {}".format(x,y,h_must))
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:

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

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


    for i in range(101):
        for j in range(101):
            remain = []
            remain_flag = False
            for k in range(n):
                if k == 0 or remain_flag:
                    if lst[k][2] == 0:
                        remain.append(lst[k])
                        remain_flag = True
                        continue

                    h = lst[k][2] + abs(lst[k][0] - i) + abs(lst[k][1] - j)
                    remain_flag = False
                    continue

                if max(h - abs(lst[k][0] - i) - abs(lst[k][1] - j),0) == lst[k][2]:
                    if k == n-1:
                        for remain in remain:
                            if max(h - abs(remain[0] - i) - abs(remain[1] - j),0) != remain[2]:
                                break

                        print(str(i)+ " " + str(j) + " " + str(h))
                        exit()
                    continue
                else:
                    break


if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:
n=int(input())

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

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

m=max(s)
l=0
ans=[]

for i in range(101):
    for j in range(101):
        for k in range(n):
            ans.append(abs(x[k]-i)+abs(y[k]-j)+h[k])
        if max(ans)==min(ans) and ans[0]>=1:
            print(i,j,ans[0])
        else:
            ans=[]

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
a = [list(map(int,input().split())) for i in range(N)]
for j in range(101):
    for k in range(101):
        first = a[0][2] + np.abs(a[0][0] - j) + np.abs(a[0][1] - k)
        for i in range(N):
            if first != a[i][2] + np.abs(a[i][0] - j) + np.abs(a[i][1] - k):
                break
        else:
            print("{} {} {}\n".format(j, k, first))
            sys.exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = [0]*n
        ans = 0
        for i in range(n):
            if xyh[i][2]!=0:
                h[i] = abs(xyh[i][0] - x) + abs(xyh[i][1] - y) + xyh[i][2]
                if ans == h[i] or ans ==0:
                    ans =h[i]
                    if i ==n-1:
                        a = 0
                        for j in range(n):
                            if xyh[j][2]!= max(h[i]- abs(xyh[j][0] - x) - abs(xyh[j][1] - y),0):
                                a=1
                                break
                        if a==0:
                            print(x, y, h[i])
                else:
                    break

Submission status: Wrong Answer

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

N = int(input())

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


for xi in range(101):
    for yi in range(101):
        H_list = []
        for x,y,h in xyhn:
            H = h + abs(x - xi) + abs(y - yi)
            H_list.append(H)

        if min(H_list) == max(H_list):
            print("%d %d %d"%(xi,yi,H_list[0]))
            exit()

Submission status: Wrong Answer

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

for i in range(100, -1, -1):
    for j in range(100, -1, -1):
        height = -1
        for x, y, h in XYH:
            hi = abs(x - i) + abs(y - j) + h
            if h == 0:
                if abs(x - i) + abs(y - j) >= 0:
                    continue
                else:
                    break
            if height == -1:
                height = hi
            else:
                if height == hi:
                    continue
                else:
                    break
        else:
            if height >= 1:
                print(i, j, height)
                exit()
raise ValueError

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
h = [0 for i in range(n)]
for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())
for i in range(0, 101):
    for j in range(0, 101):
        for k in range(0, n):
            if h[k] != 0:
                k_l = k
                true_h = h[k] + int(math.fabs(x[k]-i)) + int(math.fabs(y[k]-j))
                break
        for k in range(k_l+1, n):
            if h[k] != 0:
                tmp_h = h[k] + int(math.fabs(x[k]-i)) + int(math.fabs(y[k]-j))
                if true_h != tmp_h:
                    break
        # print(k)
        if k == n-1:
            break
    if k == n-1:
        break

print("{} {} {}".format(i, j, true_h))

Submission status: Wrong Answer

Solution code:
from itertools import product

n = int(input())
xs, ys, hs = zip(*filter(lambda e: e[2]!=0, [[int(x) for x in input().split()] for _ in range(n)]))

for i, j in product(range(0,101), repeat=2):
    k = abs(xs[0]-i) + abs(ys[0]-j) + hs[0]
    for x, y, h in zip(xs[1:], ys[1:], hs[1:]):
        if k!=abs(x-i) + abs(y-j) + h:
            break
    else:
        print(i, j, k)
        break

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

field = [[-1 for i in range(101)] for j in range(101)]

for i in range(N):
	x,y,h = map(int,input().split())
	for j in range(101):
		for k in range(101):
			if h == 0:
				if abs(x-j) + abs(y-k) < field[j][k]:
					field[j][k] = -2
			else:
				if field[j][k] == -1:
					field[j][k] = h + abs(x-j) + abs(y-k)
				elif field[j][k] != h + abs(x-j) + abs(y-k):
					field[j][k] = -2

for i in range(101):
	for j in range(101):
		if field[i][j] > 0:
			print(i,j,field[i][j])

Submission status: Wrong Answer

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

judge = 0
ans = [0, 0, 0]
for x in range(101):
    for y in range(101):
        judge = 0
        h = data[0][2] + abs(x-data[0][0]) + abs(y-data[0][1])
        for d in range(1, N):
            h_ = h - abs(x-data[d][0]) - abs(y-data[d][1])
            if data[d][2] != h_:
                judge = 1
                break
        if judge == 0:
            break
    if judge == 0:
        ans = [x, y, h]
        break


for i in ans:
    print(i, end=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
cx,cy = 0,0
list_xyh = []
for i in range(n):
    list_xyh.append(list(map(int, input().split())))
for cx in range(0,101):
    for cy in range(0,101):
        for i in range(n):
            if list_xyh[i][2] != 0:
                H = abs(cx - list_xyh[0][0]) + abs(cy - list_xyh[0][1]) + list_xyh[0][2]
                break
        for i in range(n):
            if max(H - abs(cx - list_xyh[i][0]) - abs(cy - list_xyh[i][1]),0) == list_xyh[i][2]:
                continue
            else:
                break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
for i in range(N):
  x1=list(map(int,input().split()))
  list1.append(x1)
flag=0
for i in range(101):
  for j in range(101):
    list2=[]
    for k in range(N):
      Hx=list1[k][2]+abs(list1[k][0]-i)+abs(list1[k][1]-j)
      list2.append(Hx)
    if len(set(list2))==1:
      list3=[0]
      for l in range(N):
         d=Hx-abs(list1[l][0]-i)-abs(list1[l][1]-j)
         list3.append(d)
      if min(list3)>=0:
         print(i,j,Hx)
         flag=1
      else:
        pass
    else:
      pass
    if flag==1:
      break
  if flag==1:
    break

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
N = int(input())
XYH = [list(map(int,input().split())) for _ in range(N)]

Cxy = defaultdict(int)

#-1 NG
# 0 default
#1+ ok
for x,y,h in XYH:
    for cx in range(101):
        for cy in range(101):
            val = Cxy[(cx,cy)]
            if val<0:
                continue
            tmp_H = abs(x-cx)+abs(y-cy)+h
            if h==0:
                continue #????

            if val==0:
                Cxy[(cx,cy)] = tmp_H
            elif val != tmp_H:
                Cxy[(cx, cy)] =-1

def find(d):
    for key in d.keys():
        if d[key] >0:
            return key,d[key]

(X,Y),H = find(Cxy)
print(X,Y,H)

Submission status: Wrong Answer

Solution code:

def main():
    buf = input()
    N = int(buf)
    x = []
    y = []
    h = []
    for i in range(N):
        buf = input()
        buflist = buf.split()
        x.append(int(buflist[0]))
        y.append(int(buflist[1]))
        h.append(int(buflist[2]))
    for cx in range(101):
        for cy in range(101):
            H = h[0] + dist(cx, cy, x[0], y[0])
            correct = True
            for i in range(1, N):
                if h[i] + dist(cx, cy, x[i], y[i]) != H:
                    correct = False
                    break
            if correct == True:
                print(cx, cy, H)
                return


def dist(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

xmin = 0; ymin = 0; xmax = 101; ymax = 101

for i in range(n):
    xx, yy, hh = list(map(int, input().split(' ')))
    x.append(xx)
    y.append(yy)
    h.append(hh)

field = []

for i in range(n):
    if i == 0:
        for xx in range(xmin, xmax):
            f = []
            for yy in range(ymin, ymax):
                f.append(max(abs(xx - x[i]) + abs(yy - y[i]) + h[i], 0))
            field.append(f)
    
    else:
        for xx in range(xmin, xmax):
            for yy in range(ymin, ymax):
                f = max(abs(xx - x[i]) + abs(yy - y[i]) + h[i], 0)
                if field[xx][yy] != f:
                    field[xx][yy] = -1

maxx = 0; maxy = 0; maxV = 0
for xx in range(xmin, xmax):
    for yy in range(ymin, ymax):
        if maxV <= field[xx][yy]:
            maxx = xx; maxy = yy; maxV = field[xx][yy]

print(str(maxx) + " " + str(maxy) + " " + str(maxV))

Submission status: Wrong Answer

Solution code:
def solve(n):
    can = [[[-1, float('inf')] for _ in range(101)] for _ in range(101)]
    for k in range(1, n):
        x, y, h = map(int, input().split())
        for i in range(101):
            for j in range(101):
                hh = h + abs(x - i) + abs(y - j)
                hl = 1 if h == 0 else hh
                can[i][j][0] = max(can[i][j][0], hl)
                can[i][j][1] = min(can[i][j][1], hh)

    for i in range(101):
        for j in range(101):
            hl, hh = can[i][j]
            if hl != hh:
                continue
            return i, j, hl


n = int(input())
print(*solve(n))

Submission status: Wrong Answer

Solution code:
xlst = []
ylst = []
hlst = []
n = range(int(input()))
for i in n:
    xx, yy, hh = map(int, input().split())
    xlst += [xx]
    ylst += [yy]
    hlst += [hh]
for cx in range(min(xlst), max(xlst)+1):
    for cy in range(min(ylst), max(ylst)+1):
        hhlst = [hlst[i] + abs(xlst[i]-cx) + abs(ylst[i]-cy) for i in n]
        if len(list(set(hhlst))) == 1:
            print(cx, cy, max(hhlst))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
data = []
for _ in range(N):
    x, y, h = map(int, input().split())
    data.append((x, y, h))

for i in range(100+1):
    for j in range(100+1):
        H_cand = set([])
        for d in data:
            H_cand.add(abs(d[0] - i) + abs(d[1] - j) + d[2])
        H_cand = set([h for h in H_cand if h >= 1])
        if len(H_cand) == 1:
            print(i, j, list(H_cand)[0])
            break

Submission status: Wrong Answer

Solution code:
N = int(input())

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

H = []
xy = []
first = True
for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = max(h + abs(x-x1) + abs(y-y1), 0)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            tm = h0-abs(x-xy0[0])-abs(y-xy0[1])
            if h == max(0, tm):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH


print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

Submission status: Wrong Answer

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

for i in range(100, -1, -1):
    for j in range(100, -1, -1):
        height = -1
        for x, y, h in XYH:
            hi = abs(x - i) + abs(y - j) + h
            if h == 0:
                if abs(x - i) + abs(y - j) >= 0:
                    continue
                else:
                    break
            if height == -1:
                height = hi
            else:
                if height == hi:
                    continue
                else:
                    break
        else:
            if height >= 1:
                print(i, j, height)
                exit()

Submission status: Wrong Answer

Solution code:
import sys
Input = sys.stdin.readline

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = 0
H_temp = None

if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H < H_temp:
                    Cx = c_x
                    Cy = c_y
                    H = H_temp

print("{0} {1} {2}".format(Cx, Cy, H))

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
h = [0 for i in range(n)]
for i in range(n):
    x[i], y[i], h[i] = map(int, input().split())
for i in range(0, 101):
    for j in range(0, 101):
        for k in range(0, n):
            if h[k] != 0:
                k_l = k
                true_h = h[0] + int(math.fabs(x[0]-i)) + int(math.fabs(y[0]-j))
                break
        for k in range(k_l+1, n):
            if h[k] != 0:
                tmp_h = h[k] + int(math.fabs(x[k]-i)) + int(math.fabs(y[k]-j))
                if true_h != tmp_h:
                    break
        # print(k)
        if k == n-1:
            break
    if k == n-1:
        break
print("{} {} {}".format(i, j, true_h))

Submission status: Wrong Answer

Solution code:
N = int(input())
x, y, h = [], [], []
x2, y2, h2 = [], [], []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi == 0:
        x2.append(xi)
        y2.append(yi)
        h2.append(hi)
    else:
        x.append(xi)
        y.append(yi)
        h.append(hi)


def fn(H, X, Y, Cx, Cy):
    return H + abs(Cx - X) + abs(Cy - Y)

for Cx in range(101):
    for Cy in range(101):
        height = fn(h[0], x[0], y[0], Cx, Cy)
        flag = True
        for i in range(1, len(h)):
            if height != fn(h[i], x[i], y[i], Cx, Cy):
                flag = False
                break
        if flag:
            print(Cx, Cy, height)
            exit()

print(4)

Submission status: Wrong Answer

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

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

ans = 3*[0]

for i in range(101):
    for j in range(101):
        H = h[0] + abs(x[0] - i) + abs(y[0] - j)
        flag = 1
        for k in range(N):
            if(h[k] == 0): continue
            if(H != (h[k] + abs(x[k] - i) + abs(y[k] - j))):
                flag = 0
                break
        if(flag == 1):
            print("%d %d %d" %(i, j, H))
            exit()

Submission status: Wrong Answer

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

judge = 0
ans = [0, 0, 0]
for x in range(101):
    for y in range(101):
        judge = 0
        h = data[0][2] + abs(x-data[0][0]) + abs(y-data[0][1])
        for d in range(1, N):
            h_ = h - abs(x-data[d][0]) - abs(y-data[d][1])
            if data[d][2] == h_:
                continue
            else:
                judge = 1
                break
        if judge == 0:
            break
    if judge == 0:
        ans = [x, y, h]
        break


for i in ans:
    print(i, end=" ")

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        tl = []
        for l in xyh:
            h = abs(l[0] - i) + abs(l[1] - j) + l[2]
            tl.append(h)
        
        sl = set(tl)
        if len(sl) == 1:
            print("{} {} {}".format(i, j, tl[0]))
            exit(0)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

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

m=max(s)
l=0
ans=[]

for i in range(101):
    for j in range(101):
        for k in range(n):
            ans.append(abs(x[k]-i)+abs(y[k]-j)+h[k])
        if max(ans)==min(ans):
            print(i,j,ans[0])
        else:
            ans=[]

Submission status: Wrong Answer

Solution code:
xlst = []
ylst = []
hlst = []
n = range(int(input()))
for i in n:
    xx, yy, hh = map(int, input().split())
    xlst += [xx]
    ylst += [yy]
    hlst += [hh]
for cx in range(min(xlst), max(xlst)+1):
    for cy in range(min(ylst), max(ylst)+1):
        hhlst = [hlst[i] + abs(xlst[i]-cx) + abs(ylst[i]-cy) for i in n]
        if len(list(set(hhlst))) == 1:
            print(max(hhlst))
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
X_list = []
Y_list = []
H_list = []
for i in range(n):
    tmp1, tmp2, tmp3 = map(int, input().split())
    X_list.append(tmp1)
    Y_list.append(tmp2)
    H_list.append(tmp3)

X_max = max(X_list)
X_min = min(X_list)
Y_max = max(Y_list)
Y_min = min(Y_list)
flag = False
for x in range(X_min, X_max+1):
    for y in range(Y_min, Y_max+1):
        tmp = []
        for i in range(n):
            tmp.append(abs(X_list[i]-x) + abs(Y_list[i]-y)+H_list[i])
        if max(tmp) == min(tmp):
            flag = True
        if flag:
            break
    if flag:
        break
print(x, y, max(tmp))

Submission status: Wrong Answer

Solution code:
N = int(input())
Info = [list(map(int, input().split())) for i in range(N)]
Info_nonzero = []
highest = 0
for x, y, h in Info:
    if h != 0:
        Info_nonzero.append([x, y, h])

for x, y, h in Info:
    if h == 0:
        highest = max(highest, x + y)

for Cx in range(101):
    for Cy in range(101):
        candidate_set = set()
        for x, y, h in Info_nonzero:
            H = abs(Cx - x) + abs(Cy - y) + h
            candidate_set.add(H)

        ans_H = list(candidate_set)[0]
        if len(candidate_set) == 1:
            for x, y, h in Info:
                H = abs(Cx - x) + abs(Cy - y) + h
                if h == 0:
                    if not H > ans_H:
                        break

                if h != 0:
                    if not H <= ans_H:
                        break
            else:
                print(Cx, Cy, abs(Cx - Info_nonzero[0][0]) + abs(Cy - Info_nonzero[0][1]) + Info_nonzero[0][2])
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x, y, h = [], [], []
x2, y2, h2 = [], [], []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi == 0:
        x2.append(xi)
        y2.append(yi)
        h2.append(hi)
    else:
        x.append(xi)
        y.append(yi)
        h.append(hi)


def fn(H, X, Y, Cx, Cy):
    return H + abs(Cx - X) + abs(Cy - Y)

for Cx in range(101):
    for Cy in range(101):
        height = fn(h[0], x[0], y[0], Cx, Cy)
        flag = True
        for i in range(1, len(h)):
            if height != fn(h[i], x[i], y[i], Cx, Cy):
                flag = False
                break
        if flag:
            print(Cx, Cy, height)
            exit()

print(2)