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())
src = [tuple(map(int,input().split())) for i in range(N)]

INF = float('inf')
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
                if tmph > maxh:
                    break
            else:
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
                if maxh == 1:
                    tmph = 1
        else:
            assert tmph is not None
            print(cx,cy,tmph)
            exit()

Submission status: Wrong Answer

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

for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi == 0:
        continue
    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()

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):
    for i in range(n):
        x,y,h = card[i]
        if i == 0:
            H = abs(x-cx)+abs(y-cy)+h  
        
        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))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(n):
  x,y,h = map(int,input().split())
  a.append([x,y,h])
a.sort(key=lambda x:  -x[2])
def test(t,b,c):
  for k in a:
    if c - (abs(t - k[0]) + abs(b-k[1])) != k[2]:
      return False
  return True
for i in range(101):
  for j in range(101):
    h = abs(i-a[0][0]) + abs(j - a[0][1]) + a[0][2]
    if test(i,j,h):
      print(i,j,h)
      exit()

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):
        true_h = h[0] + int(math.fabs(x[0]-i)) + int(math.fabs(y[0]-j))
        for k in range(1, n):
            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:
import numpy as np
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))

Submission status: Wrong Answer

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

INF = float('inf')
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
                if tmph > maxh:
                    break
            else:
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
                if maxh == 1:
                    tmph = 1
        else:
            print(cx,cy,tmph)
            exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import itertools

N = int(input())
ta = [list(map(int,input().split())) for _ in range(N)]
for Cx, Cy in itertools.product(range(101),range(101)):
    # もしcx,cyが決まっていた場合矛盾が起こらないか
    # H = abs(x-cx)+abs(y-cy) + h
    H = None
    for [x,y,h] in ta:
        if h == 0:
            pass
        else:
            if H is None:
                H = h + abs(x-Cx)+abs(y-Cy)
            else:
                if H != h + abs(x-Cx)+abs(y-Cy):
                    break
    else:
        break
print(Cx,Cy,H)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


heights = []
N = getN()
xmax, ymax, xmin, ymin = (-1,0,0), (0,-1,0), (200,0,0), (0,200,0)

for i in range(N):
    data = getlist()
    x,y,h = data[0],data[1],data[2]
    heights.append(data)
    if x > xmax[0]:
        xmax = (x,y,h)
    if x < xmin[0]:
        xmin = (x,y,h)
    if y > ymax[1]:
        ymax = (x,y,h)
    if y < ymin[1]:
        ymin = (x,y,h)
ansx, ansy, ansh = 0,0,0
first = heights[0]
fx,fy,fh = first[0], first[1], first[2]
for x in range(0,101):
    for y in range(0,101):
        flag = 1
        cand_h = fh + abs(fx-x) + abs(fy-y)
        #print(cand_h, x,y)
        for i in range(1,N):
            comp = heights[i]
            if comp[2] != 0:
                if (comp[2] + abs(comp[0]-x) + abs(comp[1]-y)) != cand_h:
                    #print("break",x,y)
                    flag = 0

        if flag == 1:

            #print("success", x,y)
            ansx, ansy, ansh = x, y, cand_h

print(ansx,ansy,ansh)

Submission status: Wrong Answer

Solution code:
def cal(X,Y,H):

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

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 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)]
if n > 6:
    n = 6
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):
        true_h = h[0] + int(math.fabs(x[0]-i)) + int(math.fabs(y[0]-j))
        for k in range(1, n):
            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:
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

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 = abs(c_x - x) + abs(c_y - y) + h
            elif H != abs(c_x - x) + abs(c_y - y) + h:
                break
        else:
            Cx = c_x
            Cy = c_y
            print("{0} {1} {2}".format(Cx, Cy, H))
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

data=[]

for _ in range(N):
    x,y,h=map(int,input().split())
    if h:
        data.append([x,y,h])
 
def test():
    for cx in range(101):
        for cy in range(101):
            
            temph=data[0][2]+abs(data[0][0]-cx)+abs(data[0][1]-cy)
            flag=True
            
            for d in data[1:]:
                if d[2]+abs(d[0]-cx)+abs(d[1]-cy)!=temph:
                    flag=False
                    break
                
            if flag:
                print(cx,cy,temph)
                return
            
test()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]
H_pre = 0
for cx in range(101):
    for cy in range(101):
        for x, y, h in xyh:
            if h:
                if H_pre:
                    if H_pre != h + abs(x-cx) + abs(y-cy):
                        H_pre = 0
                        break
                else:
                    H_pre = h + abs(x-cx) + abs(y-cy)
        else:
            for x, y, h in xyh:
                if h:
                    if H_pre:
                        if H_pre != h + abs(x-cx) + abs(y-cy):
                            H_pre = 0
                            break
            else: 
                print(cx, cy, H_pre)
                exit()

Submission status: Wrong Answer

Solution code:
def big(a,b):
    if a >= b:
        return a
    else:
        return b

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

info.sort(key = lambda x: [2])
info.reverse()

check = False
for cx in range(101): 
    for cy in range(101):
        high = info[0][2] + abs(info[0][0]-cx) + abs(info[0][1]-cy)
        temp = True
        for i in range(1,n):
            if info[i][2] != big(high-abs(info[i][0]-cx)-abs(info[i][1]-cy),0):
                temp = False
        if temp:
            check = True
            break
    if check:
        break
print(cx,cy,high)

Submission status: Wrong Answer

Solution code:
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())
test=True
for i in range(0,101):
    for j in range(0,101):
        test=True
        h1=abs(i-x[0])+abs(j-y[0])+h[0]
        for k in range(1,n):
            if h1!=abs(i-x[k])+abs(j-y[k])+h[k]:
                test=False
                break;
        if test==True:
            print(i,j,h1)

Submission status: Wrong Answer

Solution code:
import itertools as it
import collections as col
import bisect

import sys
sys.setrecursionlimit(10000)

def main():
    N = int(input())
    coords = [tuple([int(x) for x in input().split()]) for _ in range(N)]
    
    for guess in it.product(range(101), repeat=2):
        okay = True
        c = coords[0]
        prev_h = c[2] + abs(guess[1] - c[1]) + abs(guess[0] - c[0])
        for c in coords:
            height_diff = abs(guess[1] - c[1]) + abs(guess[0] - c[0])
            if c[2] == 0:
                if prev_h < height_diff:
                    okay = False
                    break
                    
            h = c[2] + height_diff
            if h != prev_h:
                okay = False
                break
        
        if okay:
            return '{} {} {}'.format(guess[0], guess[1], prev_h)
    
if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
can = [[0] * 101 for _ in range(101)]


def solve(n, can):
    f = True
    for k in range(1, n):
        x, y, h = map(int, input().split())
        if h == 0:
            continue
        if f:
            for i in range(101):
                for j in range(101):
                    can[i][j] = h + abs(x - i) + abs(y - j)
            f = False
        else:
            for i in range(101):
                for j in range(101):
                    if can[i][j] is None:
                        continue
                    if h + abs(x - i) + abs(y - j) != can[i][j]:
                        can[i][j] = None
    for i in range(101):
        for j in range(101):
            if can[i][j] is None:
                continue
            return i, j, can[i][j]


print(*solve(n, can))

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)

cx_cand = range(101)
cy_cand = range(101)
end_flag = False
for cx in cx_cand:
    for cy in cy_cand:

        temp = h + np.abs(x - cx) + np.abs(y - cy)                 
        temp2 = h - np.abs(x - cx) - np.abs(y - cy)                 
        unuse = (temp2 < 0) * (h == 0)
#         if cx == 2:
#             if cy == 2:
#                 aaa
        temp = temp[unuse == False]

        if np.max(temp)== np.min(temp):
            end_flag = True
            break
    if end_flag:
        break
if end_flag:
    a = h>0
    print(cx,cy,h[a][0] + np.abs(x[a][0] - cx) + np.abs(y[a][0] - cy))
else:
    aaaaaaaa

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff=min(h)
h=[i-diff for i in h]
def pattern(cx,cy,H):
    for i in range(n):
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Submission status: Wrong Answer

Solution code:
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] = [int(i) for i in input().split()]

height = 0
for i in range(101):
    for j in range(101):
        flag = 0
        okFlag = 1
        height_tmp = 0
        output = [0, 0, 0]
        for k in range(n):
            if h[k] == 0:
                continue
            if flag == 0:
                height_tmp = h[k] + abs(x[k] - i) + abs(y[k] - j)
                flag = 1
            else:
                if height_tmp != h[k] + abs(x[k]-i) + abs(y[k]-j):
                    okFlag = 0
                    break
                elif k == n-1:
                    if height_tmp == h[k] + abs(x[k] - i) + abs(y[k] - j):
                        output = [i, j, height_tmp]
                        okFlag = 1
                        #print("{} {} {}".format(i, j, height_tmp))
                        #exit()
        if okFlag == 1:
            print("{} {} {}".format(i, j, height_tmp))
            exit()

Submission status: Wrong Answer

Solution code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
xyh = []
xyh.sort(key=lambda x: x[2])
for _ in range(n):
    xyh.append(ai())

for cx in range(101):
    for cy in range(101):
        H = []
        d = []
        for x,y,h in xyh:
            H.append(h+abs(cx-x)+abs(cy-y))
            d.append(abs(cx-x)+abs(cy-y))
        hh = max(H)
        f = 0
        for i in range(n):
            if (d[i]>=hh and H[i] > hh) or (d[i] < hh and H[i] == hh):
                continue
            else:
                f = 1
                break
        if f == 0:
            print(cx,cy,hh)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
can = [[0] * 101 for _ in range(101)]


def solve(n, can):
    x, y, h = map(int, input().split())
    f = True
    for k in range(1, n):
        x, y, h = map(int, input().split())
        if h == 0:
            continue
        if f:
            for i in range(101):
                for j in range(101):
                    can[i][j] = h + abs(x - i) + abs(y - j)
            f = False
        else:
            for i in range(101):
                for j in range(101):
                    if can[i][j] is None:
                        continue
                    if h + abs(x - i) + abs(y - j) != can[i][j]:
                        can[i][j] = None
    for i in range(101):
        for j in range(101):
            if can[i][j] is None:
                continue
            return i, j, can[i][j]


print(*solve(n, can))

Submission status: Wrong Answer

Solution code:
n = int(input())

positions = [list(map(int, input().split(" "))) for i in range(n)]
print(max(list(map(lambda x: x[2], positions))))

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = [list(map(lambda x:int(x),input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        H = max(lists[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i),0)
        for k in range(1,n):
            if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) >=0:
                if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) != H:
                    break
                else :
                    if k == n-1:
                        print(i,j,lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i))

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
data = []
for i in range(N):
    v = map(int, raw_input().split())
    data.append(v)

for x in range(100+1):
    for y in range(100+1):
        h = []
        for d in data:
            if d[2] != 0:
                h.append(d[2] + abs(d[0]-x) + abs(d[1]-y))
        if len(set(h)) == 1:
            print x, y, h[0]

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 not h == max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print('{} {} {}'.format(cx,cy,H))
                break
        else:
            continue
        break
    else:
        continue
    break

Submission status: Wrong Answer

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

j = -1
for i in range(N):
    x[i],y[i],h[i] = map(int,input().split(" "))
    if h[i] !=  0:
        j = i 
        
H = 1
if j == (-1):
    for cx in range(0,101):
        for cy in range(0,101):
            for i in range(N):
                H = min(H,(abs(x[i]-cx) + abs(y[i]-cy)))

            if H > 0:
                print("{0} {1} {2}".format(cx,cy,H))
                exit(0)

for cx in range(0,101):
    for cy in range(0,101):
        H = h[j] + abs(x[j]-cx) + abs(y[j]-cy)
        flg = True
        for i in range(N):
            if (h[i] == 0 and ((abs(x[i]-cx) + abs(y[i]-cy))) < H):
                flg = False
                break
            if H != (h[i] + abs(x[i]-cx) + abs(y[i]-cy)):
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx,cy,H))
            exit(0)

Submission status: Wrong Answer

Solution code:
import sys

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

for cx in range(101):
    for cy in range(101):
        x, y, h= coordinates[0]
        H = h + abs(x-cx) + abs(y-cy)
        i = 1
        for x, y, h in coordinates[1:]:
            if not h == max(H - abs(x-cx) - abs(y-cy), 0):
                break
            else:
                i += 1
                if i == N:
                    print(cx, cy, H)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XYH):
    XYH.sort(key=lambda x: x[2], reverse=True)
    MM = 101
    M = [[1] * MM for _ in range(MM)]
    for r ,(x, y, h) in enumerate(XYH):
        if h == 0:
            M[x][y] = 0
            continue
        for i in range(MM):
            for j in range(MM):
                t = abs(i-x) + abs(j - y) + h
                if r == 0:
                    M[i][j] = t
                else:
                    if M[i][j] != t:
                        M[i][j] = 0
    
    for i in range(MM):
        for j in range(MM):
            if M[i][j] != 0:
                return '%d %d %d' % (i, j, M[i][j])
    
    assert False


def main():
    N = read_int()
    XYH = [read_int_n() for _ in range(N)]
    print(slv(N, XYH))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
for i in range(N):
  x1=list(map(int,input().split()))
  list1.append(x1)
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=[]
      for l in range(N):
         d=Hx-abs(list1[l][0]-i)-abs(list1[l][1]-j)
         list3.append(d)
      list3.sort()
      if list3[0]>=0:
         print(i,j,Hx)
      else:
        pass
    else:
      continue

Submission status: Wrong Answer

Solution code:
import copy
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)
x1 = []
y1 = []
h1 = []
for i in range(101):
    for j in range(101):
        k = h[0]+abs(i-x[0])+abs(j-y[0])
        x1.append(i)
        y1.append(j)
        h1.append(k)
q = 1
while 1:
    x2 = []
    y2 = []
    h2 = []
    for i in range(len(x1)):
        if max(h1[i]-abs(x1[i]-x[q])-abs(y1[i]-y[q]),0) == h[q]:
            x2.append(x1[i])
            y2.append(y1[i])
            h2.append(h1[i])
    x1 = copy.deepcopy(x2)
    y1 = copy.deepcopy(y2)
    h1 = copy.deepcopy(h2)
    if len(x1) == 1:
        break
    q += 1
print(x1[0],y1[0],h1[0])

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
x = np.array([xyh[i][0] for i in range(N)])
y = np.array([xyh[i][1] for i in range(N)])
h = np.array([xyh[i][2] for i in range(N)])
for Cx in range(101):
    for Cy in range(101):
        H = h + list(map(abs, [xi - Cx for xi in x])) + list(map(abs, [yi - Cy for yi in y]))
        if len(set(H)) == 1:
            break
    else:
        continue
    break
H = list(set(H))
print("{} {} {}".format(Cx, Cy, H[0]))

Submission status: Wrong Answer

Solution code:
import sys
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
x = 0
y = 0
while y <= 100:
  x = 0
  while x <= 100:
    lis = []
    for arrays in grid:
      lis.append(arrays[2]+abs(x-arrays[0])+abs(y-arrays[1]))
    if min(lis)==max(lis):
      print(x,y,max(0,arrays[2]+abs(x-arrays[0])+abs(y-arrays[1])))
      sys.exit()
    x += 1
  y += 1

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 = max(h[0] + abs(x[0] - i) + abs(y[0] - j), 0)
        flag = 1
        for k in range(N):
            if(H != max((h[k] + abs(x[k] - i) + abs(y[k] - j)), 0)):
                flag = 0
                break
        if(flag == 1):
            if(H > ans[2]):
                ans[0] = i
                ans[1] = j
                ans[2] = H

print("%d %d %d" %(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
a = int(input())

b = []

c = []

p = 0
pp = 0
ppp = 0
for i in range(a):
    b.append(list(map(int,input().split())))

for i in range(0,101):
    for j in range(0,101):
        for k in range(a):
            if k == 0:
                p = abs(b[k][0] - i) + abs(b[k][1]-j)+b[k][2]
                if b[k][2] == 0:
                    pp == 1
                    break
            else:
                if max(0,p - abs(b[k][0]-i)- abs(b[k][1]-j)) != b[k][2]:
                    pp = 1
        if pp == 0:
            ppp = 1
            break
        else:
            pp = 0
    if ppp == 1:
        print(i,j,p)
        break

Submission status: Wrong Answer

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

if n>=4:
 l=[l[0],l[1],l[n-2],l[n-1]]
 for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]==abs(l[2][0]-x)+abs(l[2][1]-y)+l[2][2]==abs(l[3][0]-x)+abs(l[3][1]-y)+l[3][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
elif n>=3:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]==abs(l[2][0]-x)+abs(l[2][1]-y)+l[2][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
else:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff=max(h)-min(h)
h=[i-diff for i in h]
def pattern(cx,cy,H):
    for i in range(n):
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Submission status: Wrong Answer

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

j = -1
for i in range(N):
    x[i],y[i],h[i] = map(int,input().split(" "))
    if h[i] !=  0:
        j = i 
        
H = 1
if j == (-1):
    for cx in range(0,101):
        for cy in range(0,101):
            for i in range(N):
                H = min(H,(abs(x[i]-cx) + abs(y[i]-cy)))

            if H > 0:
                print("{0} {1} {2}".format(cx,cy,H))
                exit(0)

for cx in range(0,101):
    for cy in range(0,101):
        H = h[j] + abs(x[j]-cx) + abs(y[j]-cy)
        flg = True
        for i in range(N):
            if (h[i] == 0 and (abs(x[i]-cx) + abs(y[i]-cy)) < H):
                flg = False
                break
            if H != (h[i] + abs(x[i]-cx) + abs(y[i]-cy)):
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx,cy,H))
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
data = []
for i in range(N):
    v = map(int, raw_input().split())
    data.append(v)

for x in range(100+1):
    for y in range(100+1):
        h = []
        for d in data:
            tmph = d[2] + abs(d[0]-x) + abs(d[1]-y)
            if tmph > 0:
                h.append(tmph)
        if len(set(h)) == 1:
            print x, y, h[0]

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    temp = [int(_) for _ in input().split(' ')]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])

for cx in range(101):
    for cy in range(101):
        ch = -1
        correctness = True
        for i in range(n):
            if ch > 0:
                if h[i] != max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0):
                    correctness = False
            if h[i] > 0:
                ch = h[i] + abs(cx - x[i]) + abs(cy - y[i])
        if correctness:
            print('{0} {1} {2}'.format(cx, cy, ch))