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

###
def dist(p1, p2):
    return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

def diff_H(p1, p2):
    return abs(p1[2]-p2[2])

def is_correct_center(cx, cy):
    now_C = (cx, cy, 0)  # Is this the center?
    prev_D = dist(P[0], now_C)
    prev_H = diff_H(P[0], now_C)
    for p in P:
        now_D = dist(p, now_C)
        now_H = diff_H(p, now_C)
        # higher_H if nearer_D
        if (- now_D + prev_D) != (now_H - prev_H):
            return False
        prev_D, prev_H = now_D, now_H
    return True

def get_answers(cx, cy):
    H = P[0][2] + dist(P[0], (cx, cy, 0))
    return cx, cy, H

### Start from here...
for cx in range(101):
    for cy in range(101):
        if is_correct_center(cx, cy):
            print(*get_answers(cx, cy))
            exit(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
info=sorted([list(map(int,input().split())) for _ in range(n)],key=lambda x:-x[2])
x0,y0,h0=info[0][0],info[0][1],info[0][2]

for i in range(101):
  for j in range(101):
    f=1
    hp=h0+abs(i-x0)+abs(j-y0)
    for k in range(n):
      x,y,h=info[k][0],info[k][1],info[k][2]
      if h>0:
        if h+abs(i-x)+abs(j-y)==hp:
          continue
        else:
          f=0
          break
    if f==1:print(i,j,hp,sep=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    ans = surveys[0][2] + abs(x-surveys[0][0]) + abs(y-surveys[0][1])
    identified = True
    for survey in surveys[1:]:
      if survey[2] == 0:
        continue
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if ans != height:
        identified = False
        break
    if identified:
      print(x, y, ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      if survey[2] == 0:
        continue
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        identified = False
        break
      if before == -1:
        before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      if survey[2] == 0:
        continue
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        identified = False
        continue
      before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = 0
    identified = True
    for survey in surveys:
      # if survey[2] == 0:
      #  continue
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != 0 and before != height:
        identified = False
        continue
      before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = 0
    identified = True
    for survey in surveys:
      if survey[2] == 0:
        continue
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != 0 and before != height:
        identified = False
        continue
      before = height
    if identified:
      print(x, y, before)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        identified = False
        continue
      if survey[2] != 0:
        before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        identified = False
        continue
      before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
def calc_h(cx,cy,xyh_item):
  return(abs(cx-xyh_item[0])+abs(cy-xyh_item[1])+xyh_item[2])

n=int(input())
xyh=[[int(x) for x in input().split()] for _ in range(n)]

#h=0の情報は役にたたないので捨てる
xyh=[item for item in xyh if item[2]!=0]
n=len(xyh)

#anslist=[]

for x in range(101):
  for y in range(101):
    c=0
    tmp=calc_h(x,y,xyh[0])
    for i in range(1,n):
      if tmp!=calc_h(x,y,xyh[i]):
        break
      else:
        c+=1
    #anslist.append([c,x,y,tmp])
    if c==n-1:
      print(x,y,tmp)

#anslist.sort(key=lambda x:x[0])
#print(*anslist[-1][1:])

Submission status: Wrong Answer

Solution code:
def calc_h(cx,cy,xyh_item):
  return(abs(cx-xyh_item[0])+abs(cy-xyh_item[1])+xyh_item[2])

n=int(input())
xyh=[[int(x) for x in input().split()] for _ in range(n)]

#h=0の情報は役にたたないので捨てる
xyh=[item for item in xyh if item[2]!=0]
n=len(xyh)

anslist=[]

for x in range(101):
  for y in range(101):
    c=0
    tmp=calc_h(x,y,xyh[0])
    for i in range(1,n):
      if tmp!=calc_h(x,y,xyh[i]):
        break
      else:
        c+=1
    anslist.append([c,x,y,tmp])

anslist.sort(key=lambda x:x[0])
print(*anslist[-1][1:])

Submission status: Wrong Answer

Solution code:
def calc_h(cx,cy,xyh_item):
  return(abs(cx-xyh_item[0])+abs(cy-xyh_item[1])+xyh_item[2])

n=int(input())
xyh=[[int(x) for x in input().split()] for _ in range(n)]

anslist=[]

for x in range(101):
  for y in range(101):
    c=0
    tmp=calc_h(x,y,xyh[0])
    for i in range(1,n):
      if tmp!=calc_h(x,y,xyh[i]):
        break
      else:
        c+=1
    anslist.append([c,x,y,tmp])

anslist.sort(key=lambda x:x[0])
print(*anslist[-1][1:])

Submission status: Wrong Answer

Solution code:
def calc_h(cx,cy,xyh_item):
  return(abs(cx-xyh_item[0])+abs(cy-xyh_item[1])+xyh_item[2])

n=int(input())
xyh=[[int(x) for x in input().split()] for _ in range(n)]

for x in range(101):
  for y in range(101):
    c=0
    tmp=calc_h(x,y,xyh[0])
    for i in range(1,n):
      if tmp!=calc_h(x,y,xyh[i]):
        break
      else:
        c+=1
    if c==n-1:
      print(x,y,tmp)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
Y = []
Height =[] 
for i in range(N):
    x,y,h = map(int,input().split())
    X.append(x)
    Y.append(y)
    Height.append(h)
List = []
flag = 0
for i in range(N):
    if flag ==1:
        break
    if Height[i]==0:
        continue
    else:
        for Cx in range(101):
            for Cy in range(101):
                tmp_h = Height[i]+abs((X[i]-Cx))+abs((Y[i]-Cy))
                if tmp_h >= 1:
                    List.append([Cx,Cy,tmp_h])
        flag = 1
     
    #1個目のx,y,hからCx,Cy,Hの候補を作り(List)，他のx,y,hは候補と照らし合わせながら答えを探す．
    #制約が小さいからできる全探索
     
for i in range(1,N):
    for j in List[:]:
        if Height[i] == max(j[2]-abs((X[i]-j[0]))-abs((Y[i]-j[1])),0):
            continue
        else:
            List.remove(j)
print(List[0][0],List[0][1],List[0][2])

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
for i in range(102):# Cx
  for j in range(102): #Cy
    height = -100
    flg = True
    for k in range(n):
      x,y,h= XYH[k][0], XYH[k][1], XYH[k][2]
      if h <= 0:
        continue
      if height != -100:
        if height == max(0, h + abs(x-i) + abs(y-j)):
          continue
        else:
          flg = False
          break
      else:
        height = max(0, h + abs(x-i) + abs(y-j))
        continue
    if flg and height > 0:
      print(i, j, height)
      sys.exit()

Submission status: Wrong Answer

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

for i in range(102):# Cx
  for j in range(102): #Cy
    height = -1
    flg = True
    for k in range(n):
      x,y,h= XYH[k][0], XYH[k][1], XYH[k][2]
      #print(x,y,h)
      if height != -1:
        if height == max(0, h + abs(x-i) + abs(y-j)):
          continue
        else:
          flg = False
          break
      else:
        height = max(0, h + abs(x-i) + abs(y-j))
        continue
    if flg and height > 0:
      print(i, j, height)
      sys.exit()

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
  n = int(input())
  x,y,z = [0]*n,[0]*n,[0]*n
  # ３点h>=に点があれば一意に求まる
  count = 0
  xyh = [[],[],[]]
  #print(xyh)
  for i in range(n):
    x[i],y[i],z[i] = map(int,input().split())
    if z[i] != 0 and count < 3:
      xyh[count].append(x[i])
      xyh[count].append(y[i])
      xyh[count].append(z[i])
      #print(xyh)
      count += 1
  #print(xyh)
  x,y,h = 0,0,0
  pass_ = 0
  for i in range(101):
    for j in range(101): # x,y の座標を定める
      h = abs(i-xyh[0][0])+abs(j-xyh[0][1]) + xyh[0][2]
      if count == 3:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 and h - abs(i-xyh[2][0])-abs(j-xyh[2][1]) - xyh[2][2] == 0:
          pass_ = 1
          x,y = i,j
          break
      
      if count == 2:
        if h - abs(i-xyh[1][0])-abs(j-xyh[1][1]) - xyh[1][2] == 0 :
          pass_ = 1
          x,y = i,j
          break

    if pass_ == 1:
      break 
  print(x,y,h)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0]*n
y=x[:]
h=x[:]
a=0

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

if n==1:
  print(x[0],y[0],h[0],sep=" ")
else:
  for i in range(101):
    for j in range(101):
      f=1
      a=0
      for k in range(n-1):      
        a=max(a,abs(i-x[k])+abs(j-y[k])+h[k])
        if h[k]==0:
          continue        
        elif abs(i-x[k+1])+abs(j-y[k+1])+h[k+1]!=abs(i-x[k])+abs(j-y[k])+h[k]:
          f=0
          break
      if f==1:print(i,j,a,sep=" ")

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
for i in range(n):
  x.append(i)
y=x[:]
h=x[:]
a=0
f=1

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

if n==1:print(x[0],y[0],h[0],sep=" ")
else:
  for i in range(101):
    for j in range(101):
      f=1
      a=abs(i-x[0])+abs(j-y[0])+h[0]
      for k in range(n):
        if h[k]==0:
          continue        
        elif a!=abs(i-x[k])+abs(j-y[k])+h[k]:
          f=0
          break
      if f==1:print(i,j,a,sep=" ")

Submission status: Wrong Answer

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

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

if n==1:print(x[0],y[0],h[0],sep=" ")
else:
  for i in range(101):
    for j in range(101):
      for k in range(n):
        a[k]=10**9-(abs(i-x[k])+abs(j-y[k])+h[k])
      if max(a)-min(a)==0:print(i,j,10**9-a[0],sep=" ")

Submission status: Wrong Answer

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

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

if n==1:print(x[0],y[0],h[0],sep=" ")
else:
  for i in range(101):
    for j in range(101):
      for k in range(n):
        a[k]=abs(i-x[k])+abs(j-y[k])+h[k]
      if max(a)-min(a)==0:print(i,j,a[0],sep=" ")

Submission status: Wrong Answer

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

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

  
for i in range(101):
  for j in range(101):
    for k in range(n):
      a[k]=abs(i-x[k])+abs(j-y[k])+h[k]
    if max(a)-min(a)==0:print(i,j,a[1],sep=" ")
  if max(a)-min(a)==0:print(i,j,a[1],sep=" ")
if max(a)-min(a)==0:print(i,j,a[1],sep=" ")

Submission status: Wrong Answer

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

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

  
for i in range(101):
  for j in range(101):
    for k in range(n):
      a[k]=abs(i-x[k])+abs(j-y[k])+h[k]
    if max(a)-min(a)==0:print(i,j,a[1],sep=" ")

Submission status: Wrong Answer

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

  
for i in range(101):
  for j in range(101):
    for k in range(n):
      a[k]=-abs(i-x[k])-abs(j-y[k])-h[k]
    if max(a)-min(a)==0:print(i,j,-a[1],sep=" ")

Submission status: Wrong Answer

Solution code:
import math;

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def main():
    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(n):
        if h[i]!=0:
            setH = i
            break
    for i in range(101):
        for j in range(101):
            H = h[setH] + abs(x[setH]-i) + abs(y[setH]-j)
            ac = 0
            for k in range(n):
                if h[k]+abs(x[k]-i)+abs(y[k]-j)!=H:
                    if h[k]!=0 and h[k]+abs(x[k]-i)+abs(y[k]-j)>0:
                        ac = -1
                        break
                    else:
                        ac = 1
                else:
                    ac = 1
            if ac>0:
                print("{} {} {}".format(i,j,H))
                return
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(x,y,h)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
flag = False
for i in range(101):
  for j in range(101):
    pH = ph+abs(px-i)+abs(py-j)
    for l in ls:
      h, x, y = l
      u = max(pH - abs(x-i) - abs(y-j), 0)
      if not u==h:
        break
    else:
      ans = (i,j,pH)
      flag = True
      break
  if flag:
    break
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
flag = False
for i in range(101):
  for j in range(101):
    pH = ph+abs(px-i)+abs(py-j)
    for l in ls:
      h, x, y = l
      u = max(pH - abs(x-i) - abs(y-j), 0)
      if not u==h:
        break
    else:
      ans = (i,j,pH)
      flag = True
      break
  if flag:
    break
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
for i in range(101):
  for j in range(101):
    pH = ph+abs(px-i)+abs(py-j)
    for l in ls:
      h, x, y = l
      u = max(pH - abs(x-i) - abs(y-j), 0)
      if not u==h:
        break
    else:
      ans = (i,j,pH)
      break
  if ans:
    break
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
for i in range(101):
  for j in range(101):
    pH = ph+abs(px-i)+abs(py-j)
    for l in ls:
      h, x, y = l
      u = pH - abs(x-i) - abs(y-j)
      if not u==h:
        break
    else:
      ans = (i,j,pH)
      break
  if ans:
    break
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
for i in range(101):
  for j in range(101):
    pH = ph+abs(px-i)+abs(py-j)
    for l in ls:
      h, x, y = l
      if h>0:
        H = h+abs(x-i)+abs(y-j)
        if not H==pH:
          break
    else:
      ans = (i,j,H)
      break
  if ans:
    break
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
for i in range(101):
  for j in range(101):
    pH = ph+abs(x-px)+abs(y-py)
    for l in ls:
      h, x, y = l
      if h>0:
        H = h+abs(x-i)+abs(y-j)
        if not H==pH:
          break
    else:
      ans = (i,j,H)
      break
  if ans:
    break
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
ls.sort(key=lambda x:x[2])
px, py, ph = ls[-1]

ans = []
for i in range(101):
  for j in range(101):
    pH = ph+abs(x-px)+abs(y-py)
    for l in ls:
      h, x, y = l
      if h>0:
        H = h+abs(x-i)+abs(y-j)
        if not H==pH:
          break
    else:
      print(i, j, H)
      break

Submission status: Wrong Answer

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

for cx in [2]:
    for cy in [2]:
        # 初期化
        H = -1
        for point in points:

            if point[2] > 0:
                h = abs(point[0] - cx) + abs(point[1] - cy) + point[2]
                if H == -1:
                    H = h
                elif H != h:
                    H = -2
                    break
            else:
                if H > abs(point[0] - cx) + abs(point[1] - cy) + point[2]:
                    H = -2
                    break
        if H > 0:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
    log += [(x,y,H)]
if len(log)>1:
  for a in log:
    i, j, H = a
    for l in ls:
      x, y, h = l
      u = H-abs(x-i)-abs(y-j)
      hh = max(u,0)
      if not h==hh:
        break
    else:
      break
  print(*a)
else:
  print(*log[0])

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
    log += [(x,y,H)]
if len(log)>1:
  for a in log:
    i, j, H = a
    for l in ls:
      x, y, h = l
      u = H-abs(x-i)-abs(y-j)
      hh = max(u,0)
      if not h==hh:
        break
    else:
      break
print(*a)

Submission status: Wrong Answer

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


def main(N, points):
    points.sort(key=lambda x: x[2], reverse=True)
    for x in range(101):
        for y in range(101):
            # 初期化
            H = -1
            for point in points:
                h = abs(point[0] - x) + abs(point[1] - y) + point[2]
                if point[2] > 0:
                    if H == -1:
                        H = h
                    elif H != h:
                        H = -1
                        break
                else:
                    if H > h:
                        H = -1
                        break
            if H > 0:
                print(x, y, h)
                return


main(N, points)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
print(x,y,H)

Submission status: Wrong Answer

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


def main(N, points):
    points.sort(key=lambda x: x[2], reverse=True)
    for x in range(101):
        for y in range(101):
            # 初期化
            H = -1
            for point in points:
                h = abs(point[0] - x) + abs(point[1] - y) + point[2]
                if point[2] > 0:
                    if H == -1:
                        H = h
                    elif H != h:
                        H = -1
                        break
                else:
                    if H > h:
                        H = -1
                        break
            if H > 0:
                print(x, y, h)
                return

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
    log = [(x,y,H)]
if len(log)>1:
  while True:
    u = 1
print(*log[0])

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
    log = [(x,y,H)]
if len(log)>1:
  while True:
    u = 1
print(*ans)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
    log = [(x,y,H)]
for a in log:
  px, py , H = a
  for l in ls:
    h, x, y = l
    if not h==max(H-abs(x-px)-abs(y-py), 0):
      break
  else:
    ans = a
print(*ans)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    ans = a
    ansh = H
    break
x, y = ans
print(x, y, ansh)

Submission status: Wrong Answer

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


def main(N, points):
    for x in range(101):
        for y in range(101):
            # 初期化
            d = {}
            h = 0
            for point in points:
                h = abs(point[0] - x) + abs(point[1] - y) + point[2]
                d[h] = True
            if len(d.keys()) == 1 and h > 0:
                print(x, y, h)
                return

main(N, points)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    break
x, y = a
print(x, y, pH)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    break
else:
  x, y = a
  print(x, y, pH)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    break
if pH==-1:
  while True:
    u = 1
else:
  x, y = a
  print(x, y, H)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    break
if pH==-1:
  ax = 0
  ay = 0
  for l in ls:
    h, x, y = l
    ax += x
    ay += y
  ax = ax//len(ls)
  ay = ay//len(ls)
  h, x, y = ls[0]
  H = abs(ax-x)+abs(ay-y)
  print(ax, ay, H)
else:
  x, y = a
  print(x, y, H)

Submission status: Wrong Answer

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
      #print(l, a)
    if h>0:
      H = h+abs(x-i)+abs(y-j)
#       print(pH, H, l)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    ansh = H
    break
x, y = a
print(x, y, ansh)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
  
L = sorted(ls, key=lambda x:x[0], reverse=True)

Cx1 = 101
Cy1 = 101
Cx2 = -1
Cy2 = -1
Chx1 = 0
Chy1 = 0
Chx2 = 0
Chy2 = 0
for l in L:
  h, x, y = l
  if Chx1<=h and Cx1>x:
    Cx1 = x
    Chx1 = h
  if Chx2<=h and Cx2<x:
    Cx2 = x
    Chx2 = h
  if Chy1<=h and Cy1>y:
    Cy1 = y
    Chy1 = h
  if Chy2<=h and Cy2<y:
    Cy2 = y
    Chy2 = h
  #print(Cx1, Cx2, Cy1, Cy2)

ans = []
for i in range(Cx1, Cx2+1):
  for j in range(Cy1, Cy2+1):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
for a in ans:
  i, j = a
  pH = -1
  for l in L:
    h, x, y = l
      #print(l, a)
    if h>0:
      H = h+abs(x-i)+abs(y-j)
#       print(pH, H, l)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    ansh = H
    break
x, y = a
print(x, y, ansh)

Submission status: Wrong Answer

Solution code:
N = int(input())
ls = []
for i in range(N):
  x,y,h = map(int, input().split())
  ls += [(h,x,y)]
  
L = sorted(ls, key=lambda x:x[0], reverse=True)

Cx1 = 101
Cy1 = 101
Cx2 = -1
Cy2 = -1
Chx1 = 0
Chy1 = 0
Chx2 = 0
Chy2 = 0
for l in L:
  h, x, y = l
  if Chx1<=h and Cx1>x:
    Cx1 = x
    Chx1 = h
  if Chx2<=h and Cx2<x:
    Cx2 = x
    Chx2 = h
  if Chy1<=h and Cy1>y:
    Cy1 = y
    Chy1 = h
  if Chy2<=h and Cy2<y:
    Cy2 = y
    Chy2 = h
  #print(Cx1, Cx2, Cy1, Cy2)

ans = []
for i in range(Cx1, Cx2+1):
  for j in range(Cy1, Cy2+1):
    ans += [(i,j)]

H = 0
pH = -1
ansh = 0
while len(ans)>1:
  na = []
  for a in ans:
    i, j = a
    pH = -1
    for l in L:
      h, x, y = l
      #print(l, a)
      if h>0:
        H = h+abs(x-i)+abs(y-j)
#        print(pH, H, l)
        if pH==-1:
          pH = H
        elif not H==pH:
          break
    else:
      na += [a]
      ansh = H
  ans = na
if pH == -1:
  for l in L:
    h, x, y =l
    if h>0:
      break
  ansh = h + abs(x-ans[0][0]) + abs(y-ans[0][1])
x, y = ans[0]
print(x, y, ansh)

Submission status: Wrong Answer

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

def main():

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

    for cx in range(101):
        for cy in range(101):
            H = -1
            b = True
            for i in I:
                if i[2] > 0:
                    h = abs(i[0]-cx) + abs(i[1]-cy) + i[2]
                    if H == -1:
                        H = h
                    if H != h:
                        b = False
                        break
            if b:
                print(cx, cy, H)
                return

if __name__ == '__main__':
    main()