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:
N = int(input())
X = []
Y = []
H = []
L = []
for i in range(N) :
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    L.append([x,y,h])
maxH = max(H)
if H.count(maxH) == 1 :
    for j in range(N) :
        if H[j] == maxH :
            print(X[j],Y[j],maxH)
            break
else :
    P = []
    Q = []
    for k in range(N) :
        if H[k] == maxH :
            P.append(X[k])
            Q.append(Y[k])
    if len(P) == 2 and len(Q) == 2 :
        for l in range(N) :
            if P[0] == L[l][0] and Q[1] == L[l][1] :
                answerX = P[1]
                answerY = Q[0]
                answerH = maxH + abs(P[0]-P[1])
                print(answerX,answerY,answerH)
                
            elif P[1] == L[l][0] and Q[0] == L[l][1] :
                answerX = P[0]
                answerY = Q[1]
                answerH = maxH + abs(P[0]-P[1])
                print(answerX,answerY,answerH)
                
    elif len(P) == 2 :
        Q = sorted(Q)
        answerY = Q[N//2]
        answerX = (min(Q)+max(Q))//2
        answerH = maxH + (max(Q)-min(Q))
        print(answerX,answerY,answerH)
        
    elif len(Q) == 2 :
        P = sorted(P)
        answerX = P[N//2]
        answerY = (min(P)+max(P))//2
        answerH = maxH + (max(P)-min(P))
        print(answerX,answerY,answerH)
        
    else :
        answerX = (min(X)+max(X))//2
        answerY = (min(Y)+max(Y))//2
        answerH = maxH + (max(P)-min(P))-1
        print(answerX,answerY,answerH)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num_of_data = int(input())

distances = [[[0 for i in range(101)] for j in range(101)] for k in range(3)] #入力した地点からの距離
positions = [[0 for i in range(3)] for j in range(3)]
ans = [-1, -1, 10000000000]

for i in range(num_of_data):
    xyh = input().strip().split()
    positions[i][0] = int(xyh[0])
    positions[i][1] = int(xyh[1])
    positions[i][2] = int(xyh[2])
    if i == 2:
        break
    
for i in range(3):
    for x in range(101):
        for y in range(101):
            distances[i][x][y] = abs(positions[i][0] - x) + abs(positions[i][1] - y)
            
for x in range(101):
    for y in range(101):
        height = positions[0][2] + distances[0][x][y]
        if height == 0:
            break
        # if (positions[1][2] + distances[1][x][y] == height and positions[2][2] + distances[2][x][y] == height) or (positions[1][2] - distances[1][x][y] == height and positions[2][2] + distances[2][x][y] == height) or (positions[1][2] + distances[1][x][y] == height and positions[2][2] - distances[2][x][y] == height) or (positions[1][2] - distances[1][x][y] == height and positions[2][2] - distances[2][x][y] == height):
        if positions[1][2] + distances[1][x][y] == height and positions[2][2] + distances[2][x][y] == height:
            if height < ans[2]:
                ans = [x, y, height]
            
# if ans == [-1, -1, -1]:
#     for x in range(101):
#         for y in range(101):
#             height = positions[0][2] - distances[0][x][y]
#             if height <= 0:
#                 break
#             if (positions[1][2] + distances[1][x][y] == height and positions[2][2] + distances[2][x][y] == height) or (positions[1][2] - distances[1][x][y] == height and positions[2][2] + distances[2][x][y] == height) or (positions[1][2] + distances[1][x][y] == height and positions[2][2] - distances[2][x][y] == height) or (positions[1][2] - distances[1][x][y] == height and positions[2][2] - distances[2][x][y] == height):
#                 ans = [x, y, height]
            
print(str(ans[0]) + " " + str(ans[1]) + " " + str(ans[2]))

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(101):
    for Cy in range(101):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and H[i] == max(h - abs(X[i]-Cx) + abs(Y[i]-Cy), 0):
            i += 1
        if i == N:
            print(Cx, Cy, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            if np.max(temp2[h > 0]) <= 10**9 + 1:
                cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>50:
    k = 52
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            if np.max(temp2[h > 0]) <= 10**9 + 1:
                cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>50:
    k = 51
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

Solution code:
pattern = int(input())

xs = []
ys = []
hs = []


for _ in range(pattern):
    x, y , h = map(int,input().split(' '))
    xs.append(x)
    ys.append(y)
    hs.append(h)

correct = 0

max_h = max(hs) + 101

for Cx in range(101):
    for Cy in range(101):
        for H in range(max(hs), max_h):
            for x, y, h in zip(xs, ys, hs):
                if abs(x-Cx) + abs(y-Cy) == abs(h-H):
                    correct += 1
                    if correct == len(xs) and max(hs) <= H:
                        print(Cx, Cy, H)
                else:
                    correct = 0
                    continue

Submission status: Wrong Answer

Solution code:
n = int(input())

idx = 0

lx = []
ly = []
lh = []

cdx = -1
cdy = -1
cdh1 = -1
cdh2 = -1

while idx < n:
    a, b, c = map(int, input().split())
    lx.append(a)
    ly.append(b)
    lh.append(c)
    idx = idx + 1

idx = 0
while idx < n:
    idx2 = idx + 1
    while idx2 < n:
        if lx[idx] == lx[idx2]:
            if lh[idx] == lh[idx2]:
                cdy = ly[idx2] + (ly[idx] - ly[idx2]) / 2
                cdh1 = lh[idx] + abs(ly[idx] - ly[idx2]) / 2

        if ly[idx] == ly[idx2]:
            if lh[idx] == lh[idx2]:
                cdx = lx[idx2] + (lx[idx] - lx[idx2]) / 2
                cdh2 = lh[idx] + abs(lx[idx] - lx[idx2]) / 2
        idx2 = idx2 + 1
    idx = idx + 1

print(str(cdx) + ' ' + str(cdy) + ' ' + str(cdh1))

Submission status: Wrong Answer

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

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

def check(cx,cy):
    Hs = []
    
    for i in range(n):
        x,y,h = card[i]
        z = abs(x-cx)+abs(y-cy)+h
        Hs.append(z)
    
    H = min(Hs)
        
    for i in range(n):
        x,y,h = card[i]
        if h == 100:
            print("{} {} {}".format(x,y,h))
            exit()

        if h == max((H-abs(x-cx)-abs(y-cy)),0):
            continue
        else:
            return False
    else:
        return True
    
for i in range(101):
    for j in range(101):
        if check(i,j):
            ax = i
            ay = j
            
            x1,y1,h1 = card[0]
            ah = abs(x1-i)+abs(y1-j)+h1

            print("{} {} {}".format(ax,ay,ah))
            exit()

Submission status: Wrong Answer

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

# 中心座標(Cx,Cy)を全通り試す
for Cx in range(101):
    for Cy in range(101):
        x, y, h = xyhs[-1]
        H = h + abs(Cx - x) + abs(Cy - y)
        for x, y, h in reversed(xyhs[:-1]):
            H2 = h + abs(Cx - x) + abs(Cy - y)
            if H != H2:
                break
            elif h == 0 and H2 < H:
                break
        else:
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

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

x, y, h = P[-1]
max_h = max(100-x, x, 100-y, y) + h + 1
max_h = min(max_h, 10**9)

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h, P[-1][2]-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            if hh - dx - dy != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))

Submission status: Wrong Answer

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

hlist = []
argx = []
argy = []
for k in range(N):
    tmplist = []
    tmpx = []
    tmpy = []
    for i in range(101):
        for j in range(101):
            if x[k] <= i and y[k] <= j:
                tmplist.append(h[k] - x[k] + i - y[k]  + j)
            elif x[k] <= i and y [k] >= j:
                tmplist.append(h[k] - x[k] + i + y[k]  - j)
            elif x[k] >= i and y [k] <= j:
                tmplist.append(h[k] + x[k] - i - y[k]  + j)
            elif x[k] > i  and y[k] > j:
                tmplist.append(h[k] + x[k] - i + y[k]  - j)

            tmpx.append(i)
            tmpy.append(j)

    hlist.append(tmplist)
    argx.append(tmpx)
    argy.append(tmpy)

for i in range(10201):
        lis = []
        for k in range(N):
            lis.append(hlist[k][i])
        if lis.count(hlist[k][i]) == N:
            print(argx[k][i],argy[k][i],hlist[k][i],sep=" ")
            exit()

Submission status: Wrong Answer

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

x=[]
y=[]
h=[]
H=[]
for i in range(n):
    x1,y1,h1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    h.append(h1)


for cx in range(101):
  for cy in range(101):
    for i in range(n):
      if h[i]==0:
        continue
      H1=abs(x[i]-cx)+abs(y[i]-cy)+h[i]
      print(i,x[i],y[i],cx,cy,H1)
      H.append(H1)
    if len(set(H))==1:
      ansx=cx
      ansy=cy
      ansh=H1
      print(ansx,ansy,ansh)
      sys.exit()
    else:
      H=[]

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            if np.max(temp2[h > 0]) <= 10**9:
                cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>50:
    k = 51
    print(cand[-k][0],cand[-k][1],cand[-k][2])

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
res  = []
for x in range(X_min, X_max+1):
    for y in range(Y_min, Y_max+1):
        tmp = []
        tmp2 = []
        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])
            else:
                tmp2.append(abs(X_list[i]-x) + abs(Y_list[i]-y)+H_list[i])
                
        if max(tmp) == min(tmp):
            res.append([x, y, max(tmp)])
        if max(tmp+tmp2) == min(tmp+tmp2):
            res.append([x, y, max(tmp)])
#         if flag:
#             break
#     if flag:
#         break
a = 0
res = res[0]
print(res[0], res[1], res[2])

Submission status: Wrong Answer

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

XY = [[True] * 101 for _ in range(101)]

for i in range(N-1):
    tmp = xyh[i][2] - xyh[i+1][2]
    for x in range(101):
        for y in range(101):
            if not XY[y][x]: 
                continue
            if abs(x-xyh[i][0]) + abs(y-xyh[i][1]) != abs(x-xyh[i+1][0]) + abs(y-xyh[i+1][1]) - tmp:
                XY[y][x] = False

for x in range(101):
    for y in range(101):
        if XY[y][x]:
            print(x,y,abs(x-xyh[0][0]) + abs(y-xyh[0][1]) + xyh[0][2])
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
xyh0 = []
for i in range(0,n):
    X,Y,h = map(int,input().split())
    if h != 0:
        xyh.append((X,Y,h))
    else:
        xyh0.append((X,Y))
ans = []
for i in range(0,101):
    for j in range(0,101):
        flag = "f"
        if len(xyh)>0:
            x,y,h = xyh[0]
            H = h + abs(x-i)+abs(y-j)
            flag = "t"
        for x,y,h in xyh:
            if H !=  h + abs(x-i)+abs(y-j):
                flag = "f"
                break
        if flag == "t":
            ans.append((i,j,H))
if len(ans) > 0:
    for i,j,H in ans:
        for x,y in xyh0:
            if H < h + abs(x-i)+abs(y-j):
                break
        ans = [(i,j,H)]
        if len(ans) == 1:
            break
# if len(ans) == 0:
#     x = [0 for i in range(0,101)]
#     y = [0 for i in range(0,101)]
#     for i,j in xyh0:
#         x[i] = 1
#         y[j] = 1
#     for xx in x:
#         if xx == 0:
#             break
#     for yy in y:
#         if xx == 0:
#             break
#     ans = [(xx,yy,1)]
x,y,h = ans[0]
print(x,y,h)













#

Submission status: Wrong Answer

Solution code:
def H(h,cx,cy,x,y):
    return h+abs(cx-x)+abs(cy-y)
 
n = int(input())
arr=[]
for i in range(n):
    arr.append(list(map(int, input().split())))
isSame = True
for cx in range(0,101):
    for cy in range(0,101):
        isSame = True
        h_prev=-1
        for a in arr:
            h= H(a[2],cx,cy,a[0],a[1])
            if a[2]>0 or h==a[2]:
                if h_prev==-1:
                    h_prev=h
                if h!=h_prev:
                    isSame=False
                    break
                else:
                    h_prev=h
        if isSame==True:
            print("{} {} {}".format(cx,cy,h))
            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 = None
 
x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
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_tmp):
                if i == 0:
                    H = abs(c_x - x) + abs(c_y - y) + h
                elif H != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if len(x_y_h_tmp) == len([xyh for xyh in x_y_h if H - abs(c_x - xyh[0]) - abs(c_y - xyh[1]) >= 0]):
                    Cx = c_x
                    Cy = c_y
                    print("{0} {1} {2}".format(Cx, Cy, H))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
import itertools


def height(x, y, Cx, Cy, H):
    return max([H - abs(x - Cx) - abs(y - Cy), 0])


N = int(sys.stdin.readline().strip())

set_list = []
for line in sys.stdin.readlines():
    x, y, h = list(map(int, line.strip().split()))
    if h == 0:
        continue
    ans_set = set()
    for Cx, Cy in itertools.product(range(101), range(101)):
        dx = abs(x - Cx)
        dy = abs(y - Cy)
        d = dx + dy
        H = h + d
        if H >= d:
            ans_set.add((Cx, Cy, H))
    set_list.append(ans_set)

ans_set = set_list[0]
for s in set_list[1:]:
    ans_set = ans_set & s

if len(ans_set) == 1:
    Cx, Cy, H = list(ans_set)[0]
    print(Cx, Cy, H)
else:
    for s in set_list:
        Cx, Cy, H = list(ans_set)[0]
        if H >= 1:
            print(Cx, Cy, H)
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
left = 0
right = 100
up = 100
down = 0
lis = []
x = []
y = []
m = []
for i in range(n):
  a = list(map(int,input().split()))
  lis.append(a)
  x.append([a[0],a[1],a[2]])
  y.append([a[1],a[0],a[2]])
  m.append([a[2],a[0],a[1]])
x.sort()
y.sort()
m.sort(reverse = True)
for i in range(n-1):
  if x[i][0] == x[i+1][0]:
    if x[i][2] > x[i+1][2]:
      up = min(up,x[i][1])
    elif x[i][2] < x[i+1][2]:
      down = max(down,x[i+1][1])
    else:
      up = min(up,x[i+1][1])
      down = max(down,x[i][1])
      
  if y[i][0] == y[i+1][0]:
    if y[i][2] > y[i+1][2]:
      right = min(right,y[i][1])
    elif y[i][2] < y[i+1][2]:
      left = max(left,y[i+1][1])
    else:
      right = min(right,y[i+1][1])
      left = max(left,y[i][1])
if up == 100 and down == 0 and right == 100 and left == 0:
  print(m[0][1],m[0][2],m[0][0])
  exit()
ansx = (right+left)//2
ansy = (up+down) // 2
print(ansx,ansy,abs(ansx-x[0][0])+abs(ansy-x[0][1])+x[0][2])

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]
stopflag = False

if sum(hs) == 0:
    H = 1
    for cx in range(101):
        if cx not in xs:
            x_ans = cx
    for cy in range(101):
        if cy not in ys:
            y_ans = cy
    print('{} {} {}'.format(x_ans,y_ans,H))

else:
    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))
                    stopflag = True
                    break
            if stopflag:
                break
        if stopflag:
            break

Submission status: Wrong Answer

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):
        ans = 1
        H = 1
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = max(abs(x - CX) + abs(y - CY) + h, h)
            if H < 1:
                ans = -1
                break
            #print(CX, CY)
            
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if h != max(H - abs(x - CX) - abs(y - CY), 0):
                ans = -1
                break
        if H < 1:
            ans = -1
            
        if ans == 1:
            print(CX, CY, H)
            break
    if ans == 1:
        break

Submission status: Wrong Answer

Solution code:
def H(h,cx,cy,x,y):
    return h+abs(cx-x)+abs(cy-y)
 
n = int(input())
arr=[]
for i in range(n):
    arr.append(list(map(int, input().split())))
isSame = True
for cx in range(0,101):
    for cy in range(0,101):
        isSame = True
        h_prev=-1
        for a in arr:
            h= H(a[2],cx,cy,a[0],a[1])
            if a[2]>0 or h_prev==a[2]:
                if h_prev==-1:
                    h_prev=h
                if h!=h_prev:
                    isSame=False
                    break
                else:
                    h_prev=h
        if isSame==True:
            print("{} {} {}".format(cx,cy,h))
            exit

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>5:
    for k in range(len(cand)):
        if cand[k][2] <= 10**9:
            print(cand[k][0],cand[k][1],cand[k][2])
            break

Submission status: Wrong Answer

Solution code:
n = int(input())

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)
    
end = 0

for x in range(101):
    for y in range(101):
        H = info[0][2] + abs(x-info[0][0]) + abs(y-info[0][1])
        for i in range(1,n):
            if info[i][2] != max(0,H - abs(x-info[i][0]) - abs(y- info[i][1])):
                break
        else:
            print(x,y,H)
            end = 1
            
        if end == 1:
            break
    if end == 1:
        break
# elif n ==2:
#     info = sorted(info, key = lambda x:x[2])
#     if info[0][0] > info[1][0]:
#         h = info[1][2] + info[1][0]
#         x = 0
#     else:
#         h = info[1][2] + 100- info[1][0]
#         x = 100
#     if info[0][1] > info[1][1]:
#         h += info[1][1]
#         y = 0
#     else:
#         h += 100 - info[1][1]
#         y =100
#     ans = list(map(str,(x,y,h)))
#     print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
Y = []
H = []
L = []
for i in range(N) :
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    L.append([x,y,h])
maxH = max(H)
if H.count(maxH) == 1 :
    for j in range(N) :
        if H[j] == maxH :
            print(X[j],Y[j],maxH)
            break
else :
    P = []
    Q = []
    for k in range(N) :
        if H[k] == maxH :
            P.append(X[k])
            Q.append(Y[k])
    if len(P) == 2 and len(Q) == 2 :
        for l in range(N) :
            if P[0] == L[l][0] and Q[1] == L[l][1] :
                answerX = P[1]
                answerY = Q[0]
                answerH = maxH + abs(P[0]-P[1])
                print(answerX,answerY,answerH)
                
            elif P[1] == L[l][0] and Q[0] == L[l][1] :
                answerX = P[0]
                answerY = Q[1]
                answerH = maxH + abs(P[0]-P[1])
                print(answerX,answerY,answerH)
                
    elif len(P) == 2 :
        Q = sorted(Q)
        answerY = Q[N//2]
        answerX = (min(Q)+max(Q))//2
        answerH = maxH + (min(Q)+max(Q))//2-1
        print(answerX,answerY,answerH)
        
    elif len(Q) == 2 :
        P = sorted(P)
        answerX = P[N//2]
        answerY = (min(P)+max(P))//2
        answerH = maxH + (min(P)+max(P))//2-1
        print(answerX,answerY,answerH)
        
    else :
        answerX = (min(X)+max(X))//2
        answerY = (min(Y)+max(Y))//2
        answerH = maxH + (min(P)+max(P))//2-1
        print(answerX,answerY,answerH)

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>5:
    k = 98
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

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):
        ans = 1
        H = 1
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = abs(x - CX) + abs(y - CY) + h
            if H < 1:
                ans = -1
                break
            #print(CX, CY)
            
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if H != abs(x - CX) + abs(y - CY) + h:
                ans = -1
                break
            if h != max(H - abs(x - CX) - abs(y - CY), 0):
                ans = -1
                break
        if H < 1:
            ans = -1
            
        if ans == 1:
            print(CX, CY, H)
            break
    if ans == 1:
        break

Submission status: Wrong Answer

Solution code:
def cal(X,Y,H):
    
    c=0
    for i in range(N):
        if(H[i]==0):    c+=1

    for i in range(0,101):
        for j in range(0,101):
            temp=H[c]+abs(X[c]-i)+abs(Y[c]-j)
            for l in range(c+1,N):
                if(H[l]!=0):
                    s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                    if(temp==s):
                        temp=s
                    else:
                        break
                else:
                    if(temp-abs(X[l]-i)-abs(Y[l]-j)>0):
                        break
            else:
                for m in range(0,c):
                    if(temp-abs(X[c]-i)-abs(Y[c]-j)>0):
                        break
                else:
                    return print("{} {} {}".format(i,j,temp))

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(101):
    for Cy in range(101):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and h == H[i] + abs(X[i]-Cx) + abs(Y[i]-Cy):
            i += 1
        if i == N:
            print(Cx, Cy, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>5:
    k = 50
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

Solution code:
N = int(input())

def get_cands(x, y, h):
    if h > 0:
        for xc in range(100 + 1):
            for yc in range(100 + 1):
                hc = h + abs(xc - x) + abs(yc - y)
                if hc <= 10**9:
                    yield (xc, yc, hc)
    else:
        for xc in range(100 + 1):
            for yc in range(100 + 1):
                hc = h + abs(xc - x) + abs(yc - y)
                for hc2 in range(1, hc + 1):
                    yield (xc, yc, hc2)

x1, y1, h1 = map(int, input().split())
cand = set(get_cands(x1, y1, h1))

for _ in range(1, N):
    new_cand = set()
    x, y, h = map(int, input().split())
    for c in get_cands(x, y, h):
        if c in cand:
            new_cand.add(c)
    cand = new_cand
    if len(cand) == 1:
        break
if len(cand) == 1:
    print(*next(iter(cand)))
else:
    import time
    time.sleep(0.01 * len(cand))

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>5:
    k = 3
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

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

x, y, h = P[-1]
max_h = max(100-x, x, 100-y, y) + h + 1

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h, P[-1][2]-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            if hh - dx - dy != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))