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())
points = []
center = True
centercount = 0
centers = []
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centers.append([cx, cy, h])
        centercount+=1
        break
  if centercount==1:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))
  else:
    #print(str(centers[0][0])+' '+str(centers[0][1])+str(centers[0][2]))
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
center = True
centercount = 0
centers = []
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(101, -1, -1):
    for j in range(101, -1, -1):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centers.append([cx, cy, h])
        centercount+=1
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Wrong Answer

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

N = int(input())
P = [0] * N
highest = 0
for n in range(N):
    P[n] = tuple([int(x) for x in input().strip().split()])
    highest = max(highest, P[n][2])

def calch(c, p):
    return max(c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1]), 0)

def dh(c, p):
    return max(p[2] - (c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1])), 0)

def f(p, P):
    h = -1
    th = -1
    for pp in P:
        if calch(p, pp) == 0 and pp[2] == 0:
            continue
        th = dh(p, pp)
        if h == -1 or th == h:
            h = th
        else:
            return -1
    else:
        return th

for x in range(101):
    for y in range(101):
        h = highest
        while True:
            h_ = f((x, y, h), P)
            if h_ == -1:
                break
            elif h_ == 0:
                print(x, y, h)
                exit()
            else:
                h += h_

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
center = True
centercount = 0
centers = []
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centers.append([cx, cy, h])
        centercount+=1
        break
  if centercount==1:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))
  else:
    print(str(centers[0][0])+' '+str(centers[0][1])+' '+str(centers[0][2]))

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
center = True
centercount = 0
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centercount+=1
        break
  if centercount==1:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
center = True
centercount = 0
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        centercount+=1
        break
  if centercount==101:
    print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Wrong Answer

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

N = int(input())
P = [0] * N
highest = 0
for n in range(N):
    P[n] = tuple([int(x) for x in input().strip().split()])
    highest = max(highest, P[n][2])

def dh(c, p):
    return max(p[2] - (c[2] - abs(p[0] - c[0]) - abs(p[1] - c[1])), 0)

def f(p, P):
    h = -1
    for pp in P:
        th = dh(p, pp)
        if h == -1 or th == h:
            h = th
        else:
            return -1
    else:
        return th

for x in range(101):
    for y in range(101):
        h = highest
        while True:
            h_ = f((x, y, h), P)
            if h_ == -1:
                break
            elif h_ == 0:
                print(x, y, h)
                exit()
            else:
                h += h_

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True and temph>0:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Wrong Answer

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

# 仮の頂上を求めるため、最初の要素を用いる
init_X = pyramids[0][0]
init_Y = pyramids[0][1]
init_H = pyramids[0][2]
# 全探索を行う
for center_X in range(101):
    for center_Y in range(101):
        H = init_H + abs(init_X - center_X) + abs(init_Y - center_Y)
        # 最初の要素以外において、仮頂点とマンハッタン距離の関係が全て一致しているか判定
        for j in range(1,N):
            if pyramids[j][2] != H - abs(pyramids[j][0] - center_X) - abs(pyramids[j][1] - center_Y):
                break
        # 全て成立する時答え
        else:
            print(center_X,center_Y,H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
center = True
for i in range(n):
  points.append([int(x) for x in input().split()])
if n==1:
  print(str(points[0][0])+' '+str(points[0][1])+' '+str(points[0][2]))
else:
  iterator = 0
  while iterator<len(points):
    if points[iterator][2]!=0:
      points[iterator], points[0] = points[0], points[iterator]
      break
    iterator+=1
  for i in range(0, 101):
    for j in range(0, 101):
      center = True
      temph = abs(points[0][0]-i)+abs(points[0][1]-j)+points[0][2]
      k = 1
      while k<len(points):
        if temph != abs(points[k][0]-i)+abs(points[k][1]-j)+points[k][2]:
          if points[k][2]==0:
            k+=1
            continue
          center = False
          break
        k+=1
      if center==True:
        cx = i
        cy = j
        h = temph
        break
  print(str(cx) + ' ' + str(cy) + ' ' + str(h))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
  xyh = [int(z) for z in input().split()]
  x.append(xyh[0])
  y.append(xyh[1])
  h.append(xyh[2])
maxx = x[h.index(max(h))]
maxy = y[h.index(max(h))]
maxh = max(h)
i=0
while i<len(h):
  j=i+1
  while j<len(h):
    if h[i]==h[j]:
      if y[i]==y[j] and h[i]!=0:
        maxx = int((x[i]+x[j])/2)
        maxh = int(h[i]+abs(x[j]-x[i])/2)
      if x[i]==x[j] and h[i]!=0:
        maxy = int((y[i]+y[j])/2)
        maxh = int(h[i]+abs(y[j]-y[i])/2)
    j+=1
  i+=1
print(str(maxx)+ ' ' + str(maxy) + ' ' + str(maxh))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
  xyh = [int(z) for z in input().split()]
  x.append(xyh[0])
  y.append(xyh[1])
  h.append(xyh[2])
maxx = x[h.index(max(h))]
maxy = y[h.index(max(h))]
maxh = max(h)
i=0
while i<len(h):
  j=i+1
  while j<len(h):
    if h[i]==h[j]:
      if y[i]==y[j] and h[i]!=0:
        maxy = int((x[i]+x[j])/2)
        maxh = int(h[i]+abs(x[j]-x[i])/2)
      if x[i]==x[j] and h[i]!=0:
        maxx = int((y[i]+y[j])/2)
        maxh = int(h[i]+abs(y[j]-y[i])/2)
    j+=1
  i+=1
print(str(maxx)+ ' ' + str(maxy) + ' ' + str(maxh))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
  xyh = [int(z) for z in input().split()]
  x.append(xyh[0])
  y.append(xyh[1])
  h.append(xyh[2])
maxx = x[h.index(max(h))]
maxy = y[h.index(max(h))]
maxh = max(h)
i=0
while i<len(h):
  j=i+1
  while j<len(h):
    if h[i]==h[j]:
      if y[i]==y[j] and y[i]!=0:
        maxy = int((x[i]+x[j])/2)
        maxh = int(h[i]+abs(x[j]-x[i])/2)
      if x[i]==x[j] and x[i]!=0:
        maxx = int((y[i]+y[j])/2)
        maxh = int(h[i]+abs(y[j]-y[i])/2)
    j+=1
  i+=1
print(str(maxx)+ ' ' + str(maxy) + ' ' + str(maxh))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
  xyh = [int(z) for z in input().split()]
  x.append(xyh[0])
  y.append(xyh[1])
  h.append(xyh[2])
maxx = x[h.index(max(h))]
maxy = y[h.index(max(h))]
maxh = max(h)
i=0
while i<len(h):
  j=i+1
  while j<len(h):
    if h[i]==h[j]:
      if y[i]==y[j]:
        maxy = int((x[i]+x[j])/2)
        maxh = int(h[i]+abs(x[j]-x[i])/2)
      if x[i]==x[j]:
        maxx = int((y[i]+y[j])/2)
        maxh = int(h[i]+abs(y[j]-y[i])/2)
    j+=1
  i+=1
print(str(maxx)+ ' ' + str(maxy) + ' ' + str(maxh))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
  xyh = [int(x) for x in input().split()]
  x.append(xyh[0])
  y.append(xyh[1])
  h.append(xyh[2])
maxx = x[h.index(max(h))]
maxy = y[h.index(max(h))]
maxh = max(h)
i=0
while i<len(h):
  j=i+1
  while j<len(h):
    if h[i]==h[j]:
      if y[i]==y[j]:
        maxy = (y[i]+y[j])/2
        maxh = y[i]+(j-i)/2
      if x[i]==x[j]:
        maxx = (x[i]+x[j])/2
        maxh = y[i]+(j-i)/2
    j+=1
  i+=1
print(str(maxx)+ ' ' + str(maxy) + ' ' + str(max(h)))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
  xyh = [int(x) for x in input().split()]
  x.append(xyh[0])
  y.append(xyh[1])
  h.append(xyh[2])
print(str(x[h.index(max(h))]) + ' ' + str(y[h.index(max(h))]) + ' ' + str(max(h)))

Submission status: Wrong Answer

Solution code:
n=int(input())
d=[]
d=[list(map(int,input().split())) for i in range(n)]
i=0
while i<len(d):
  if d[i][2]==0:
     d.pop(i)
  i+=1
  
for Cx in range(0,101):
  for Cy in range(0,101):
    k=0
    if n>=2:
      for i in range(len(d)-1):
        if d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy) != d[i+1][2]+abs(d[i+1][0]-Cx)+abs(d[i+1][1]-Cy):
          k=1
      if k==0:
        print(Cx,Cy,d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy))

Submission status: Wrong Answer

Solution code:
n=int(input())
d=[]
d=[list(map(int,input().split())) for i in range(n)]
h=0
  
for Cx in range(0,101):
  for Cy in range(0,101):
    k=0
    if n>=2:
      for i in range(n-1):
        if d[i][2]!=0 and d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy) != d[i+1][2]+abs(d[i+1][0]-Cx)+abs(d[i+1][1]-Cy):
          k=1
        elif d[i][2]==0 and d[i+1][2]!=0 and d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy) > d[i+1][2]+abs(d[i+1][0]-Cx)+abs(d[i+1][1]-Cy):
          k=1

      if k==0:
        print(Cx,Cy,d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy))

Submission status: Wrong Answer

Solution code:
n=int(input())
d=[]
d=[list(map(int,input().split())) for i in range(n)]
h=0
  
for Cx in range(0,101):
  if h!=0:
    break
  for Cy in range(0,101):
    k=0
    if n>=2:
      for i in range(n-1):
        if d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy) != d[i+1][2]+abs(d[i+1][0]-Cx)+abs(d[i+1][1]-Cy):
          k=1
      if k==0:
        print(Cx,Cy,d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy))
        h=1

Submission status: Wrong Answer

Solution code:
n=int(input())
d=[]
d=[list(map(int,input().split())) for i in range(n)]
  
  
for Cx in range(0,101):
  for Cy in range(0,101):
    k=0
    if n>=2:
      for i in range(n-1):
        if d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy) != d[i+1][2]+abs(d[i+1][0]-Cx)+abs(d[i+1][1]-Cy):
          k=1
      if k==0:
        print(Cx,Cy,d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy))

Submission status: Wrong Answer

Solution code:
n=int(input())
d=[]
if n>=4:
  for i in range(4):
    d.append(list(map(int,input().split())))
    n=4
else:
  d=[list(map(int,input().split())) for i in range(n)]
  
  
for Cx in range(0,101):
  for Cy in range(0,101):
    k=0
    if n>=2:
      for i in range(n-1):
        if d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy) != d[i+1][2]+abs(d[i+1][0]-Cx)+abs(d[i+1][1]-Cy):
          k=1
      if k==0:
        print(Cx,Cy,d[i][2]+abs(d[i][0]-Cx)+abs(d[i][1]-Cy))

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split()))for i in range(N)]
xyh.sort(reverse=True,key=lambda x:x[2])
for cx in range(101):
  for cy in range(101):
    H=0
    flag=False
    for i,tmp in enumerate(xyh):
      x,y,h=tmp
   
      if h != 0:
        tmp= h+abs(x-cx)+abs(y-cy)
      else:
        if H-abs(x-cx)-abs(y-cy) <=0:
          continue
      if H!=0:
        if H==tmp:
         
          if i==N-1:
            flag=True
          continue
        else:
          break
      else:
        H=tmp
        

    if flag:
      print(cx,cy,H)
      exit(0)

Submission status: Wrong Answer

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

for cx in range(101):
  for cy in range(101):
    H=0
    flag=False
    for i,tmp in enumerate(xyh):
      x,y,h=tmp
   
      if h != 0:
        tmp= h+abs(x-cx)+abs(y-cy)
       
      if H!=0:
        if H==tmp:
         
          if i==N-1:
            flag=True
          continue
        else:
          break
      else:
        H=tmp
        

    if flag:
      print(cx,cy,H)
      exit(0)

Submission status: Wrong Answer

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

l.sort(key=lambda x: x[2])
#print(l)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
lis = np.zeros((101,101))
s = list()
for k in range(N):
    print(s)
    tmp = list()
    x,y,h = map(int,input().split())
    if h == 0:
        continue
    if s:
        if len(s) == 1:
            break
        for i in s:
            if i[2] == h+abs(i[0]-x)+abs(i[1]-y):
                tmp.append(i)
        s = tmp
    else:
        for i in range(101):
            for j in range(101):
                if lis[i][j] == 0:
                    lis[i][j] = h+abs(i-x)+abs(j-y)
                elif lis[i][j] == h+abs(i-x)+abs(j-y):
                    s.append([i,j,lis[i][j]])
else:
    for i in range(101):
        for j in range(101):
            if lis[i][j] == 1:
                s.append([i,j,lis[i][j]])
print(s[0][0], s[0][1], int(s[0][2]))

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())

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

for x in range(101):
    for y in range(101):
        height = abs(xyhl[0][0] - x) + abs(xyhl[0][1] - y) + xyhl[0][2]
        for x1,y1,h1 in xyhl:
            hh = abs(x1-x)+abs(y1-y)+h1
            if hh != height:
                break
        else:
            print(x)
            print(y)
            print(height)
            sys.exit()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    xyh = [[int(i) for i in input().split()] for _ in range(N)]
    for cx in range(101):
        for cy in range(101):
            H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
            if all(max(H-abs(x - cx)-abs(y - cy), 0) == h for x, y, h in xyh):
                return print(cx, cy, H)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    xyh = [[int(i) for i in input().split()] for _ in range(N)]
    if N == 1:
        return print(*xyh[0])
    elif N == 2:
        xyh.sort(key=lambda p: p[2])
        return print(*xyh[1])
    xyh.sort(key=lambda p: p[2])
    from collections import Counter
    c = Counter(h for x, y, h in xyh)
    c_m = c.most_common()
    if c_m[0][1] == 1:
        ch = c_m[0][1]
        for x, y, h in xyh:
            if h == ch:
                return print(x, y, h)
    else:
        ch = c_m[0][0] + 1
        ans = set()
        dxy = ((0, 1), (1, 0), (-1, 0), (0, -1),
               (1, 1), (-1, -1), (1, -1), (-1, 1))
        for i in range(c_m[0][1]):
            for x, y, h in xyh:
                if ch - 1 == h:
                    if i == 0:
                        for dx, dy in dxy:
                            if 0 <= x+dx <= 100 and 0 <= y+dy <= 100:
                                ans.add((x+dx, y+dy))
                    else:
                        cur = set()
                        for dx, dy in dxy:
                            if 0 <= x+dx <= 100 and 0 <= y+dy <= 100:
                                cur.add((x+dx, y+dy))
                        ans = ans & cur
        xy = {(x, y) for x, y, h in xyh}
        ans = ans - xy
        if len(ans) == 1:
            for a in ans:
                print(a[0], a[1], ch)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y, H = [], [], []
X_zero, Y_zero = [], []
C_x, C_y = None, None

for _ in range(N):
	x, y, h = map(int, input().split())
	if h > 0:
		X.append(x)
		Y.append(y)
		H.append(h)
	else:
		X_zero.append(x)
		Y_zero.append(y)
	
# 答え候補は(i, j)
end = 0
for i in range(0, 100 + 1):
	if end: break
	for j in range(0, 100 + 1):
		if end: break
		cur = None
		ok = 1
		for n in range(len(X)):
			if cur == None:
				cur = H[n] + abs(i - X[n]) + abs(j - Y[n])
				C_x = i
				C_y = j
			else:
				if cur != H[n] + abs(i - X[n]) + abs(j - Y[n]):
					ok = 0
					break
		if ok:
			end = 1
			for n in range(len(X_zero)):
				if not abs(i - X[n]) + abs(j - Y[n]) >= cur:
					end = 0
					break
			
print(C_x, C_y, cur)

Submission status: Wrong Answer

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

top = [0, 0]
top_height = []
top_height_ans = 0
flag = False
for x in range(0, 101):
    for y in range(0, 101):
        for i in range(N):
            top_height.append(abs(x - h_info[i][0]) + abs(y - h_info[i][1]) + h_info[i][2])
            if (i >= 1 and top_height[i-1] != top_height[i]
                and (h_info[i-1][2] > 0 and h_info[i][2] > 0)
                or (h_info[i][2] == 0 and top_height[i-1] > top_height[i])
                or (h_info[i-1][2] == 0 and top_height[i-1] < top_height[i])):
                    top_height.clear()
                    break
            elif i == N - 1:
                top = [x, y]
                top_height_ans = min(top_height)
                flag = True
                break
        if flag:
            break
    if flag:
        break
                

print(top[0], top[1], top_height_ans)

Submission status: Wrong Answer

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

top = [0, 0]
top_height_prev = 0
top_height_now = 0
flag = False
for x in range(0, 101):
    for y in range(0, 101):
        for i in range(N):
            top_height_prev = top_height_now
            top_height_now = (abs(x - h_info[i][0]) + abs(y - h_info[i][1]) + h_info[i][2])
            if i >= 1 and top_height_prev != top_height_now:
                break
            elif i == N - 1:
                top = [x, y]
                flag = True
                break
        if flag:
            break
    if flag:
        break
                

print(top[0], top[1], top_height_now)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

cx_candidates = range(101)
cy_candidates = range(101)


for cx in cx_candidates:
    for cy in cy_candidates:
        chs = set()
        for x, y, h in x_y_hs:
            if h == 0:
                continue
            else:
                ch = h + abs(x - cx) + abs(y - cy)
                chs.add(ch)

        if len(chs) == 1:
            print(cx, cy, list(chs)[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
cnt = 0
h = 0
while h == 0:
    x, y, h = map(int, input().split())
    cnt += 1

for Cx in range(101):
    for Cy in range(101):
        Ph = abs(x-Cx) + abs(y-Cy) + h
        lis.append([Cx,Cy,Ph])

for _ in range(N-cnt):
    x, y, h = map(int, input().split())
    newlis = []
    if h == 0: 
        for l in lis:
            if abs(x-l[0]) + abs(y-l[1]) + h >= l[2]:
                newlis.append(l)
    else:
        for l in lis:
            if abs(x-l[0]) + abs(y-l[1]) + h == l[2]:
                newlis.append(l)
    lis = newlis

print(" ".join(map(str,lis[0])))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        H=[]
        for k in range(n):
            if l[k][2]>0:
                H.append(l[k][2]+abs(l[k][0]-i)+abs(l[k][1]-j))
            else:
                continue
        if len(set(H))==1:
            print(i,j,H[0])
            break

Submission status: Wrong Answer

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

x = xyh[0][0]
y = xyh[0][1]
h = xyh[0][2]

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

Submission status: Wrong Answer

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

x = xyh[0][0]
y = xyh[0][1]
h = xyh[0][2]

for cx in range(0,101):
  for cy in range(0,101):
    H = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
    for i in range(1,N):
      if xyh[i][2] != max(H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy),0):
        break
    else:
      print(cx,cy,H)
      break

Submission status: Wrong Answer

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

x = xyh[0][0]
y = xyh[0][1]
h = xyh[0][2]

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

Submission status: Wrong Answer

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

x = xyh[0][0]
y = xyh[0][1]
h = xyh[0][2]

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

Submission status: Wrong Answer

Solution code:
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort(key=lambda x:x[2],reverse=True)
def cal(y,x,datum):
  if datum[2]==0:
    return
  return abs(y-datum[1])+abs(x-datum[0])+datum[2]
for i in range(101):
  for j in range(101):
    height=cal(i,j,data[0])
    flag=0
    for k in data[1:]:
      if height!=cal(i,j,k):
        flag=1
        break
    if flag:pass
    else:print(j,i,height);exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.sort(key=lambda x:x[2],reverse=True)
def cal(y,x,datum):
  if datum[2]==0:
    return
  return abs(y-datum[1])+abs(x-datum[0])+datum[2]
for i in range(101):
  for j in range(101):
    height=cal(i,j,data[0])
    flag=0
    for k in data[1:]:
      if height!=cal(i,j,k):
        flag=1
        break
    if flag:pass
    else:print(height);exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xs = []
for i in range(n):
    x,y,h = list(map(int,input().split()))
    xs.append((x,y,h))
 
#print(xs)
ans = True
htop = -1
for i in range(101):
    for j in range(101):
        htop = -1
        ans = True
        #print("----", i,j)
        for k in range(n):
            x,y,h = xs[k]
            #print(x,y,h,htop,h+abs(x-i)+abs(y-i))
            if h == 0:
                continue
            if htop == -1:
                htop = h + abs(x-i) + abs(y-j)
            if htop > 0 and htop != h + abs(x-i) + abs(y-j):
                ans = False
                break
            #print(htop,  h+abs(x-i) + abs(y-j), x,y,h)
        if ans:
            break
    if ans:
        break
if htop == -1:
	htop = 1  
print(i,j,htop)

Submission status: Wrong Answer

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

#print(xs)
for i in range(101):
    for j in range(101):
        htop = -1
        for k in range(n):
            x,y,h = xs[k]
            if h != 0:
                htop = h + abs(x-i) + abs(y-j)
                break
        ans = True
        #print("----", i,j)
        for k in range(n):
            x,y,h = xs[k]
            #print(x,y,h,htop,h+abs(x-i)+abs(y-i))
            if h == 0:
                if max(htop - abs(x-i) - abs(y-i), 0) == 0:
                    continue
            if h == 0:
                ans = False
                break
            if htop != h + abs(x-i) + abs(y-j):
                ans = False
                break
            if htop < 1:
                ans = False
                break
            #print(htop,  h+abs(x-i) + abs(y-j), x,y,h)
        if ans:
            break
    if ans:
        break
print(i,j,htop)

Submission status: Wrong Answer

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

#print(xs)
ans = True
htop = -1
for i in range(101):
    for j in range(101):
        htop = -1
        ans = True
        #print("----", i,j)
        for k in range(n):
            x,y,h = xs[k]
            #print(x,y,h,htop,h+abs(x-i)+abs(y-i))
            if h == 0:
                continue
            if htop == -1:
                htop = h + abs(x-i) + abs(y-j)
            if htop != h + abs(x-i) + abs(y-j):
                ans = False
                break
            if htop < 1:
                ans = False
                break
            #print(htop,  h+abs(x-i) + abs(y-j), x,y,h)
        if ans:
            break
    if ans:
        break
print(i,j,htop)