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())
xyh = []
for _ in range(N):
    x, y, h = map(int, input().split())
    xyh.append([x, y, h])

ansX = 0
ansY = 0
ansH = 0
for cx in range(0, 101):
    for cy in range(0, 101):
        H = 0
        for x, y, h in xyh:
            if h == 0:
                if H > abs(x - cx) + abs(y - cy):
                    H = -1
                    break
                continue
            if H == 0:
                H = h + abs(x - cx) + abs(y - cy)
            elif H != h + abs(x - cx) + abs(y - cy):
                H = -1
            if H == -1:
                break
        if H > 0:
            ansH = H
            ansX = cx
            ansY = cy
            break
    if ansH > 0:
        break

print(ansX, ansY, ansH)

Submission status: Wrong Answer

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

ansX = 0
ansY = 0
ansH = 0
for cx in range(0, 101):
    for cy in range(0, 101):
        H = 0
        for x, y, h in xyh:
            if h == 0:
                continue
            if H == 0:
                H = h + abs(x - cx) + abs(y - cy)
            elif H != h + abs(x - cx) + abs(y - cy):
                H = -1
            if H == -1:
                break
        if H > 0:
            ansH = H
            ansX = cx
            ansY = cy
            break
    if ansH > 0:
        break

print(ansX, ansY, ansH)

Submission status: Wrong Answer

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

for cx in range(0, 101):
    for cy in range(0, 101):
        H = 0
        for x, y, h in xyh:
            if h == 0:
                continue
            if H == 0:
                H = h + abs(x - cx) + abs(y - cy)
            else:
                if H != h + abs(x - cx) + abs(y - cy):
                    H = -1
            if H == -1:
                break
        if H > 0:
            break
    if H > 0:
        break

print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = {}
for _ in range(N):
    x, y, h = map(int, input().split())
    if not (x, y) in d:
        d[(x, y)] = h
    else:
        d[(x, y)] = max(h, d[(x, y)])

for cx in range(0, 101):
    for cy in range(0, 101):
        H = 0
        for (x, y), h in d.items():
            if H == 0:
                H = h + abs(x - cx) + abs(y - cy)
            else:
                if H != h + abs(x - cx) + abs(y - cy):
                    H = -1
            if H == -1:
                break
        if H > 0:
            break
    if H > 0:
        break

print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    for cx in range(101):
        for cy in range(101):
            H = h[0] + abs(cx - x[0]) + abs(cy - y[0])
            found = True
            for i in range(1, N):
                tmp_h = h[i] + abs(cx - x[i]) + abs(cy - y[i])
                if H != tmp_h:
                    found = False
                    break
            if H > 0 and found:
                print(cx, cy, H)
                return
    print('error')
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    for cx in range(101):
        for cy in range(101):
            H = h[0] + abs(cx - x[0]) + abs(cy - y[0])
            found = True
            for i in range(1, N):
                tmp_h = h[i] + abs(cx - x[i]) + abs(cy - y[i])
                if H != tmp_h:
                    found = False
                    break
            if found:
                print(cx, cy, H)
                return
    print('error')
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def find(cx, cy, H):
	for x,y,h in xyh:
		if h != max(H-abs(x-cx)-abs(y-cy), 0):
			return False
	return True

def solve():
	for cx in range(101):
		for cy in range(101):
			x,y,h = xyh[0]
			H = h + abs(x-cx) + abs(y-cy)
			if find(cx, cy, H):
				return "%d %d %d" % (cx, cy, H)
	return "NOT FOUND !!"

print(solve())

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for _ in range(N):
    t_x, t_y, t_h = map(int, input().split())
    x.append(t_x)
    y.append(t_y)
    h.append(t_h)

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

        H = -1
        # 初期化
        for index, t_h in enumerate(h):
            if t_h != 0:
                H = abs(i - x[index]) + abs(j - y[index]) + t_h
                break

        for t_x, t_y, t_h in zip(x, y, h):
            if t_h == 0 and H > abs(i - t_x) + abs(j - t_y):
                break
            elif H != abs(i - t_x) + abs(j - t_y) + t_h:
                break
        else:
            print(i, j, H)
            break

        continue
    else:
        continue

    break

Submission status: Wrong Answer

Solution code:
N = int(input())


info = [[0,0,0] for i in range(N)]

for n in range(N):
    info[n][0],info[n][1],info[n][2] = map(int,input().split())

info.sort(key=lambda x:x[2])
for cx in range(101):
    for cy in range(101):
        cnt = 1
        H = info[0][2] + abs(info[0][0]-cx) + abs(info[0][1]-cy)
        for n in range(1,N):
            cnt += 1 
            if info[n][2] != max(H-abs(info[n][0]-cx)-abs(info[n][1]-cy),0):
                break
            if cnt == N:
                print(cx,cy,H)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for _ in range(N):
    t_x, t_y, t_h = map(int, input().split())
    x.append(t_x)
    y.append(t_y)
    h.append(t_h)

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

        H = -1

        for t_x, t_y, t_h in zip(x, y, h):
            if H == -1:
                H = abs(i - t_x) + abs(j - t_y) + t_h
            elif H != abs(i - t_x) + abs(j - t_y) + t_h:
                break
        else:
            print(i, j, H)
            break

        continue
    else:
        continue

    break

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())

Height = []
tmp = []
for i in range(N):
    x, y, h = map(int, input().split())
    if i == 0:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                H = h + abs(x-c_x) + abs(y-c_y)
                d = (c_x, c_y, H)
                Height.append(d)
    else:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                H = h + abs(x-c_x) + abs(y-c_y)
                d = (c_x, c_y, H)
                if d in Height:
                    if d not in tmp:
                        tmp.append(d)
        if i == N-1:
            Height.clear()
            break
        else:
            Height = copy.deepcopy(tmp)
            tmp.clear()

print(tmp)

Submission status: Wrong Answer

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

for Y in range(101):
    for X in range(101):
        H = -1
        for i in range(N):
            if h[i] > 0:
                if H == -1:
                    H = h[i] + abs(x[i] - X) + abs(y[i] - Y)
                elif H == h[i] + abs(x[i] - X) + abs(y[i] - Y):
                    if i == N-1:
                        print('{} {} {}'.format(X, Y, H))
                        exit()
                else:
                    break
            else:
                if H == -1:
                    H = abs(x[i] - X) + abs(y[i] - Y)
                elif H <= abs(x[i] - X) + abs(y[i] - Y):
                    if i == N-1:
                        print('{} {} {}'.format(X, Y, H))
                        exit()
                    else:
                        break
                else:
                    break

Submission status: Wrong Answer

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

for Y in range(101):
    for X in range(101):
        H = -1
        for i in range(N):
            if H == -1 and h[i] != 0:
                H = h[i] + abs(x[i] - X) + abs(y[i] - Y)
            elif h[i] == 0:
                if H == -1:
                    break
                if H <= abs(x[i] - X) + abs(y[i] - Y):
                    if i == N-1:
                        print('{} {} {}'.format(X, Y, H))
                        exit()
                else:
                    break
            elif H == h[i] + abs(x[i] - X) + abs(y[i] - Y):
                if i == N-1:
                    print('{} {} {}'.format(X, Y, H))
                    exit()
            else:
                break

Submission status: Wrong Answer

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

for Y in range(101):
    for X in range(101):
        H = -1
        for i in range(N):
            if H == -1 and h[i] != 0:
                H = h[i] + abs(x[i] - X) + abs(y[i] - Y)
            elif h[i] == 0:
                if H == -1:
                    break
                if H <= abs(x[i] - X) + abs(y[i] - Y):
                    if i == N-1:
                        print('{} {} {}'.format(X, Y, H))
                        exit()
            elif H == h[i] + abs(x[i] - X) + abs(y[i] - Y):
                if i == N-1:
                    print('{} {} {}'.format(X, Y, H))
                    exit()
            else:
                break

Submission status: Wrong Answer

Solution code:
N = int(input())
data = []
for i in range(N):
  data.append([int(j) for j in input().split()])

for cx in range(101):
  for cy in range(101):
    high = []
    high0 = []
    for i in range(N):
      if data[i][2] == 0:
        high0.append(data[i][2] + abs(data[i][0] - cx) + abs(data[i][1] - cy))
        break
      high.append(data[i][2] + abs(data[i][0] - cx) + abs(data[i][1] - cy))
      if len(set(high)) > 1:
        break
    if len(set(high)) == 1:
      print(cx, cy, high[0])
      exit()
    elif len(high) == 0 and len(set(high0)) == 1:
      print(cx, cy, high0[0])
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
data = []
for i in range(N):
  data.append([int(j) for j in input().split()])

for cx in range(101):
  for cy in range(101):
    high = []
    for i in range(N):
      if data[i][2] == 0:
        break
      high.append(data[i][2] + abs(data[i][0] - cx) + abs(data[i][1] - cy))
      if len(set(high)) > 1:
        break
    if len(set(high)) == 1:
      print(cx, cy, high[0])
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
data = []
for i in range(N):
  data.append([int(j) for j in input().split()])

for cx in range(101):
  for cy in range(101):
    high = []
    for i in range(N):
      high.append(data[i][2] + abs(data[i][0] - cx) + abs(data[i][1] - cy))
      if len(set(high)) > 1:
        break
    if len(set(high)) == 1:
      print(cx, cy, high[0])
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [tuple(map(int,input().split())) for i in range(N)]
D = 0
for Cx in range(101):
    for Cy in range(101):
        H = 0
        F = 1
        for i in A:
            if H < 1:
                H = i[2] + abs(i[0]-Cx) + abs(i[1]-Cy)
                if not i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                    H = 0
            elif i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                continue
            else:
                F = 0
                break
        for i in A:
            if not (i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0)):
                F = 0
                break
        if F == 1 and H >= 1 and D == 0:
            D = 1
            print(Cx,Cy,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [tuple(map(int,input().split())) for i in range(N)]
D = 0
for Cx in range(101):
    for Cy in range(101):
        H = 0
        F = 1
        for i in A:
            if H < 1:
                H = i[2] + abs(i[0]-Cx)+abs(i[1]-Cy)
            elif i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                continue
            else:
                F = 0
                break
        for i in A:
            if not i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                F = 0
                break
        if F == 1 and H >= 1 and D == 0:
            D = 1
            print(Cx,Cy,H)

Submission status: Wrong Answer

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

for Cx in range(101):
    for Cy in range(101):
        H = 0
        F = 1
        for i in A:
            if H < 1:
                H = i[2] + abs(i[0]-Cx)+abs(i[1]-Cy)
            elif i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                continue
            else:
                F = 0
                break
        for i in A:
            if not i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                F = 0
                break
        if F == 1 and H >= 1:
            print(Cx,Cy,H)

Submission status: Wrong Answer

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

for Cx in range(101):
    for Cy in range(101):
        H = -1
        F = 1
        for i in A:
            if H < 1:
                H = i[2] + abs(i[0]-Cx)+abs(i[1]-Cy)
            elif i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                continue
            else:
                F = 0
                break
        for i in A:
            if not i[2] == max(H-abs(i[0]-Cx)-abs(i[1]-Cy),0):
                F = 0
                break
        if F == 1:
            print(Cx,Cy,H)

Submission status: Wrong Answer

Solution code:
from itertools import *

n = int(input())
xyh = []
for i in range(n):
    xyh += [list(map(int, input().split()))]
[x0, y0, h0] = xyh[0]
for x, y in product(range(0, 101), range(0, 101)):
    h = h0 + abs(x - x0) + abs(y - y0)
    for k in xyh[1:]:
        if h != k[2] + abs(x - k[0]) + abs(y - k[1]):
            break
    else:
        break
print(x, y, h)

Submission status: Wrong Answer

Solution code:
from itertools import *

n=int(input())
xyh=[]
for i in range(n):
    xyh+=[list(map(int,input().split()))]
[x0,y0,h0]=xyh[0]
br=0
for x,y in product(range(0,101),range(0,101)):
    h=h0+abs(x-x0)+abs(y-y0)
    for k in xyh[1:]:
        if h!=k[2]+abs(x-k[0])+abs(y-k[1]):
            break
    else:
        br=1
    if br:break
print(x,y,h)

Submission status: Wrong Answer

Solution code:
CX = range(101)
CY = range(101)
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N
def equation(x,y,h,cx,cy):
    true_h = abs(x-cx) + abs(y-cy) + h
    return true_h

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

t_h = [0]*N
    
for i in range(101):
    for j in range(101):
        for k in range(N):
            t_h[k] = equation(x[k], y[k], h[k], CX[i], CY[j])
        hikaku = [t_h[0]]*N
        if t_h == hikaku:
            print(CX[i], CY[j], t_h[0])
            exit()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    ans = float("inf")
    for i in range(n+1):
        m = 0
        k = i
        while k > 0:
            m += k%6
            k //= 6
        k = n-i
        while k > 0:
            m += k%9
            k //= 9
        if m < ans:
            ans = m
    print(ans)
    return

#B
def B():
    n = I()
    x = [None for i in range(n)]
    y = [None for i in range(n)]
    h = [None for i in range(n)]
    for i in range(n):
        x[i],y[i],h[i] = LI()
    if n == 1:
        print(x[0],y[0],h[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            ch = h[0]+abs(x[0]-cx)+abs(y[0]-cy)
            f = 1
            for i in range(n):
                if max(ch-abs(x[i]-cx)-abs(y[i]-cy),0) != h[i]:f = 0
            if f:
                print(cx,cy,ch)
                quit()
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    ans = float("inf")
    for i in range(n+1):
        m = 0
        k = i
        while k > 0:
            m += k%6
            k //= 6
        k = n-i
        while k > 0:
            m += k%9
            k //= 9
        if m < ans:
            ans = m
    print(ans)
    return

#B
def B():
    n = I()
    x = [None for i in range(n)]
    y = [None for i in range(n)]
    h = [None for i in range(n)]
    if n == 1:
        print(x[0],y[0],h[0])
        quit()
    for i in range(n):
        x[i],y[i],h[i] = LI()
    for cy in range(101):
        for cx in range(101):
            ch = h[0]+abs(x[0]-cx)+abs(y[0]-cy)
            f = 1
            for i in range(n):
                if max(ch-abs(x[i]-cx)-abs(y[i]-cy),0) != h[i]:f = 0
            if f:
                print(cx,cy,ch)
                quit()
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    ans = float("inf")
    for i in range(n+1):
        m = 0
        k = i
        while k > 0:
            m += k%6
            k //= 6
        k = n-i
        while k > 0:
            m += k%9
            k //= 9
        if m < ans:
            ans = m
    print(ans)
    return

#B
def B():
    n = I()
    x = [None for i in range(n)]
    y = [None for i in range(n)]
    h = [None for i in range(n)]
    for i in range(n):
        x[i],y[i],h[i] = LI()
    for cy in range(101):
        for cx in range(101):
            ch = h[0]+abs(x[0]-cx)+abs(y[0]-cy)
            f = 1
            for i in range(n):
                if max(ch-abs(x[i]-cx)-abs(y[i]-cy),0) != h[i]:f = 0
            if f:
                print(cx,cy,ch)
                quit()
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
n=int(input());d=[list(map(int,input().split()))for i in range(n)]
for i in range(n):
  if d[i][2]!=0:s=d[i];break
  if i==n-1:s=d[-1]
for x in range(101):
  for y in range(101):
    h=abs(s[0]-x)+abs(s[1]-y)+s[2]
    bol=True
    for i in range(1,n):
      if max(0,h-abs(d[i][0]-x)-abs(d[i][1]-y))!=d[i][2]:bol=False
    if bol:print(x,y,h);exit()

Submission status: Wrong Answer

Solution code:
n=int(input());d=[list(map(int,input().split()))for i in range(n)]
for i in range(n):
  if d[i][2]!=0:s=d[i];break
for x in range(101):
  for y in range(101):
    h=abs(s[0]-x)+abs(s[1]-y)+s[2]
    bol=True
    for i in range(1,n):
      if abs(d[i][0]-x)+abs(d[i][1]-y)+d[i][2]!=h:bol=False
    if bol:print(x,y,h);exit()

Submission status: Wrong Answer

Solution code:
n=int(input());d=[list(map(int,input().split()))for i in range(n)]
for x in range(101):
  for y in range(101):
    h=max(1,abs(d[0][0]-x)+abs(d[0][1]-y)+d[0][2])
    bol=True
    for i in range(1,n):
      if abs(d[i][0]-x)+abs(d[i][1]-y)+d[i][2]!=h:bol=False
    if bol:print(x,y,h);exit()

Submission status: Wrong Answer

Solution code:
n=int(input());d=[list(map(int,input().split()))for i in range(n)]
for x in range(101):
  for y in range(101):
    h=abs(d[0][0]-x)+abs(d[0][1]-y)+d[0][2]
    bol=True
    for i in range(1,n):
      if abs(d[i][0]-x)+abs(d[i][1]-y)+d[i][2]!=h:bol=False
    if bol:print(x,y,h);exit()

Submission status: Wrong Answer

Solution code:
def high(i):
    return abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2]

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

for i in range(N):
    if xyh[i][2] != 0:
        non_zero = i
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        H = high(non_zero)
        if all([H == max(high(i), H) for i in range(N)]):
            print('{} {} {}'.format(cx, cy, H))
            break

Submission status: Wrong Answer

Solution code:
def high(i):
    return abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2]

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

for i in range(N):
    if xyh[i][2] != 0:
        non_zero = i
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        H = high(non_zero)
        if all([H == high(i) if xyh[i][2] != 0 else 1 for i in range(N)]):
            print('{} {} {}'.format(cx, cy, H))
            break

Submission status: Wrong Answer

Solution code:
def high(i):
    return abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2]

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

for i in range(N):
    if xyh[i][2] != 0:
        non_zero = i
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        H = high(non_zero)
        if all([H == high(i) for i in range(N)]):
            print('{} {} {}'.format(cx, cy, H))
            break

Submission status: Wrong Answer

Solution code:
def high(i):
    return abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2]

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

for i in range(0, 101):
    if xyh[i][2] != 0:
        non_zero = i
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        H = high(non_zero)
        if all([H == high(i) for i in range(N)]):
            print('{} {} {}'.format(cx, cy, H))
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for x in range(101):
	for y in range(101):
		h = a[n - 1][0] + abs(x - a[0][2]) + abs(y - a[0][1])
		for k in range(n):
			d = h - abs(x - a[k][2]) - abs(y - a[k][1])
			if a[k][0] != max(d, 0):
				break
			if k == n - 1:
				print(x, y, h)
				exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
b = []
flag = 0
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for i in range(101):
	for j in range(101):
		h = a[0][0] + abs(i - a[0][2]) + abs(j - a[0][1])
		for k in range(n):
			d = h - abs(i - a[k][2]) - abs(j - a[k][1])
			if a[k][0] != max(d, 0):
				break
			if k == n - 1:
				print(i, j, h)
				exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
p = [list(map(int, input().split())) for i in range(N)]
h = [h for x, y, h in p]
maxh = max(h)
def height(H, cx, cy, l):
    for x, y, h in l:
        if h != max(H-abs(x-cx)-abs(y-cy) , 0):
            return False
    return True
flag = False
for i in range(maxh,10**9 +1):
    for cx in range(101):
        for cy in range(101):
            if height(i, cx, cy, p):
                print(cx, cy, i)
                flag = True
                break
        if flag:
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
from itertools import product
import sys
input = sys.stdin.readline

N = int(input())
coo = [[int(_) for _ in input().split()] for _ in range(N)]

if N == 1:
    print(coo[0][0], coo[0][1], coo[0][2])
else:
    for x, y in product(range(101), range(101)):
        H = abs(x-coo[0][0]) + abs(y-coo[0][1]) + coo[0][2]
        for i in coo:
            if i[2] != max(0, H-abs(x-i[0])-abs(y-i[1])):
                break
        else:
            print(x, y, H)
            break

Submission status: Wrong Answer

Solution code:
from itertools import product
import sys
input = sys.stdin.readline


N = int(input())
coo = [[int(_) for _ in input().split()] for _ in range(N)]

for x, y in product(range(101), range(101)):
    H = abs(x-coo[0][0]) + abs(y-coo[0][1]) + coo[0][2]
    for i in coo:
        if i[2] != max(0, H-abs(x-i[0])-abs(y-i[1])):
            break
    else:
        print(x, y, H)
        break

Submission status: Wrong Answer

Solution code:
from itertools import product
import sys
input = sys.stdin.readline

N = int(input())
coo = [[int(_) for _ in input().split()] for _ in range(N)]

for x, y in product(range(101), range(101)):
    H = abs(x-coo[0][0]) + abs(y-coo[0][1]) + coo[0][2]
    for i in coo:
        if abs(x-i[0])+abs(y-i[1])+i[2] != H:
            break
    else:
        print(x, y, H)
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
get = []
height = []

xa = 0
ya = 0
ha = 1

for ii in range(n):
    get.append(list(map(int,input().split())))

# get[n,0] xn-1 / get[n,1] yn-1 / get[n,2] hn-1
#print(get)


for cx in range(101):
    for cy in range(101):
        for jj in range(len(get)):
            x = get[jj][0]
            y = get[jj][1]
            h = get[jj][2]
            if h != 0:
                height.append(str(h+abs(x-cx)+abs(y-cy)))

        #print(height.count(height[0]))
        #print(len(height))

        
        if height.count(height[0]) == len(height):
            xa = cx
            ya = cy
            ha = height[0]
            #print(xa,ya,ha)
        #print(height)

        if len(height) == 0:
            xa = 0
            ya = 0
            ha = 1
            
        height.clear()



print(xa,ya,ha)

Submission status: Wrong Answer

Solution code:
n = int(input())
get = []
height = []

xa = 0
ya = 0
ha = 1

for ii in range(n):
    get.append(list(map(int,input().split())))

# get[n,0] xn-1 / get[n,1] yn-1 / get[n,2] hn-1
#print(get)


for cx in range(101):
    for cy in range(101):
        for jj in range(len(get)):
            x = get[jj][0]
            y = get[jj][1]
            h = get[jj][2]
            if h != 0:
                height.append(str(h+abs(x-cx)+abs(y-cy)))

        #print(height.count(height[0]))
        #print(len(height))

        
        if height.count(height[0]) == len(height):
            xa = cx
            ya = cy
            ha = height[0]
            #print(xa,ya,ha)
        #print(height)
        height.clear()


print(xa,ya,ha)