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

Q = []
for _ in range(N):
    x, y, h = map(int, input().split())
    Q.append((h, x, y))
Q.sort(reverse=True)

seikai = True
for yc in range(101):
    seikai = False
    for xc in range(101):
        valid = True
        h, x, y = Q[0]
        hc = abs(x-xc) + abs(y-yc) + h
        for (h, x, y) in Q:
            if hc > abs(x-xc) + abs(y-yc) + h:
                valid = False
                break
        if not valid:
            continue
        seikai = True
        break
    if seikai:
        break

print(xc, yc, hc)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

seikai = True
for yc in range(101):
    seikai = False
    for xc in range(101):
        valid = True
        x, y, h = Q[0]
        hc = abs(x-xc) + abs(y-yc) + h
        for (x, y, h) in Q:
            if h == 0:
                continue
            if hc != abs(x-xc) + abs(y-yc) + h:
                valid = False
                break
        if not valid:
            continue
        seikai = True
        break
    if seikai:
        break

print(xc, yc, hc)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
X = np.zeros(N, dtype = np.int64)
Y = np.zeros(N, dtype = np.int64)
H = np.zeros(N, dtype = np.int64)
for i in range(N):
    x, y, h = map(int, input().split())
    X[i] = x
    Y[i] = y
    H[i] = h
for x in range(101):
    for y in range(101):
        result = (np.abs(X - x) + np.abs(Y - y) + H) * (H != 0)
        s = set(result)
        if 0 in s:
            s -= {0}
        if len(s) <= 1:
            height = (np.abs(X - x) + np.abs(Y - y) + H).min()
            print(x, y, height)
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
X = np.zeros(N, dtype = np.int64)
Y = np.zeros(N, dtype = np.int64)
H = np.zeros(N, dtype = np.int64)
for i in range(N):
    x, y, h = map(int, input().split())
    X[i] = x
    Y[i] = y
    H[i] = h
node = 10 ** 9
for x in range(101):
    for y in range(101):
        result = (abs(X - x) + abs(Y - y) + H) * (H != 0)
        s = set(result)
        if 0 in s:
            s -= {0}
        if len(s) <= 1:
            height = (abs(X - x) + abs(Y - y) + H).min()
            print(x, y, height)
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
X,Y,H=[],[],[]
for i in range(N):
  XX,YY,HH=map(int,input().split())
  X.append(XX)
  Y.append(YY)
  H.append(HH)
for i in range(101):
  for j in range(101):
    ans=1
    m=0
    for k in range(N):
      if(k==0):
        m=abs(X[k]-i)+abs(Y[k]-j)+H[k]
      else:
        if(max(m-abs(X[k]-i)-abs(Y[k]-j),0)!=H[k]):
          ans=0
    if(ans):
      print(i,j,m)
      break

Submission status: Wrong Answer

Solution code:
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 i in range(101):
    for j in range(101):
        H=abs(x[0]-i)+abs(y[0]-j)+h[0]
        for k in range(1,n):
            if H-abs(x[k]-i)-abs(y[k]-j)==h[k]:
                continue
            else:
                break
        else:
            print(str(i)+" "+str(j)+" "+str(H))

Submission status: Wrong Answer

Solution code:
import os, sys, re, math

N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N

grid = []
for i in range(101):
    grid.append([-1] * 101)

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

for X in range(101):
    for Y in range(101):
        if grid[Y][X] >= 0:
            continue
        c = 10 ** 9
        for i in range(N):
            c = min(h[i] + abs(X - x[i]) + abs(Y - y[i]), c)
        grid[Y][X] = c

maxX = 0
maxY = 0
maxH = 0
for yy in range(101):
    for xx in range(101):
        if grid[yy][xx] > maxH:
            maxX = xx
            maxY = yy
            maxH = grid[yy][xx]

print ('%d %d %d' % (maxX, maxY, maxH))

Submission status: Wrong Answer

Solution code:
N=int(input())
info=[list(map(int,input().split())) for i in range(N)]
info.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    height=info[0][2]+abs(info[0][0]-i)+abs(info[0][1]-j)
    for h in range(1,N):
      if max(0,height-(info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j)))!=0:break
      if h==N-1 and max(0,height-(info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j)))==height:
        print(i,j,height);exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
info=[list(map(int,input().split())) for i in range(N)]
info.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    height=info[0][2]+abs(info[0][0]-i)+abs(info[0][1]-j)
    for h in range(1,N):
      if max(0,info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j))!=height:break
      if h==N-1 and max(0,info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j))==height:
        print(i,j,height);exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
info=[list(map(int,input().split())) for i in range(N)]
info.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    height=info[0][2]+abs(info[0][0]-i)+abs(info[0][1]-j)
    for h in range(1,N):
      if info[h][2]==0:continue
      if max(0,info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j))!=height:break
      if h==N-1 and max(0,info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j))==height:
        print(i,j,height);exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
info=[list(map(int,input().split())) for i in range(N)]
info.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    height=info[0][2]+abs(info[0][0]-i)+abs(info[0][1]-j)
    for h in range(1,N):
      if info[h][2]==0:continue
      if info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j)!=height:break
      if h==N-1 and info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j)==height:
        print(i,j,height);exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
info=[list(map(int,input().split())) for i in range(N)]
info.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
  for j in range(101):
    height=info[0][2]+abs(info[0][0]-i)+abs(info[0][1]-j)
    for h in range(1,N):
      if info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j)!=height:break
      if h==N-1 and info[h][2]+abs(info[h][0]-i)+abs(info[h][1]-j)==height:
        print(i,j,height);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)
    if c>0:
        g=i

for i in range(101):
    for j in range(101):
        t=h[g]+abs(x[0]-i)+abs(y[0]-j)
        f=0
        for k in range(0,n):
            if h[k]==max(0,t-abs(x[k]-i)-abs(y[k]-j)):
                f+=1
        if f==n:
            print(i,j,t)
            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)
    if c>0:
        g=i

for i in range(101):
    for j in range(101):
        t=h[g]+abs(x[0]-i)+abs(y[0]-j)
        f=1
        for k in range(0,n):
            if h[k]==max(0,t-abs(x[k]-i)-abs(y[k]-j)):
                f+=1
        if f==n:
            print(i,j,t)
            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 i in range(101):
    for j in range(101):
        t=h[0]+abs(x[0]-i)+abs(y[0]-j)
        f=1
        for k in range(1,n):
            if h[k]==max(0,t-abs(x[k]-i)-abs(y[k]-j)):
                f+=1
        if f==n:
            print(i,j,t)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
maxH = 0
maxPairs = []
xs = []
ys = []
hs = []
for i in range(N):
    x, y, h = [int(a) for a in input().split()]
    xs.append(x)
    ys.append(y)
    hs.append(h)
    if (h > maxH):
        maxH = h
        maxPairs = []
        maxPairs.append([x, y])
    elif (h == maxH):
        maxPairs.append([x, y])

if (len(maxPairs) == 1):
    print (str(maxPairs[0][0]) + ' ' + str(maxPairs[0][1]) + ' ' + str(maxH))
elif (len(maxPairs) == 2):
    for i in range(N):
        if (hs[i] == (maxH - 1)):
            if(maxPairs[0][0] == xs[i] and maxPairs[1][1] == ys[i]):
                print (str(maxPairs[1][0]) + ' ' + str(maxPairs[0][1]) + ' ' + str(maxH + 1))
            else:
                print (str(maxPairs[0][0]) + ' ' + str(maxPairs[1][1]) + ' ' + str(maxH + 1))
elif (len(maxPairs) >= 3):
    if (maxPairs[0][0] != maxPairs[1][0] and maxPairs[1][0] != maxPairs[2][0]):
        x = int((maxPairs[0][0] + maxPairs[1][0] + maxPairs[2][0]) / 3)
        y = maxPairs[0][1] if (maxPairs[0][1] == maxPairs[1][1]) else maxPairs[2][1]
    else:
        x = maxPairs[0][0] if (maxPairs[0][0] == maxPairs[1][0]) else maxPairs[2][0]
        y = int((maxPairs[0][1] + maxPairs[1][1] + maxPairs[2][1]) / 3)
    print (str(x) + ' ' + str(y) + ' ' + str(maxH + 1))

Submission status: Wrong Answer

Solution code:
import os, sys, re, math

N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N

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

minH = min(h)
maxH = max(h) + 200

for cx in x:
    for cy in y:
        for H in range(minH, maxH + 1):
            valid = True
            for nn in range(N):
                valid &= max(H - abs(x[nn] - cx) - abs(y[nn] - cy), 0) == h[nn]
            if valid:
                print ('%d %d %d' % (cx, cy, H))
                sys.exit(0)

Submission status: Wrong Answer

Solution code:
import os, sys, re, math

N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N

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

minH = min(h)
maxH = max(h) + 200

for cx in [min(x), sum(x) // len(x), max(x)]:
    for cy in [min(y), sum(y) // len(y), max(y)]:
        for H in range(minH, maxH + 1):
            valid = True
            for nn in range(N):
                valid &= max(H - abs(x[nn] - cx) - abs(y[nn] - cy), 0) == h[nn]
            if valid:
                print ('%d %d %d' % (cx, cy, H))
                sys.exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    x, y, h = list(map(int, input().split(' ')))
    l.append((x, y, h))
if len(l) == 1:
    print('%d %d %d' % (l[0][0], l[0][1], l[0][2]))
    exit()
for cx in range(101):
    for cy in range(101):
        takasa = None
        correct = True
        for x, y, h in l:
            if h == 0:
                continue
            if takasa is None and h + (abs(cx - x) + abs(cy - y)) > 0:
                takasa = h + (abs(cx - x) + abs(cy - y))
            elif takasa != (h + (abs(cx - x) + abs(cy - y))):
                correct = False
                break
        if correct:
            print('%d %d %d' % (cx, cy, l[0][2] + abs(l[0][0] - cx) + abs(l[0][1] - cy)))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    x, y, h = list(map(int, input().split(' ')))
    l.append((x, y, h))
if len(l) == 1:
    print('%d %d %d' % (l[0][0], l[0][1], l[0][2]))
    exit()
for cx in range(101):
    for cy in range(101):
        takasa = None
        correct = True
        for x, y, h in l:
            if takasa is None and h + (abs(cx - x) + abs(cy - y)) > 0:
                takasa = h + (abs(cx - x) + abs(cy - y))
            elif takasa != (h + (abs(cx - x) + abs(cy - y))):
                correct = False
                break
        if correct:
            print('%d %d %d' % (cx, cy, l[0][2] + abs(l[0][0] - cx) + abs(l[0][1] - cy)))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    x, y, h = list(map(int, input().split(' ')))
    l.append((x, y, h))
for cx in range(101):
    for cy in range(101):
        takasa = None
        correct = True
        for x, y, h in l:
            if takasa is None and h + (abs(cx - x) + abs(cy - y)) > 0:
                takasa = h + (abs(cx - x) + abs(cy - y))
            elif takasa != (h + (abs(cx - x) + abs(cy - y))):
                correct = False
                break
        if correct:
            print('%d %d %d' % (cx, cy, l[0][2] + abs(l[0][0] - cx) + abs(l[0][1] - cy)))

Submission status: Wrong Answer

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

answer = []
          
for cx in range(101):
  for cy in range(101):
    ## 全ての条件を満たすかどうかをみていく
    H = xyh[0][2]+abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)
    for xxyyhh in xyh[1:]:
      x = xxyyhh[0]
      y = xxyyhh[1]
      height = xxyyhh[2]
      
      if height == max(H -abs(x-cx) - abs(y-cy),0):
        continue
      else:
          break  
    else:
      print(cx,cy,H)
      sys.exit()

Submission status: Wrong Answer

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

answer = []
          
for cx in range(101):
  for cy in range(101):
    ## 全ての条件を満たすかどうかをみていく
    prev = xyh[0][2]+abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)
    for xxyyhh in xyh[1:]:
      x = xxyyhh[0]
      y = xxyyhh[1]
      height = xxyyhh[2]
      
      if height > 0:
        H = height+abs(x-cx)+abs(y-cy)
        if prev == H:
          continue
        else:
          break  
      else:
        continue
    else:
      print(cx,cy,prev)
      sys.exit()

Submission status: Wrong Answer

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

answer = []
          
for cx in range(101):
  for cy in range(101):
    ## 全ての条件を満たすかどうかをみていく
    prev = xyh[0][2]+abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)
    for xxyyhh in xyh[1:]:
      x = xxyyhh[0]
      y = xxyyhh[1]
      height = xxyyhh[2]
      
      if height > 0:
        H = height+abs(x-cx)+abs(y-cy)
        if prev == H:
          prev = H
          continue
        else:
          break  
      else:
        continue
    else:
      print(cx,cy,prev)
      sys.exit()

Submission status: Wrong Answer

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

answer = []
          
for cx in range(0, 101):
  for cy in range(0,101):
    ## 全ての条件を満たすかどうかをみていく
    H = -1
    for xxyyhh in xyh:
      height = xxyyhh[2]
      x = xxyyhh[0]
      y = xxyyhh[1]
      if H == -1 and height > 0:
        H = height+abs(x-cx)+abs(y-cy)
      else:
        if height == max(H-abs(x-cx)-abs(y-cy),0):
          continue
        else:
          break
    else:
      print(cx,cy,H)
      sys.exit()

Submission status: Wrong Answer

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

answer = []
          
for cx in range(0, 101):
  for cy in range(0,101):
    ## 全ての条件を満たすかどうかをみていく
    prev = -1
    for xxyyhh in xyh:
      height = xxyyhh[2]
      x = xxyyhh[0]
      y = xxyyhh[1]
      
      if height > 0:
        H = height+abs(x-cx)+abs(y-cy)
        if prev == -1 or prev == H:
          prev = H
          continue
        else:
          break  
      else:
        break
    else:
      if prev > 0:
        print(cx,cy,prev)
        sys.exit()

Submission status: Wrong Answer

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

answer = []
          
for cx in range(0, 101):
  for cy in range(0,101):
    ## 全ての条件を満たすかどうかをみていく
    prev = -1
    for xxyyhh in xyh:
      height = xxyyhh[2]
      x = xxyyhh[0]
      y = xxyyhh[1]
      
      if height > 0:
        H = height+abs(x-cx)+abs(y-cy)
        if prev == -1 or prev == H:
          prev = H
          continue
        else:
          break  
      else:
        continue
    else:
      if prev > 0:
        print(cx,cy,prev)
        sys.exit()

Submission status: Wrong Answer

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

answer = []
          
for cx in range(0, 101):
  for cy in range(0,101):
    prev = -1
    for xxyyhh in xyh:
      height = xxyyhh[2]
      x = xxyyhh[0]
      y = xxyyhh[1]
      H = max(height+abs(x-cx)+abs(y-cy),0)
      if prev == -1 or prev == H:
        prev = H
        continue
      else:
        break   
    else:
      if prev > 0:
        print(cx,cy,prev)
        sys.exit()

Submission status: Wrong Answer

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

answer = []
          
for cx in range(0, 101):
  for cy in range(0,101):
    prev = -1
    for xxyyhh in xyh:
      height = xxyyhh[2]
      x = xxyyhh[0]
      y = xxyyhh[1]
      H = max(height+abs(x-cx)+abs(y-cy),0)
      if prev == -1 or prev == H:
        prev = H
        continue
      else:
        break   
    else:
      print(cx,cy,prev)
      sys.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 i in range(101):
    for j in range(101):
        t=h[0]+abs(x[0]-i)+abs(y[0]-j)
        f=1
        for k in range(1,n):
            if h[k]+abs(x[k]-i)+abs(y[k]-j)==t:
                f+=1
        if f==n:
            print(i,j,t)
            exit()

Submission status: Wrong Answer

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


def f(points):
    for x in range(0, 101):
        for y in range(0, 101):
            p = points[0]
            h = abs(x - p[0]) + abs(y - p[1]) + p[2]
            same = True
            for i in range(1, len(points)):
                p = points[i]
                h_p = abs(x - p[0]) + abs(y - p[1]) + p[2]
                if h != h_p:
                    same = False
                    break
            if same:
                return x, y, h
    return -1,-1,-1


ans = f(points)
print("{} {} {}".format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

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


def f(points):
    for x in range(0, 101):
        for y in range(0, 101):
            h = 0
            same = True
            for p in points:
                if p[2] == 0:
                    continue
                h_p = abs(x - p[0]) + abs(y - p[1]) + p[2]
                if h != 0 and h != h_p:
                    same = False
                    break
                elif h == 0:
                    h = h_p
            if same:
                return x, y, h
    return 0,0,0


ans = f(points)
print("{} {} {}".format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
n=int(input())
v=[[int(_) for _ in input().split()] for l in range(n)]
v.sort(key=lambda x:x[2])

s=set()

def detect():
  for x in range(101):
    for y in range(101):
      for i in range(n):
        if v[i][2]:
          s.add(v[i][2]+abs(v[i][0]-x)+abs(v[i][1]-y))
      if len(s)==1:
        print(x,y,list(s)[0])
        return
      else:
         s.clear()

detect()

Submission status: Wrong Answer

Solution code:
n=int(input())
v=[[int(_) for _ in input().split()] for l in range(n)]
v.sort(key=lambda x:x[2])

s=set()

def detect():
  for x in range(101):
    for y in range(101):
      for i in range(n):
        s.add(abs(v[i][0]-x)+abs(v[i][1]-y)+v[i][2])
      if len(s)==1:
        print(x,y,v[0][2]+abs(v[0][0]-x)+abs(v[0][1]-y))
        return
      else:
        s.clear()

detect()

Submission status: Wrong Answer

Solution code:
n=int(input())
v=[[int(_) for _ in input().split()] for l in range(n)]
v.sort(key=lambda x:x[2])

print(v)

s=set()

def detect():
  for x in range(101):
    for y in range(101):
      for i in range(n):
        s.add(abs(v[i][0]-x)+abs(v[i][1]-y)+v[i][2])
      if len(s)==1:
        print(x,y,v[0][2]+abs(v[0][0]-x)+abs(v[0][1]-y))
        return
      else:
        s.clear()

detect()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda i:i[2], reverse=True)
x0, y0, h0 = xyh[0]

for i in range(101):
    for j in range(101):
        H = h0 + abs(i - x0) + abs(j - y0)
        for x, y, h in xyh:
            if h > 0:
                if H != h + abs(i - x) + abs(j - y):
                    break
            else:
                if h > 0:
                    break
        else:
            print(i, j, H)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda i:i[2], reverse=True)

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

for i in range(101):
    for j in range(101):
        H = []
        for x, y, h in xyh:
            if h != 0:
                temp = h + abs(i - x) + abs(j - y)
                if 1 <= temp:
                    H.append(temp)
        if len(set(H)) == 1:
            print(i, j, H[0])
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        found = True
        H = data[0][2] + abs(data[0][0] - x) + abs(data[0][1] - y)
        if all(c == max(H - abs(a - x) - abs(b - y), 0) for a, b, c in data):
            print("{} {} {}".format(x, y, H))
            exit(0)

Submission status: Wrong Answer

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

for x in range(0, 101):
    for y in range(0, 101):
        found = True
        H = data[0][2] + abs(data[0][0] - x) + abs(data[0][1] - y)
        if all(c == max(H - abs(a - x) - abs(b - y), 0) for a, b, c in data):
            print("{} {} {}".format(x, y, H))
            exit(0)

Submission status: Wrong Answer

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

for x in range(0, 101):
    for y in range(0, 101):
        found = True
        H = data[0][2] + abs(data[0][0] - x) + abs(data[0][1] - y)
        for i in range(n):
            tmp_H = max(H - abs(data[i][0] - x) - abs(data[i][1] - y), 0)
            if data[i][2] != tmp_H:
                found = False
                break
        if found:
            print("{} {} {}".format(x, y, H))
            exit(0)

Submission status: Wrong Answer

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

for x in range(0, 101):
    for y in range(0, 101):
        found = True
        H = data[0][2] + abs(data[0][0] - x) + abs(data[0][1] - y)
        for i in range(n):
            tmp_H = H - abs(data[i][0] - x) - abs(data[i][1] - y)
            if data[i][2] != tmp_H:
                found = False
                break
        if found:
            print("{} {} {}".format(x, y, H))
            exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
loc = [list(map(int,input().split())) for _ in range(n)]
for i in range(101):
  for j in range(101):
    h = abs(loc[0][0]-i)+abs(loc[0][1]-j)+loc[0][2]
    for l in loc[1:]:
      if l[2] != max(h-abs(l[0]-i)-abs(l[1]-j),0):
        break
    else:
      print(i,j,h)
      break

Submission status: Wrong Answer

Solution code:
n = int(input())
loc = [list(map(int,input().split())) for _ in range(n)]
for i in range(101):
  for j in range(101):
    h = abs(loc[0][0]-i)+abs(loc[0][1]-j)+loc[0][2]
    for l in loc[1:]:
      if l[2] != max(h-abs(l[0]-i)-abs(l[1]-j),0):
        break
    else:
      print(i,j,h)
      break
  else:
    continue
  break

Submission status: Wrong Answer

Solution code:
n = int(input())
loc = [list(map(int,input().split())) for _ in range(n)]
for i in range(101):
  for j in range(101):
    h = abs(loc[0][0]-i)+abs(loc[0][1]-j)+loc[0][2]
    for l in loc[1:]:
      h_new = abs(l[0]-i)+abs(l[1]-j)+l[2]
      if h !=h_new:
        break
    else:
      print(i,j,h)
      break
  else:
    continue
  break

Submission status: Wrong Answer

Solution code:
n = int(input())
loc = [list(map(int,input().split())) for _ in range(n)]
for i in range(101):
  for j in range(101):
    h = abs(loc[0][0]-i)+abs(loc[0][1]-j)+loc[0][2]
    for l in loc[1:]:
      h_new = abs(l[0]-i)+abs(l[1]-j)+l[2]
      if h !=h_new:
        break
    else:
      print(i,j,h)
      break

Submission status: Wrong Answer

Solution code:
def get_H(cx,cy):
  H0 = info_list[0][2] + abs(info_list[0][0]-cx) + abs(info_list[0][1]-cy)
  for info in info_list[1:]:
    if H0 != info[2] + abs(info[0]-cx) + abs(info[1]-cy): return -1
  return H0

N = int(input())
info_list = []
for _ in range(N):
  x,y,h = map(int,input().split())
  if h != 0:
    info_list.append([x,y,h])

for cx in range(101):
  for cy in range(101):
    res = get_H(cx,cy)
    if res != -1:
      print(cx,cy,res)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh_list = [list(map(int, input().split())) for _ in range(n)]
list_0_100 = [i for i in range(0, 101)]
possible_list = []
for i in range(len(xyh_list)):
    if xyh_list[i][2] != 0:
        x1 = xyh_list[i][0]
        y1 = xyh_list[i][1]
        h1 = xyh_list[i][2]
        break
for a in range(i+1, len(xyh_list)):
    x2 = xyh_list[a][0]
    y2 = xyh_list[a][1]
    h2 = xyh_list[a][2]
    break
    
for i in list_0_100:
    for j in list_0_100:
        if (h2 + abs(x2 - i) + abs(y2 - j)) == (h1 + abs(x1 - i) + abs(y1 - j)):
            possible_list.append([i, j])   # cx, cy 候補
pos_list = []
for i in range(a+1, n):
    if len(possible_list) == 1:
        break
    x = xyh_list[i][0]
    y = xyh_list[i][1]
    h = xyh_list[i][2]
    if h == 0:
        continue
    for j in range(len(possible_list)):  
        x_ = possible_list[j][0]
        y_ = possible_list[j][1]
        if (h + abs(x - x_) + abs(y - y_)) == (h2 + abs(x2 - x_) + abs(y2 - y_)):
            pos_list.append([x_, y_])
    possible_list = pos_list
    pos_list = []

print(possible_list[0][0], possible_list[0][1], \
      h2 + abs(x2 - possible_list[0][0]) + abs(y2 - possible_list[0][1]))

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int, input().split())) for _ in range(n)]
# 中心座標を全探索（たかだか101*101*N通り）
for i in range(101):
    for j in range(101):
        # １つ目の要素を用いてHを設定
        H=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for x,y,h in xyh:
            if h==max(H-abs(x-i)-abs(y-j),0):
                continue
            else:
                break
        else:
            print(i,j,H)

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int, input().split())) for _ in range(n)]
# 中心座標を全探索（たかだか101*101*N通り）
for i in range(101):
    for j in range(101):
        # １つ目の要素を用いてHを設定
        H=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for x,y,h in xyh[1:]:
            if h==max(H-abs(x-i)-abs(y-j),0):
                continue
            else:
                break
        else:
            print(i,j,H)

Submission status: Wrong Answer

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
# from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    points = [tuple(map(int, input().split())) for _ in range(N)]
    points = [(x,y,h) for x,y,h in points if h > 0]
    for cx in range(101):
        for cy in range(101):
            H = abs(cx-points[0][0])+abs(cy-points[0][1])+points[0][2]
            for x,y,h in points[1:]:
                if H != abs(cx-x)+abs(cy-y)+h: break
            else:
                print(cx,cy,H)

if __name__ == '__main__':
    main()