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

highest = float('inf')
for x, y, h in Info:
    if h != 0:
        test = (x, y, h)
        break

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

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

            if h > 0 and H <= highest:
                candidate_set.add(H)

        ans_H = 0
        for x, y, h in Info:
            if h != 0:
                ans_H = max(ans_H, abs(Cx - test[0]) + abs(Cy - test[1]) + test[2])

        if len(candidate_set) == 1 and ans_H <= highest:
            print(Cx, Cy, ans_H)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    for x in range(101):
        for y in range(101):
            a=abs(xi-x)+abs(yi-y)+hi
            if xymap[x][y]==a or xymap[x][y]==-1 :
                xymap[x][y]=a
            else:
                xymap[x][y]=-2
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for i in range(0, 101):
    for j in range(0, 101):
        center = [i, j]
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        # print(i, j, h)

        flag = True
        for k in range(1, N):
            # print(l[k])
            # print(l[k][0])
            if max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0) != l[k][2]:
                flag = False

        if flag:
            print(i, j, h)
            exit()

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)
changedx=[]
changedy=[]
changedh=[]
for i in range(n):
    if h[i]==0:
        continue
    changedx.append(x[i])
    changedy.append(y[i])
    changedh.append(h[i])
diff=min(changedh)
changedh=[i-diff for i in changedh]
def pattern(cx,cy,H):
    for i in range(len(changedh)):
        if H-abs(changedx[i]-cx)-abs(changedy[i]-cy)!=changedh[i]:
            return False
    return True
def pattern_when_h_is_small(cx,cy,H):
    for i in range(n):
        if H-abs(x[i]-cx)-abs(y[i]-cy)!=h[i]:
            return False
    return True
from itertools import product
if len(changedh)<=20:
    for cx,cy,H in product(range(101),range(101),range(1,10)):
        if pattern_when_h_is_small(cx,cy,H):
            print(cx,cy,H)
            break
else:
    for cx,cy,H in product(range(101),range(101),range(1,201)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            break

Submission status: Wrong Answer

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


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)

for cx in range(0, 101):
    for cy in range(0, 101):
        TH = set(H(cx, cy, x, y, h) for x, y, h in xyh)
        if len(TH) == 1:
            TTH = TH.pop()
            if TTH >= 1:
                print(cx, cy, TTH)

Submission status: Wrong Answer

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

import itertools


MIN_C = 0
MAX_C = 100


def validate_c(conds, c_x, c_y):
    h = None
    for x, y, z in conds:
        if z <= 0:
            continue
        h_targ = abs(x - c_x) + abs(y - c_y) + z
        if h is None:
            h = h_targ
        elif h != h_targ:
            return (False, None)
    else:
        return (True, h)    


def solve(conds):
    if all(z == 0 for _, _, z in conds):
        x_min = min(x for x, _, _ in conds)
        x_max = max(x for x, _, _ in conds)
        y_min = min(y for _, y, _ in conds)
        y_max = max(y for _, y, _ in conds)
        c_x = (x_min + x_max) // 2
        c_y = (y_min + y_max) // 2
        x, y, z = conds[0]
        h = abs(x - c_x) + abs(y - c_y) * z
        return c_x, c_y, h
    for c_x, c_y in itertools.product(range(MIN_C, MAX_C + 1), repeat=2):
        j, h = validate_c(conds, c_x, c_y)
        if j:
            return c_x, c_y, h
                


def main():
    n = (int(input()))
    conds = [tuple(int(z) for z in input().split()) for _ in range(n)]
    res = solve(conds)
    print(*res)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
pts = [map(int, raw_input().split()) for i in xrange(n)]

for i in xrange(105):
    for j in xrange(105):
        H = -7
        ok = True
        for k in pts:
            if max(H - abs(k[0] - i) - abs(k[1] - j), 0) == k[2]:
                continue
            elif H < 1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                ok = False
        if ok and H > 0:
            print i, j, H
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for i in range(101):
    for j in range(101):
        H = -1
        judge = True
        for k in range(N):
#            if info[k][2] == 0:
#                continue
            dis = abs(i - info[k][0]) + abs(j - info[k][1])
            if H == -1:
                H = info[k][2] + dis
            else:
                if H != (info[k][2] + dis):
                    judge = False
        if judge == True:
            print("{} {} {}".format(i,j,H))
            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 = [[0] * MM for _ in range(MM)]
    for r ,(x, y, h) in enumerate(XYH):
        if h == 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])


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


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)

for cx in range(0, 101):
    for cy in range(0, 101):
        TH = set(H(cx, cy, x, y, h) for x, y, h in xyh)
        if len(TH) == 1:
            TTH = TH.pop()
            if TTH > 1:
                print(cx, cy, TTH)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))
H = 0
h = 0
flag = False
for i in range(101):
    for j in range(101):
        H = xyz[0][2] + abs(xyz[0][0]-i) + abs(xyz[0][1]-j)
        for k in xyz:
            h = H -abs(k[0]-i)-abs(k[1]-j)
            if h < 0:
                h = 0
            if h == k[2]:
                continue
            else:
                break
        else:
            flag = True
            print("{} {} {}".format(i, j, H))
        if flag:
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8
#

def return_H(x, y, h, cx, cy):
    retval_H = h + abs(x - cx) + abs(y - cy)
    return retval_H

def main(n, l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            retl = []
            for x, y, h in l:
                retl.append(return_H(x, y, h, cx, cy))
            if len(set(retl)) == 1:
                print('{} {} {}'.format(cx, cy, retl[0]))
                return
            
    
if __name__ == '__main__':
    try:
        n  = int(input().strip())
        l = []
        for i in range(n):
            l.append(list(map(int, input().strip().split(' '))))
        main(n, l)
    except EOFError:
        pass

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

if N == 1:
    print(G[0][0],G[0][1],G[0][2])
    exit(0)

for Cx in range(101):
    for Cy in range(101):
        f = 1
        H = G[0][2] + abs(Cx-G[0][0]) + abs(Cy-G[0][1])
        for k in range(1,N):
            if G[k][2] + abs(Cx-G[k][0]) + abs(Cy-G[k][1]) != H and G[k][2] != 0:
                f = 0
            elif H-abs(Cx-G[k][0])-abs(Cy-G[k][1]) <= 0 and G[k][2] != 0:
                f = 0
        if f:
            print(Cx,Cy,H)
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

points = []
for i in range(0, N):
    xi, yi, hi = map(int, input().split())
    points.append((xi, yi, hi))

for CX in range(101):
    for CY in range(101):
        Hs = set()
        for x, y, h in points:
            H = h + abs(x - CX) + abs(y - CY)
            Hs.add(H)
        if len(Hs) == 1:
            print('{} {} {}'.format(CX, CY, H))
            exit()

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

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

for i in range(0, 101):
    for j in range(0, 101):
        center = [i, j]
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        # print(i, j, h)

        flag = True
        for k in range(1, N):
            # print(l[k])
            # print(l[k][0])
            if h - abs(i - l[k][0]) - abs(j - l[k][1]) != l[k][2]:
                flag = False

        if flag:
            print(i, j, h)
            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 = [[0] * MM for _ in range(MM)]
    for r ,(x, y, h) in enumerate(XYH):
        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])


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:
lines = [list(map(int, input().split()))for _ in range(int(input()))]

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = lines[0]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        flag = True
        for x0, y0, h0 in lines[1:]:
            tmp = h0 + abs(cx - x0) + abs(cy - y0)
            if h0 > 0 and tmp != h:
                flag = False
                break
        if flag:
            print(cx, cy, h)
            exit()

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:
      print(i,j,Hx)
    else:
      continue

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: x[2])
info.sort()

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,len(info)):
            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(raw_input())
pts = [map(int, raw_input().split()) for i in xrange(n)]

for i in xrange(105):
    for j in xrange(105):
        H = -7
        ok = True
        for k in pts:
            if max(H - abs(k[0] - i) - abs(k[1] - j), 0) == k[2]:
                continue
            elif H < 1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                ok = False
        if ok:
            print i, j, max(H, 1)
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = [[int(j) for j in input().split()] for i in range(N)]
ind = float('inf')
for i, (x,y,h) in enumerate(d):
    if h != 0:
        ind = i
        break

for cx in range(0, 101):
    for cy in range(0, 101):
        x,y,h = d[ind]
        H = h + abs(x - cx) + abs(y - cy)
        l = [h == max(H - abs(x - cx) - abs(y - cy), 0) for x,y,h in d[1:]]
        if all(l):
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ext = lambda x: list(x)[0]

for xcand in range(101):
    for ycand in range(101):
        values = set()
        for x, y, h in xyh:
            values.add(abs(xcand - x) + abs(ycand - y) + h)
        if len(values) == 1:
            v = ext(values)
            if v < 0: continue
            print(xcand, ycand, v)
            exit()

Submission status: Wrong Answer

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

if N == 1:
    print(G[0][0],G[0][1],G[0][2])
    exit(0)

for Cx in range(101):
    for Cy in range(101):
        f = 1
        H = G[0][2] + abs(Cx-G[0][0]) + abs(Cy-G[0][1])
        for k in range(1,N):
            if G[k][2] + abs(Cx-G[k][0]) + abs(Cy-G[k][1]) != H:
                f = 0
            elif H-abs(Cx-G[k][0])-abs(Cy-G[k][1]) <= 0 and G[k][2] != 0:
                f = 0
        if f:
            print(Cx,Cy,H)
            exit(0)

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):
        height_tmp = h[0] + abs(x[0]-i) + abs(y[0]-j)
        for k in range(1, n):
            if height_tmp != h[k] + abs(x[k]-i) + abs(y[k]-j):
                break
            elif k == n-1:
                if height_tmp == h[k] + abs(x[k] - i) + abs(y[k] - j):
                    print("{} {} {}".format(i, j, height_tmp))
                    exit()

Submission status: Wrong Answer

Solution code:
n=int(input())

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

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

m=max(s)
l=0

for i in range(101):
    for j in range(101):
        for k in range(n):
            if m-i-j>=1 and max(0,m-i-j-abs(x[k]-i)-abs(y[k]-j))==h[k]:
                l+=1
                if l==n:
                    print(i,j,m-i-j)
        l=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:
  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,arrays[2]+abs(x-arrays[0])+abs(y-arrays[1]))
      sys.exit()
    x += 1
  y += 1

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


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)

for cx in range(0, 101):
    for cy in range(0, 101):
        TH = set(H(cx, cy, x, y, h) for x, y, h in xyh)
        if len(TH) == 1:
            print(cx, cy, TH.pop())

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for i in range(n):
    x, y, h = list(map(int, input().split()))
    xs.append(x)
    ys.append(y)
    hs.append(h)

x_cands = []
y_cands = []
for x1 in range(101):
    for y1 in range(101):
        h0 = None
        for x, y, h in zip(xs, ys, hs):
            if h == 0:
                continue
            if h0 is None:
                h0 = abs(x1 - x) + abs(y1 - y) + h
            elif abs(x1 - x) + abs(y1 - y) + h != h0:
                break
        else:
            x_cands.append(x1)
            y_cands.append(y1)

h_cands = []
for xc, yc in zip(x_cands, y_cands):
    for x, y, h in zip(xs, ys, hs):
        if h != 0:
            h_cands.append(h + abs(xc - x) + abs(yc - y))
            break

for xc, yc, hc in zip(x_cands, y_cands, h_cands):
    for x, y, h in zip(xs, ys, hs):
        if h != max(hc - abs(xc - x) - abs(yc - y), 0):
            break
    else:
        print(x_cands[0], y_cands[0], h_cands[0])
        exit(0)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
pts = [map(int, raw_input().split()) for i in xrange(n)]

for i in xrange(105):
    for j in xrange(105):
        H = -7
        ok = True
        for k in pts:
            if max(H - abs(k[0] - i) - abs(k[1] - j), 0) == k[2]:
                continue
            elif H < 1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                ok = False
        if ok:
            print i, j, H
            exit(0)

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):
    MM = 101
    M = [[0] * MM for _ in range(MM)]
    for r ,(x, y, h) in enumerate(XYH):
        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])


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:
# coding: utf-8
# Your code here!

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

Submission status: Wrong Answer

Solution code:

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

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


    for i in range(101):
        for j in range(101):
            for k in range(n):
                if k == 0:
                    h = lst[k][2] + abs(lst[k][0] - i) + abs(lst[k][1] - j)
                    if h <= 0:
                        break
                    continue

                if h == lst[k][2] + abs(lst[k][0] - i) + abs(lst[k][1] - j):
                    if k == n-1:
                        print(str(i)+ " " + str(j) + " " + str(h))
                        exit()
                    continue
                else:
                    break





if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [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):
        height_tmp = h[0] + abs(x[0]-i) + abs(y[0]-j)
        for k in range(1, n):
            if height_tmp != h[k] + abs(x[k]-i) + abs(y[k]-j):
                break
            elif k == n-1:
                if height_tmp == h[k] + abs(x[k] - i) + abs(y[k] - j):
                    print("{} {} {}".format(i, j, height_tmp))

Submission status: Wrong Answer

Solution code:
n=int(input())
xymap=[[0 for j in range(101)] for i in range(101)]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    for x in range(101):
        for y in range(101):
            a=abs(xi-x)+abs(yi-y)+hi
            if xymap[x][y]==a or xymap[x][y]==0 :
                xymap[x][y]=a
            else:
                xymap[x][y]=-1
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-1:
            print(x,y,xymap[x][y])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for Cx in range(100 + 1):
    for Cy in range(100 + 1):
        flg = True
        H = -1
        for x, y, h in XYHs:
            CF = abs(x - Cx) + abs(y - Cy)
            if h != 0:
                t = h + CF
                if H == -1:
                    H = t
                elif H != t:
                    flg = False
                    break
        if flg:
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

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

if n == 1:
	#x, y, h = map(int, input().split())
	print(ps[0][0], ps[0][1], ps[0][2])
else:
	for X in range(101):
		for Y in range(101):
			valid = True
			const = -1
			for p in ps:
				x, y, h = p[0], p[1], p[2]
				if h != 0:
					if const < 0:
						const = abs(X - x) + abs(Y - y) + h
					else:
						if abs(X - x) + abs(Y - y) + h != const:
							valid = False
							break
				else:
					if const >= 0:
						if const - abs(X - x) - abs(Y - y) > 0:
							valid = False
							break
			if valid == True:
				print(X, Y, const)
				sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

x = []

for i in range(n):
	x.append(list(map(int,input().split())))

a = 0
b = 0
for i in range(101):
	for j in range(101):
		for k in range(n):
			if k == 0:
				a = x[k][2] + abs(i-x[k][0]) + abs(j-x[k][1])
				b += 1
			else:
				if a == x[k][2] + abs(i-x[k][0]) + abs(j-x[k][1]):
					b += 1
		if b == n:
			print(i,j,a)
		b = 0

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,xy)を全通り試す
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]):
            if h == 0:
                break
            H2 = h + abs(Cx - x) + abs(Cy - y)
            if H != H2:
                break
        else:
            print(Cx, Cy, H)
            exit()

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)
changedx=[]
changedy=[]
changedh=[]
for i in range(n):
    if h[i]==0:
        continue
    changedx.append(x[i])
    changedy.append(y[i])
    changedh.append(h[i])
diff=min(changedh)
changedh=[i-diff for i in changedh]
def pattern(cx,cy,H):
    for i in range(len(changedh)):
        if H-abs(changedx[i]-cx)-abs(changedy[i]-cy)!=changedh[i]:
            return False
    return True
from itertools import product
for cx,cy,H in product(range(101),range(101),range(1,201)):
    if pattern(cx,cy,H):
        print(cx,cy,H+diff)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
for cx in range(cm+1):
    for cy in range(cm+1):
        H = abs(cx-x[0]) + abs(cy-y[0]) + h[0]
        contra = False
        for i in range(1,N):
            H2 =abs(cx-x[i]) + abs(cy-y[i]) + h[i]
            if H2 == H:
                continue
            else:
                contra = True
        if not contra:
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

Solution code:
import itertools

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)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        break
print("{} {} {}".format(cx, cy, H[0]))