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())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            x = a[k][0]
            y = a[k][1]
            h = a[k][2]
            if h == 0:
                continue
            else:
                H.append(h + abs(x-i) + abs(y-j))
                if len(set(H)) > 1:
                    break
            if k == n-1 and len(H) > 0:
                print(i,j,H[0])
                exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
hs=[xyh[i][-1] for i in range(n)]
mh=min(hs)
if mh==0:
    mh=1
for cx in range(101):
    for cy in range(101):
        t=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
        j=True
        for i in range(1,n):
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]!=t:
                j=False
        if j:
            print(cx,cy,t)
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
d = [[int(j) for j in input().split()] for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        x,y,h = d[0]
        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:
#!/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):
    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(input())
x,y,h = [0]*N,[0]*N,[0]*N

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

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(input())
Info = [list(map(int, input().split())) for i in range(N)]
for x, y, h in Info:
    if h != 0:
        test = (x, y, h)
        break

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:
                candidate_set.add(H)

        if len(candidate_set) == 1:
            print(Cx, Cy, abs(Cx - test[0]) + abs(Cy - test[1]) + test[2])
            exit()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        H = -1
        tmp = []
        for l in xyh:
            if l[2]==0:
                tmp.append([l[0],l[1]])
                continue
            h = l[2] + abs(i-l[0]) + abs(j-l[1])
            if H!=-1:
                if H!=h:
                    break
            else:
                H = h
        else:
            if H>=1:
                for mmm in tmp:
                    hhh = H - abs(mmm[0]-i) - abs(mmm[1]-j)
                    if hhh>0:
                        break
                print(i,j,H)
                exit()

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

for cx in range(101):
  for cy in range(101):
    ch = None
    for x, y, h in arr:
      t = h + abs(cx-x) + abs(cy-y)
      if ch is not None and t != ch:
        break
      ch = t
    else:
      print(cx, cy, ch)
      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:
        break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    info_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [x, y, h] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        info_list.append((x, y, h))

    for Cx in range(101):
        for Cy in range(101):
            pre_H = -1
            is_all_eq = True
            for info in info_list:
                x = info[0]
                y = info[1]
                h = info[2]
                H =  h + abs(Cx - x) + abs(Cy - y)
                if H - abs(Cx - x) - abs(Cy - y) < 0:
                    if h != 0:
                        is_all_eq = False
                        break
                if pre_H == -1 or H == pre_H:
                    pre_H = H
                else:
                    is_all_eq = False
                    break;
            if is_all_eq == True:
                break
        if is_all_eq == True:
                break

    print Cx, Cy, H

if __name__ == '__main__':
    main()

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:
N = int(input())

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

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

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

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
                break
        if contra:
            continue
        else:
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

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

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

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
        Z = []
        for x, y, h in XYH:
            hi = abs(x - i) + abs(y - j) + h
            if h == 0:
                Z.append([x, y])
                continue
            if height == -1:
                height = hi
            else:
                if height == hi:
                    pass
                else:
                    break
        else:
            for x, y in Z:
                if abs(x - i) + abs(y - j) >= 0:
                    continue
                else:
                    break
            else:
                print(i, j, height)
                exit()

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))
        else:
            print(cx,cy,tmph)
            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
        if f:
            print(Cx,Cy,H)
            exit(0)

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())
    if h != 0:
        info.append([x,y,h])

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 high != info[i][2] + abs(info[i][0]-cx) + abs(info[i][1]-cy):
                temp = False
        if temp:
            check = True
            break
    if check:
        break
print(cx,cy,high)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    info_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [x, y, h] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        info_list.append((x, y, h))

    for Cx in range(101):
        for Cy in range(101):
            pre_H = -1
            is_all_eq = True
            for info in info_list:
                x = info[0]
                y = info[1]
                h = info[2]
                H =  h + abs(Cx - x) + abs(Cy - y)
                if H - abs(Cx - x) - abs(Cy - y) < 0:
                    if h == 0:
                        is_all_eq = False
                        break
                if pre_H == -1 or H == pre_H:
                    pre_H = H
                else:
                    is_all_eq = False
                    break;
            if is_all_eq == True:
                break
        if is_all_eq == True:
                break

    print Cx, Cy, H

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    s=input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))
    h.append(int(s[2]))
for cx in range(101):
    for cy in range(101):
        hh=h[0]+abs(cx-x[0])+abs(cy-y[0])
        flag=True
        for i in range(n):
            if h[i]!=max(0,hh-abs(cx-x[i])-abs(cy-y[i])):
                flag=False
                break
        if flag:
            print(cx,cy,hh)

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

flag = 0
for i in range(n):
    if data[i][2] > 0:
        flag = 1
        break

if flag == 0:
    print(data[0][0], data[0][1], 0)
else:
    for cx in range(0, 101):
        for cy in range(0, 101):
            for i in range(n):
                if data[i][2] > 0:
                    H = abs(data[i][0]-cx) + abs(data[i][1]-cy) + data[i][2]
            check = 0
            for i in range(n):
                if data[i][2] > 0:
                    if abs(data[i][0]-cx) + abs(data[i][1]-cy) + data[i][2] != H:
                        check = 1
            if check == 0:
                print(cx, cy, H)
                exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

isOk = False
i = 0
j = 0
constant = -1

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

        constant = -1
        for k in range(n):
            if h[k] != 0:
                temp = h[k] + abs(i - x[k]) + abs(j - y[k])

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:
            for p in range(n):
                if h[k] == 0 and constant - abs(i - x[k]) - abs(j - y[k]) > 0:
                    break
            else:
                isOk = True
                break
        
    if isOk:
        break

print(i, j, constant)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xi, yi, hi = [int(_) for _ in input().split()]
    if hi != 0:
        x.append(xi)
        y.append(yi)
        h.append(hi)

for cxi in range(101):
    for cyi in range(101):
        flag = True
        for i in range(len(h)):
            if i == 0:
                height = h[i] + abs(x[i]-cxi) + abs(y[i]-cyi)
            else:
                if height != h[i] + abs(x[i]-cxi) + abs(y[i]-cyi):
                    flag = False
                    continue
        if flag:
            print(cxi, cyi, height)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

cx_cand = range(101)
cy_cand = range(101)
end_flag = False
for cx in cx_cand:
    for cy in cy_cand:
        temp = np.abs(x - cx) + np.abs(y - cy) + hs
        if np.max(temp)== np.min(temp):
            
            end_flag = True
            break
    if end_flag:
        break
print(cx,cy,temp[0])

Submission status: Wrong Answer

Solution code:
# C

# input

N = int(input())
x_list = [0]*N
y_list = [0]*N
h_list = [0]*N

for i in range(N):
    x, y, h = map(int, input().split())
    x_list[i] = x
    y_list[i] = y
    h_list[i] = h
    
# brute force
done = False
for CX in range(101):
    for CY in range(101):
        for i in range(N):
            if h_list[i] > 0:
                H = h_list[i] + abs(CX - x_list[i]) + abs(CY - y_list[i])
                break
        done = True
        for i in range(1, N):
            if h_list[i] != max(0, H - abs(CX - x_list[i]) - abs(CY - y_list[i])):
                done = False
                break
        if done:
            break
    if done:
        break
print(" ".join([str(CX), str(CY), str(H)]))

Submission status: Wrong Answer

Solution code:
N=int(input().strip())
xyh=[]
for i in range(N):
    xyh.append(list(map(int, input().strip().split())))
xyh=sorted(xyh, key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        flag=True
        Hcand=-1
        for x,y,h in xyh:
            H= h+abs(x-cx)+abs(y-cy)
            if Hcand==-1:
                Hcand=H
            else:
                if Hcand!=H:
                    flag=False
                    break
        if flag:
            break
    if flag:
        break
print("{} {} {}".format(cx,cy,H))

Submission status: Wrong Answer

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

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:
                candidate_set.add(H)

        if len(candidate_set) == 1:
            print(Cx, Cy, abs(Cx - Info[0][0]) + abs(Cy - Info[0][1]) + Info[0][2])
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input().strip())
xyh=[]
for i in range(N):
    xyh.append(list(map(int, input().strip().split())))
xyh=sorted(xyh, key=lambda x:x[2])
for cx in range(101):
    for cy in range(101):
        flag=True
        Hcand=-1
        for x,y,h in xyh:
            H= h+abs(x-cx)+abs(y-cy)
            if Hcand==-1:
                Hcand=H
            else:
                if Hcand!=H:
                    flag=False
                    break
        if flag:
            break
    if flag:
        break
print("{} {} {}".format(cx,cy,H))

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
			if valid == True:
				print(X, Y, const)
				sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
for CX in range(101):
    for CY in range(101):
        ans = 1
        H = 0
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = max(H, abs(x - CX) + abs(y - CY) + h)
            #print(CX, CY)
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if h != max(H - abs(x - CX) - abs(y - CY), 0):

                ans = -1
                break

        if ans == 1:
            print(CX, CY, H)
            break
            1
    if ans == 1:
        break

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
        if f:
            print(Cx,Cy,H)
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
A = X[0]
for cx in range(101):
    for cy in range(101):
        H = A[2] + abs( A[0] - cx) + abs( A[1] - cy)
        Flag = True
        for i in range(N):
            if max( H - abs(X[i][0]-cx) - abs(X[i][1] - cy), 0) != X[i][2]:
                Flag = False
                break
        if Flag:
            print('{} {} {}'.format(cx, cy, H))
            break
    if Flag:
        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

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

if n == 1:
	#x, y, h = map(int, input().split())
	print(x, y, h)
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
			if valid == True:
				print(X, Y, const)
				sys.exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
hs=[xyh[i][-1] for i in range(n)]
mh=min(hs)
if mh==0:
    mh=1
for cx in range(101):
    for cy in range(101):
        for h in range(mh,mh+101):
            j=True
            for i in range(n):
                if max(h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:
                    j=False
            if j:
                print(cx,cy,h)
                break

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    info_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [x, y, h] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        info_list.append((x, y, h))

    for Cx in range(101):
        for Cy in range(101):
            pre_H = -1
            is_all_eq = True
            for info in info_list:
                x = info[0]
                y = info[1]
                h = info[2]
                H =  h + abs(Cx - x) + abs(Cy - y)
                if H - abs(Cx - x) - abs(Cy - y) < 0:
                    H = 0
                if pre_H == -1 or H == pre_H:
                    pre_H = H
                else:
                    is_all_eq = False
                    break;
            if is_all_eq == True:
                break
        if is_all_eq == True:
                break

    print Cx, Cy, H

if __name__ == '__main__':
    main()

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 height == -1:
                height = hi
            else:
                if height == hi:
                    pass
                elif h==0 and abs(x - i) + abs(y - j) > hi:
                    pass
                else:
                    break
        else:
            print(i, j, height)
            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())
    x.append(xi)
    y.append(yi)
    h.append(hi)

isOk = False
i = 0
j = 0
constant = -1

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

        constant = -1
        for k in range(n):
            if h[k] != 0:
                temp = h[k] + abs(i - x[k]) + abs(j - y[k])

                if constant == -1:
                    constant = temp

                if constant != temp:
                    break
        else:
            isOk = True
            break
        
    if isOk:
        break

print(i, j, constant)

Submission status: Wrong Answer

Solution code:
import sys
fin = sys.stdin.readline
N = int(fin())
info_list = [[int(elem) for elem in fin().split(' ')] for _ in range(N)]
assert len(info_list[0]) == 3

for cx in range(101):
    for cy in range(101):
        H = None
        for x, y, h in info_list:
            if H is None and h != 0:
                H = abs(x - cx) + abs(y - cy) + h
                continue
            elif H is None and h == 0:
                continue
            elif H is not None:
                if h != max(H - abs(x - cx) - abs(y - cy), 0):
                    break
        else:
            print("{} {} {}".format(cx, cy, H))
            exit(0)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
RC112 C
"""

n = int(input())
xyhlist = [tuple(map(int,input().split())) for i in range(n)]

from itertools import product
for x,y in product(range(0,101),range(0,101)):
    test = set(map(lambda t:t[2]+abs(t[0]-x)+abs(t[1]-y),xyhlist))
    hh = test.pop()
    if len(test) == 0 and hh>=1:
        print(x,y,hh)
        exit()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        H = -1
        for l in xyh:
            h = l[2] + abs(i-l[0]) + abs(j-l[1])
            if H!=-1:
                if H!=h:
                    break
            else:
                H = h
        else:
            if H>=1:
                print(i,j,H)
                exit()

Submission status: Wrong Answer

Solution code:
# C

# input

N = int(input())
x_list = [0]*N
y_list = [0]*N
h_list = [0]*N

for i in range(N):
    x, y, h = map(int, input().split())
    x_list[i] = x
    y_list[i] = y
    h_list[i] = h
    
# brute force
done = False
for CX in range(101):
    for CY in range(101):
        H = h_list[0] + abs(CX - x_list[0]) + abs(CY - y_list[0])
        done = True
        for i in range(1, N):
            if H != h_list[i] + abs(CX - x_list[i]) + abs(CY - y_list[i]):
                done = False
                break
        if done:
            break
    if done:
        break
print(" ".join([str(CX), str(CY), str(H)]))