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())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
#print(L)

for i in range(101):
    for j in range(101):
        tmp = -1
        for x in L:
            H = abs(x[0]-i) + abs(x[1]-j) + x[2]
            if H < 1:
                break
            if tmp != -1 and tmp != H:
                break
            else:
                tmp = H
        else:
            for x in L:
                if x[2]==max(0,H-abs(x[0]-i)-abs(x[1]-j)):
                    pass
                else:
                    break
            else:
                print(i,j,H)

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        tmp = -1
        for x in L:
            H = abs(x[0]-i) + abs(x[1]-j) + x[2]
            if H < 1:
                break
            if tmp != -1 and tmp != H:
                break
            else:
                tmp = H
        else:
            print(i,j,H)
            quit()

Submission status: Wrong Answer

Solution code:
import sys

def is_center(x, y, P):
  H = [abs(x-p[0]) + abs(y-p[1]) + p[2] for p in P if p[2] != 0]
  return len(set(H)) == 1


def center(C, P):
  for c in C:
    check = [p[2] == max(c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1]), 0) for p in P]
    if all(check):
      return '{} {} {}'.format(c[0], c[1], c[2])

def main():
  input = sys.stdin.readline
  N = int(input())
  P = [[0, 0, 0] for _ in range(N)]

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

  C = []
  for i in range(101):
    for j in range(101):
      if is_center(i, j, P):
        h = abs(i - P[0][0]) + abs(j - P[0][1]) + P[0][2]
        C.append([i, j, h])
  
  ans = center(C, P)
  print(ans)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import sys

def is_center(x, y, P):
  H = [abs(x-p[0]) + abs(y-p[1]) + p[2] for p in P if p[2] != 0]
  return len(set(H)) == 1

def main():
  input = sys.stdin.readline
  N = int(input())
  P = [[0, 0, 0] for _ in range(N)]
  for i in range(N):
    x, y, h = map(int, input().split())
    P[i][0], P[i][1], P[i][2] = x, y, h
  for i in range(101):
    for j in range(101):
      if is_center(i, j, P):
        h = abs(i - P[0][0]) + abs(j - P[0][1]) + P[0][2]
        ans = '{} {} {}'.format(i, j, h)
        break

  print(ans)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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



H=[]

CX=0
CY=0
height=0


for cx in range(101):
    for cy in range(101):
        H=[]
        for i in range(n):
            if X[i][2]==0:
                continue
            h=X[i][2]+abs(cx-X[i][0])+abs(cy-X[i][1])
            H.append(h)
        if len(set(H))==1:
            CX=cx
            CY=cy
            height=H[0]
            break
    else:
        continue
    break

print(str(CX)+" "+str(CY)+" "+str(height))

Submission status: Wrong Answer

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



H=[]

CX=0
CY=0
height=0


for cx in range(101):
    for cy in range(101):
        H=[]
        for i in range(n):
            h=X[i][2]+abs(cx-X[i][0])+abs(cy-X[i][1])
            H.append(h)
        if len(set(H))==1:
            CX=cx
            CY=cy
            height=H[0]
            break
    else:
        continue
    break

print(str(CX)+" "+str(CY)+" "+str(height))

Submission status: Wrong Answer

Solution code:
def calc_height(xs, ys, hs, cx, cy):
    ret = -1
    for i in range(len(xs)):
        x = xs[i]
        y = ys[i]
        h = hs[i]
        if h == 0:
            continue
        a = abs(x - cx)
        b = abs(y - cy)
        ch = h + a + b
        if ret == -1:
            ret = ch
        else:
            if ret != ch:
                return -1
    return ret


def solve(xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = calc_height(xs, ys, hs, cx, cy)
            if h > 0:
                return cx, cy, h


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)


print(' '.join([str(q) for q in solve(xs, ys, hs)]))

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for cx in range(101):
    for cy in range(101):
        flg = True
        H = abs(x[0] - cx) + abs(y[0] - cy) + h[0]
        for i in range(1,N):
            th = max( H - abs(x[i] - cx) - abs(y[i] - cy), 0 )
            if h[i] != th:
                flg = False
                break
        if flg == True:
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for cx in range(101):
    for cy in range(101):
        flg = True
        H = abs(x[0] - cx) + abs(y[0] - cy) + h[0]
        if h[0] == 0:
            H = h[0]
        for i in range(1,N):
            th = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
            if H != th:
                flg = False
                break
        if flg == True:
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for cx in range(101):
    for cy in range(101):
        flg = True
        H = abs(x[0] - cx) + abs(y[0] - cy) + h[0]
        for i in range(1,N):
            th = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
            if H != th:
                flg = False
                break
        if flg == True:
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for cx in range(101):
    for cy in range(101):
        flg = True
        for i in range(N):
            H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
            if i != 0 and H != th and H > 0:
                flg = False
                break
            th =  H
        if flg == True and H != 0:
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for cx in range(101):
    for cy in range(101):
        flg = True
        for i in range(N):
            H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
            if i != 0 and H != th:
                flg = False
                break
            th =  H
        if flg == True:
            print(cx,cy,H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))
p.sort(key = lambda x:x[2], reverse = True)
for i in range(101):
    for j in range(101):
        t = p[0][2] + abs(i - p[0][0]) + abs(j - p[0][1])
        if any([
            t != p[k][2] + abs(i - p[k][0]) + abs(j - p[k][1]) 
            if p[k][2] > 0 else t >= abs(i - p[k][0]) + abs(j - p[k][1]) 
            for k in range(1, n)
        ]):
            continue
        else:
            print(i, j, t)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
p = []
for _ in range(n):
    p.append(list(map(int, input().split())))
p.sort(key = lambda x:x[2], reverse = True)
for i in range(101):
    for j in range(101):
        t = p[0][2] + abs(i - p[0][0]) + abs(j - p[0][1])
        if any([t != p[k][2] + abs(i - p[k][0]) + abs(j - p[k][1]) for k in range(1, n)]):
            continue
        else:
            print(i, j, t)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
n = int(input())

arr = []

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

for i in range(101):
    for j in range(101):
        len1 = abs(arr[0][0] - i) + abs(arr[0][1] - j)
        ch = len1 + arr[0][2]
        for k in range(n-1):
            lenk = abs(arr[k+1][0] - i) + abs(arr[k+1][1] - j)
            if ch == lenk + arr[k+1][2]:
                if k == n-2:
                    print("{} {} {}".format(i, j, ch))
                else:
                    continue
            else:
                break

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]    
def checker(s,t,factor):
    if(abs(x[factor]-s)-abs(x[factor+1]-s)+abs(y[factor]-t)-abs(y[factor+1]-t)==h[factor+1]-h[factor]):
        if(factor<n-2):
            checker(s,t,factor+1)
        elif(factor==n-2):
            print(s,t,abs(max_x-s)+abs(max_y-t)+max(h))
if(n==1):
    print(x[0],y[0],h[0])
else:
    for u in range(101):
        for w in range(101):
            checker(u,w,0)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]    
def checker(s,t,factor):
    if(abs(x[factor]-s)-abs(x[factor+1]-s)+abs(y[factor]-t)-abs(y[factor+1]-t)==h[factor+1]-h[factor]):
        if(factor<n-2):
            checker(s,t,factor+1)
        elif(factor==n-2):
            print(s,t,abs(max_x-s)+abs(max_y-t)+max(h))
for u in range(101):
    for w in range(101):
        checker(u,w,0)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]    
if(n==3):
    for s in range(101):
        for t in range(101):
            if(abs(x[0]-s)-abs(x[1]-s)+abs(y[0]-t)-abs(y[1]-t)==h[1]-h[0]):
                if(abs(x[1]-s)-abs(x[2]-s)+abs(y[1]-t)-abs(y[2]-t)==h[2]-h[1]):
                    print(s,t,(abs(max_x-s)+abs(max_y-t)+max(h)))
elif(n>=4):
    for s in range(101):
        for t in range(101):
            if(abs(x[0]-s)-abs(x[1]-s)+abs(y[0]-t)-abs(y[1]-t)==h[1]-h[0]):
                if(abs(x[1]-s)-abs(x[2]-s)+abs(y[1]-t)-abs(y[2]-t)==h[2]-h[1]):
                    if(abs(x[2]-s)-abs(x[3]-s)+abs(y[2]-t)-abs(y[3]-t)==h[3]-h[2]):
                        print(s,t,(abs(max_x-s)+abs(max_y-t)+max(h)))

else:
    print(max_x,max_y,max(h))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]    
if(n>=3):
    for s in range(101):
        for t in range(101):
            if(abs(x[0]-s)-abs(x[1]-s)+abs(y[0]-t)-abs(y[1]-t)==h[1]-h[0]):
                if(abs(x[1]-s)-abs(x[2]-s)+abs(y[1]-t)-abs(y[2]-t)==h[2]-h[1]):
                    print(s,t,(abs(max_x-s)+abs(max_y-t)+max(h)))
else:
    print(max_x,max_y,max(h))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]   
print(max_x,max_y)
if(n>=3):
    for s in range(101):
        for t in range(101):
            if(abs(x[0]-s)-abs(x[1]-s)+abs(y[0]-t)-abs(y[1]-t)==h[1]-h[0]):
                if(abs(x[1]-s)-abs(x[2]-s)+abs(y[1]-t)-abs(y[2]-t)==h[2]-h[1]):
                    print(s,t,(abs(max_x-s)+abs(max_y-t)+max(h)))
else:
    print(max_x,max_y,max(h))

Submission status: Wrong Answer

Solution code:
n = int(input())
cl = []
for _ in range(n):
    cl.append([int(i) for i in input().split()])

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

def is_valid(cx, cy):
    ok = False
    for coo in cl:
        x = coo[0]
        y = coo[1]
        h = coo[2]
        
        if h > 0:
            ch = culc_ch(cx, cy, x, y, h)
            ok = True
            break
    
    for coo in cl:
        x = coo[0]
        y = coo[1]
        h = coo[2]
        
        if h > 0:
            if culc_ch(cx, cy, x, y, h) != ch:
                return False, -1
    if ok:
        return True, ch
    else:
        return False, -1

for cx in range(101):
    for cy in range(101):
        ok, ch = is_valid(cx, cy)
        if ok:
            print(cx, cy, ch)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
cl = []
for _ in range(n):
    cl.append([int(i) for i in input().split()])

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

def is_valid(cx, cy):
    for coo in cl:
        x = coo[0]
        y = coo[1]
        h = coo[2]
        
        if h > 0:
            ch = culc_ch(cx, cy, x, y, h)
            break
    
    for coo in cl:
        x = coo[0]
        y = coo[1]
        h = coo[2]
        
        if h > 0:
            if culc_ch(cx, cy, x, y, h) != ch:
                return False
    return True

for cx in range(101):
    for cy in range(101):
        if is_valid(cx, cy):
            for coo in cl:
                h = coo[2]
                if h > 0:
                    x = coo[0]
                    y = coo[1]
                    break
            ch = culc_ch(cx, cy, x, y, h)
            print(cx, cy, ch)
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
cl = []
for _ in range(n):
    cl.append([int(i) for i in input().split()])

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

def is_valid(cx, cy):
    for coo in cl:
        x = coo[0]
        y = coo[1]
        h = coo[2]
        
        if h > 0:
            ch = culc_ch(cx, cy, x, y, h)
            break
    
    for coo in cl:
        x = coo[0]
        y = coo[1]
        h = coo[2]
        
        if h > 0:
            if culc_ch(cx, cy, x, y, h) != ch:
                return False
    return True

for cx in range(101):
    for cy in range(102):
        if is_valid(cx, cy):
            for coo in cl:
                h = coo[2]
                if h > 0:
                    x = coo[0]
                    y = coo[1]
                    break
            ch = culc_ch(cx, cy, x, y, h)
            print(cx, cy, ch)
            break

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]   
if(n>=3):
    for s in range(100):
        for t in range(100):
            if(abs(x[0]-s)-abs(x[1]-s)+abs(y[0]-t)-abs(y[1]-t)==h[1]-h[0]):
                if(abs(x[1]-s)-abs(x[2]-s)+abs(y[1]-t)-abs(y[2]-t)==h[2]-h[1]):
                    if(abs(x[2]-s)-abs(x[3]-s)+abs(y[2]-t)-abs(y[3]-t)==h[3]-h[2]):
                        print(s,t,(abs(max_x-s)+abs(max_y-t)+max(h)))
else:
    print(max_x,max_y,max(h))

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xt, yt, ht = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = ht + abs(xt - Cx) + abs(yt - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Submission status: Wrong Answer

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

for Cx in range(101):
  for Cy in range(101):
    H = ht + abs(xt - Cx) + abs(yt - Cy)
    if(all(h == H - abs(x - Cx) - abs(y - Cy) for x, y, h in xyh)):
      print(Cx, Cy, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
X = []
Y = []
H = []

for _ in range(n):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for cx in range(101):
    for cy in range(101):
        flg = False
        # print(cx, cy)
        tmp = None
        for k in range(n):
            # print(tmp)
            if H[k] == 0:
                continue 
            if not tmp:
                tmp = H[k]+abs(cx-X[k])+abs(cy-Y[k])
                continue
            if tmp == H[k]+abs(cx-X[k])+abs(cy-Y[k]):
                continue
            else:
                flg = True 
                break
        if flg:
            continue
        else:
            print(cx, cy, tmp)
            exit()

Submission status: Wrong Answer

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

for o in range(n):
    s=list(map(int,input().split()))
    if s != 0:
        a.append(s)

for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            print(i,j,h)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
plist = [tuple(map(int, input().split())) for i in range(n)]
plist = sorted(plist, key = lambda x: -x[2])

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            elif i[2] == 0:
                if h >= diff:
                    break
            else:
                if h != diff + i[2]:
                    break
        else:
            if h <= 0:
                pass
            else:
                print("{} {} {}".format(x, y, h))

Submission status: Wrong Answer

Solution code:
n = int(input())
plist = [tuple(map(int, input().split())) for i in range(n)]
plist = sorted(plist, key = lambda x: -x[2])

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            elif i[2] == 0:
                if h <= diff:
                    break
            else:
                if h != diff + i[2]:
                    break
        else:
            if h <= 0:
                pass
            else:
                print("{} {} {}".format(x, y, h))

Submission status: Wrong Answer

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                if i[2] == 0:
                    pass
                else:
                    h = diff + i[2]
            elif i[2] == 0:
                if h <= diff:
                    break
            else:
                if h != diff + i[2] or diff + i[2] == 0:
                    break
        else:
            print("{} {} {}".format(x, y, h))

Submission status: Wrong Answer

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            if i[2] == 0:
                continue
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2] or diff + i[2] == 0:
                    break
        else:
            print("{} {} {}".format(x, y, h))

Submission status: Wrong Answer

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2] or diff + i[2] == 0:
                    break
        else:
            print("{} {} {}".format(x, y, h))

Submission status: Wrong Answer

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2] or diff + i[2] == 0:
                    break
        else:
            print(x, y, h)

Submission status: Wrong Answer

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2] or diff + i[2] > 10**9 or diff + i[2] == 0:
                    break
        else:
            print(x, y, h)

Submission status: Wrong Answer

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2] or diff + i[2] > 10**9:
                    break
        else:
            print(x, y, h)

Submission status: Wrong Answer

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2] or diff + i[2] > 100:
                    break
        else:
            print(x, y, h)

Submission status: Wrong Answer

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

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

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):
    for i in d:
      if i[2] > 0:
        H = i[2] + abs(x-i[0]) + abs(y-i[1])
        print(H)
        break
    if all(l[2] == max(H - abs(x-l[0]) - abs(y-l[1]), 0) for l in d):
      print('{} {} {}'.format(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):
    for i in d:
      if i[2] > 0:
        H = d[0][2] + abs(x-d[0][0]) + abs(y-d[0][1])
        break
    if all(l[2] == max(H - abs(x-l[0]) - abs(y-l[1]), 0) for l in d):
      print('{} {} {}'.format(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):
    for i in d:
      if i[2] > 0:
        H = d[0][2] + abs(x-d[0][0]) + abs(y-d[0][1])
        break
    if all(H == l[2] + abs(x-l[0]) + abs(y-l[1]) for l in list(filter(lambda x:x[2]>0, d))):
      print('{} {} {}'.format(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):
    for i in d:
      if i[2] > 0:
        H = d[0][2] + abs(x-d[0][0]) + abs(y-d[0][1])
        break
    #H = d[0][2] + abs(x-d[0][0]) + abs(y-d[0][1])
    if all(H == l[2] + abs(x-l[0]) + abs(y-l[1]) for l in d):
      print('{} {} {}'.format(x, y, H))
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x_h=[]
y_h=[]
H=[]
x_0=[]
y_0=[]
for i in range(n):
    x,y,h = map(int,input().split())
    if h==0:
        x_0.append(x)
        y_0.append(y)
    else:
        x_h.append(x)
        y_h.append(y)
        H.append(h)

def solve(H,x_h,y_h,x_0,y_0):
    for c_x in range(101):
        for c_y in range(101):
            h=H[0]+abs(x_h[0]-c_x)+abs(y_h[0]-c_y)
            flag=True
            for i in range(1,len(x_h)):
                if h != H[i]+abs(x_h[i]-c_x) +abs(y_h[i]-c_y):
                    flag = False
                    break

            if flag:
                return c_x,c_y,h

c_x,c_y,H = solve(H,x_h,y_h,x_0,y_0)
print(c_x,c_y,H)

Submission status: Wrong Answer

Solution code:
n=int(input())
data = [list(map(int,(input().split()))) for j in range(n)]
min_h = 10**10
for i in range(n):
    min_h = min(min_h,data[i][2])

def IsChusin(cx,cy,ch):
    for d in data:
        if d[2] != max(ch-abs(d[0]-cx)-abs(d[1]-cy),0):
            return False
    return True

for x in range(101):
    for y in range(101):
        for h in range(min_h,min_h+101):
            if IsChusin(x,y,h):
                print(x,y,h)

Submission status: Wrong Answer

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

ansx,ansy,ansh = -1,-1,-1

for _ in range(n):
    xyh.append(list(map(int,input().split())))

for px in range(101):
    for py in range(101):
        nh = [0 for _ in range(n)]
        for nn in range(n):
            if xyh[nn][2]!=0:
                nh[nn] = xyh[nn][2] + abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py)
        if all(nh[0] == x for x in nh):
            ansx,ansy,ansh=px,py,max(ansh,nh[0])

print(ansx,ansy,ansh)

Submission status: Wrong Answer

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

ansx,ansy,ansh = -1,-1,-1

for _ in range(n):
    xyh.append(list(map(int,input().split())))

for px in range(101):
    for py in range(101):
        nh = [0 for _ in range(n)]
        for nn in range(n):
            nh[nn] = xyh[nn][2] + abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py)
        if all(nh[0] == x for x in nh):
            ansx,ansy,ansh=px,py,max(ansh,nh[0])

print(ansx,ansy,ansh)

Submission status: Wrong Answer

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

for _ in range(n):
    xyh.append(list(map(int,input().split())))

for px in range(101):
    for py in range(101):
        nh = [0 for _ in range(n)]
        for nn in range(n):
            nh[nn] = xyh[nn][2] + abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py)
        if all(nh[0] == x for x in nh):
            print(px,py,nh[0])
            exit()

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())
ansx=-1
ansy=-1
ansh=-1
for i in range(101):
    for j in range(101):
        P=True
        tmph=-1
        for k in range(N):
            if h[k]>0:
                tmph=h[k]+abs(i-x[k])+abs(j-y[k])
                break
        for k in range(N):
            if tmph!=max(0,h[k]+abs(i-x[k])+abs(j-y[k])):
                P=False
        if P==True:
            ansx=i
            ansy=j
            ansh=tmph
print(ansx,ansy,ansh)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for Cx in range(101):
  mx, my, mh = xyh[0]
  for Cy in range(101):
    H = mh + abs(mx - Cx) + abs(my - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
p=[list(map(int,input().split()))for _ in range(n)]
ax,ay,ah=list(filter(lambda x:x[2],p))[0]
for x in range(101):
  for y in range(101):
    H=ah+abs(ax-x)+abs(ay-y)
    if all(H==t[2]+abs(t[0]-x)+abs(t[1]-y)for t in p):
      print(x,y,H)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(filter(lambda x:x[2],[list(map(int,input().split()))for _ in range(n)]))
for x in range(101):
  for y in range(101):
    H=set(t[2]+abs(t[0]-x)+abs(t[1]-y)for t in p)
    if len(H)<2:
      print(x,y,list(H)[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
for i in range(101):
    for j in range(101):
        check = []
        check2 = True
        for k in range(n):
            H = h[k] + abs(x[k] - i) + abs(y[k] - j)
            if h[k] > 0:
                if H != abs(x[k]-i)+abs(y[k]-j)+h[k]:
                    H = -1
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    H = -1
        if H != -1:
            print(i, j, H)