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

if all(h[i] == 0 for i in range(N)):

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

            for k in range(N):
                if i != x[k] and j != y[k]:
                    print(i,j,1)
                    break

else:

    for i in range(101):
        for j in range(101):
            
            for k in range(N):
                if h[k] == 0:
                    continue
                H = abs(i-x[k]) + abs(j-y[k]) + h[k]
                break

            for k in range(N):
                if h[k] == 0:
                    continue
                if H != abs(i-x[k]) + abs(j-y[k]) + h[k]:
                    break
            else:
                print(i,j,H)

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        
        for k in range(N):
            if h[k] == 0:
                continue
            H = abs(i-x[k]) + abs(j-y[k]) + h[k]
            break

        for k in range(N):
            if h[k] == 0:
                continue
            if H != abs(i-x[k]) + abs(j-y[k]) + h[k]:
                break
        else:
            print(i,j,H)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] != max(tmp-abs(x[i]-Cx)-abs(y[i]-Cy), 0)):
                    break
                if(i == N-1 and tmp > 1):
                    print(Cx, Cy, tmp)
                    quit()               
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] > 0 and tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                    break
                if(i == N-1 and tmp > 1):
                    print(Cx, Cy, tmp)
                    quit()               
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = 0
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = max(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] > 0 and tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                    break
                if(i == N-1 and tmp > 0 and h[k] > 0):
                    print(Cx, Cy, tmp)
                    quit()
                elif(i == N-1 and h[k] == 0):
                    print(Cx, Cy, tmp+1)
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = 0
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = max(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] > 0 and tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                    break
                if(i == N-1 and tmp > 0):
                    print(Cx, Cy, tmp)
                    quit()
                elif(i == N-1 and tmp == 0):
                    print(Cx, Cy, 1)
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] > 0 and tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                    break
                if(i == N-1 and tmp > 0):
                    print(Cx, Cy, tmp)
                    quit()
                elif(i == N-1 and tmp == 0):
                    print(Cx, Cy, abs(x[k]-Cx)+abs(y[k]-Cy)+1)
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] > 0 and tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                    break
                if(i == N-1 and tmp > 0):
                    print(Cx, Cy, tmp)
                    quit()
                else:
                    print(Cx, Cy, abs(x[k]-Cx)+abs(y[k]-Cy)+1)
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N
    k = N
    
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
        if(h[i] > 0):
            k = min(k, i)
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[k]-Cx)+abs(y[k]-Cy)+h[k]
            for i in range(N):
                if(h[i] > 0 and tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                    break
                if(i == N-1):
                    print(Cx, Cy, tmp)
                    quit()
                
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N

    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    for Cx in range(101):
        for Cy in range(101):
            if(h[0] != 0):
                tmp = abs(x[0]-Cx)+abs(y[0]-Cy)+h[0]
                for i in range(1, N):
                    if(tmp < 1 or tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                           break
                    if(i == N-1):
                        print(Cx, Cy, tmp)
                        quit()
            else:
                tmp = -abs(x[0]-Cx)-abs(y[0]-Cy)
                for i in range(1, N):
                    if(tmp != -abs(x[i]-Cx)-abs(y[i]-Cy)):
                        break
                    if(i == N-1):
                        print(Cx, Cy, 1+tmp*(-1))
                        quit()
    
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N

    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = max(abs(x[0]-Cx)+abs(y[0]-Cy)+h[0], 0)
            for i in range(1, N):
                if(tmp == 0 or tmp != max(0, abs(x[i]-Cx)+abs(y[i]-Cy)+h[i])):
                       break
                if(i == N-1):
                    print(Cx, Cy, tmp)
    
main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    x = [0]*N
    y = [0]*N
    h = [0]*N

    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    for Cx in range(101):
        for Cy in range(101):
            tmp = abs(x[0]-Cx)+abs(y[0]-Cy)+h[0]
            for i in range(1, N):
                if(tmp != abs(x[i]-Cx)+abs(y[i]-Cy)+h[i]):
                       break
                if(i == N-1):
                    print(Cx, Cy, tmp)
    
main()

Submission status: Wrong Answer

Solution code:
import sys

N=int(input())
xyhlist=[]
for i in range(N):
  x,y,h=map(int,input().split())
  xyhlist.append((x,y,h))
#print(xyhlist)

for cx in range(101):
  for cy in range(101):
    ch=-1
    for x,y,h in xyhlist:
      if h==0:
        continue
      elif ch==-1:
        ch=h+abs(x-cx)+abs(y-cy)
        #print(cx,cy,ch)
      else:
        ch2=h+abs(x-cx)+abs(y-cy)
        if ch!=ch2:
          break
    else:
      print(cx,cy,ch)
      sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys

N=int(input())
xyhlist=[]
for i in range(N):
  x,y,h=map(int,input().split())
  xyhlist.append((x,y,h))
#print(xyhlist)

for cx in range(101):
  for cy in range(101):
    ch=-1
    for x,y,h in xyhlist:
      if ch==-1:
        ch=h+abs(x-cx)+abs(y-cy)
        #print(cx,cy,ch)
      else:
        ch2=h+abs(x-cx)+abs(y-cy)
        if ch!=ch2:
          break
    else:
      print(cx,cy,ch)
      sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
import copy

N = int(input())

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

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

for cx in range(101):
    for cy in range(101):
        beforeH = ""
        roop = 0
        minH = float('inf')
        for i in range(len(XYH)):
            if XYH[i][2] == 0:
                minH = min(minH, abs(cx-XYH[i][0])+abs(cy-XYH[i][1]))
                roop += 1
            else:
                calced_H = calcH(XYH[i][0], XYH[i][1], XYH[i][2], cx, cy)
                if beforeH == "":
                    beforeH = calced_H
                elif calced_H > minH:
                    break
                elif beforeH != calced_H:
                    break
                roop += 1
        if roop == N:
            print(str(cx)+" "+str(cy)+" "+str(min(beforeH,minH)))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
import copy

N = int(input())

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

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

for cx in range(101):
    for cy in range(101):
        beforeH = ""
        roop = 0
        minH = float('inf')
        for i in range(len(XYH)):
            if XYH[i][2] == 0:
                minH = min(minH, abs(cx-XYH[i][0])+abs(cy-XYH[i][1]))
                roop += 1
            else:
                calced_H = calcH(XYH[i][0], XYH[i][1], XYH[i][2], cx, cy)
                if beforeH == "":
                    beforeH = calced_H
                elif calced_H > minH:
                    break
                elif beforeH != calced_H:
                    break
                roop += 1
        if roop == N:
            print(str(cx)+" "+str(cy)+" "+str(beforeH))
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
field=[[0 for _ in range(101)] for _ in range(101)]

p=[list(map(int,input().split())) for _ in range(N)]
for x,y,h in p:
    if h!=0:
        tem_x=x
        tem_y=y
        tem_h=h
        break

for i in range(101):
    for k in range(101):
        flag=True
        H=tem_h+abs(tem_x-i)+abs(tem_y-k)
        for x,y,h in p:
            if H==max(h+abs(x-i)+abs(y-k),0):
                pass
            else:
                flag=False
        if flag:
            print(i,k,H)
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
field=[[0 for _ in range(101)] for _ in range(101)]

p=[list(map(int,input().split())) for _ in range(N)]
for x,y,h in p:
    if h!=0:
        tem_x=x
        tem_y=y
        tem_h=h
        break

for i in range(101):
    for k in range(101):
        flag=True
        H=tem_h+abs(tem_x-i)+abs(tem_y-k)
        for x,y,h in p:
            if H==h+abs(x-i)+abs(y-k):
                pass
            else:
                flag=False
        if flag:
            print(i,k,H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
for i in range(N):
    h = xyh_list[i][2]
    if h != 0:
        no_zero_h = i
        break
else:
    print("aaaaaaaaaaa")

break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        x = xyh_list[no_zero_h][0]
        y = xyh_list[no_zero_h][1]
        h = xyh_list[no_zero_h][2]
        H = h + abs(x-i) + abs(y-j)
        
        if 1 <= H:
            for k in range(0,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                if h != 0 and h + abs(x-i) + abs(y-j) != H:
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
            
    if break_flag == 1:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
for i in range(N):
    h = xyh_list[i][2]
    if h != 0:
        no_zero_h = i
        break
        
break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        x = xyh_list[no_zero_h][0]
        y = xyh_list[no_zero_h][1]
        h = xyh_list[no_zero_h][2]
        H = h + abs(x-i) + abs(y-j)
        
        if 1 <= H:
            for k in range(0,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                if h + abs(x-i) + abs(y-j) != H:
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
            
    if break_flag == 1:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
for i in range(N):
    h = xyh_list[i][2]
    if h != 0:
        no_zero_h = i
        break

break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        #print("Cx=",i,",Cy=",j)
        
        #h = max(H-abs(x-Cx)-abs(y-Cy),0)
        #H = h + abs(x-i) + abs(y-j)
        x = xyh_list[no_zero_h][0]
        y = xyh_list[no_zero_h][1]
        h = xyh_list[no_zero_h][2]
        H = h + abs(x-i) + abs(y-j)
        
        #print(h,"=max(",H-abs(x-i)-abs(y-j),",0)")
        
        if 1 <= H:
            for k in range(0,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                #print(h,"=max(",H-abs(x-i)-abs(y-j),",0)")
                
                if h != 0 and h + abs(x-i) + abs(y-j) != H:
                    #print("Error")
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
    if break_flag == 1:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
H_set = set()

break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        #print("Cx=",i,",Cy=",j)
        
        #h = max(H-abs(x-Cx)-abs(y-Cy),0)
        #H = h + abs(x-i) + abs(y-j)
        x = xyh_list[0][0]
        y = xyh_list[0][1]
        h = xyh_list[0][2]
        H = h + abs(x-i) + abs(y-j)
        
        #print(h,"=max(",H-abs(x-i)-abs(y-j),",0)")
        
        if 1 <= H:
            for k in range(1,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                if h + abs(x-i) + abs(y-j) != H:
                    #print("Error")
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
    if break_flag == 1:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
H_set = set()

break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        #print("Cx=",i,",Cy=",j)
        
        #h = max(H-abs(x-Cx)-abs(y-Cy),0)
        #H = h + abs(x-i) + abs(y-j)
        x = xyh_list[0][0]
        y = xyh_list[0][1]
        h = xyh_list[0][2]
        H = h + abs(x-i) + abs(y-j)
        
        #print(h,"=max(",H-abs(x-i)-abs(y-j),",0)")
        
        if 1 <= H:
            for k in range(1,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                #print(h,"=max(",H-abs(x-i)-abs(y-j),",0)")
                
                if h != 0 and h + abs(x-i) + abs(y-j) != H:
                    #print("Error")
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
    if break_flag == 1:
        break

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N=int(input())

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

xyh.sort(key=itemgetter(2),reverse=True)
for h in xyh:
    if h[2]==0:
        count+=1
for px in range(101):
    for py in range(101):
        judge=0
        base=0
        for i in xyh:
            if i[2]>=1:
                if base==0:
                    base=i[2]+abs(i[0]-px)+abs(i[1]-py)
                    judge+=1
                elif base==i[2]+abs(i[0]-px)+abs(i[1]-py):
                    judge+=1
            else:
                if max(base-abs(i[0]-px)-abs(i[1]-py),0)==0:
                    judge=0

        if judge==N:
            print(px,py,base)
            break

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N=int(input())

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

xyh.sort(key=itemgetter(2),reverse=True)
for h in xyh:
    if h[2]==0:
        count+=1
for px in range(101):
    for py in range(101):
        judge=0
        base=0
        for i in xyh:
            if base==0:
                base=i[2]+abs(i[0]-px)+abs(i[1]-py)
                judge+=1
            elif base==i[2]+abs(i[0]-px)+abs(i[1]-py):
                judge+=1

        if judge==N:
            print(px,py,base)
            break

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
N=int(input())

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

xyh.sort(key=itemgetter(2),reverse=True)
for h in xyh:
    if h[2]==0:
        count+=1
for px in range(101):
    for py in range(101):
        judge=0
        base=0
        for i in xyh:
            if base==0:
                base=i[2]+abs(i[0]-px)+abs(i[1]-py)
                judge+=1
            elif base==i[2]+abs(i[0]-px)+abs(i[1]-py):
                judge+=1

        if judge==N-count:
            print(px,py,base)
            break

Submission status: Wrong Answer

Solution code:
N=int(input())

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

for x in range(101):
    for y in range(101):
        judge=0
        base=0
        zero=0
        for i in xyh:
            if i[2]>=1:
                if base==0:
                    base=i[2]+abs(i[0]-x)+abs(i[1]-y)
                    judge+=1
                elif base==i[2]+abs(i[0]-x)+abs(i[1]-y):
                    judge+=1
            else:
                zero+=1
        if judge==N-zero:
            print(x,y,i[2]+abs(i[0]-x)+abs(i[1]-y))

Submission status: Wrong Answer

Solution code:

n = int(input())

data = [list(map(int, input().split())) for _ in range(n)]
result = [0] * n

for i in range(100 + 1):
    for j in range(100 + 1):
        for k in range(n):
            result[k] = data[k][2] + abs(data[k][0] - i) + abs(data[k][1] - j)
        if max(result) == min(result):
            print("{0} {1} {2}".format(i, j, max(result)))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
data = []
for _ in range(N):
    x, y, h = map(int,input().split())
    data.append([h, x, y])
data.sort(reverse=True)
end = False
for x in range(101):
    if end:
        break
    for y in range(101):
        xi, yi, hi = data[0]
        H = hi + abs(x - xi) + abs(y - yi)
        for i in range(1, N):
            xi, yi, hi = data[i]
            if max(H - abs(x - xi) - abs(y - yi), 0) != hi:
                break
            if i == N - 1:
                print(x, y, H)
                end = True
                break

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):

        x, y, h = XYH[0]
        H = abs(x-cx) + abs(y-cy) + h

        if all([h == H - abs(x-cx) - abs(y-cy) for x, y, h in XYH]):
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):

        x, y, h = XYH[1]
        H = abs(x-cx) + abs(y-cy) + h

        if all([h == H - abs(x-cx) - abs(y-cy) for x, y, h in XYH]):
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):

        x, y, h = XYH[0]
        H = abs(x-cx) + abs(y-cy) + h

        if all([H == abs(x-cx) + abs(y-cy) + h for x, y, h in XYH]):
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

for cx in range(0, 101):
    for cy in range(0, 101):

        for x, y, h in XYH:

            H = None
            if h != 0:
                H = abs(x - cx) + abs(y - cy) + h
                break

            if H == None:
                X = [None] * 101
                Y = [None] * 101
                for x, y, h in XYH:
                    X[x] = True
                    Y[y] = True
                print(X.index(None), Y.index(None), 1)
                exit()

        cnt = 0
        for x, y, h in XYH:
            if h != 0:
                if abs(x - cx) + abs(y - cy) + h == H:
                    cnt += 1
            else:
                cnt += 1

        if cnt == n:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

for cx in range(0, 101):
    for cy in range(0, 101):

        for x, y, h in XYH:
            if h != 0:
                H = abs(x - cx) + abs(y - cy) + h
                break

        cnt = 0
        for x, y, h in XYH:
            if h != 0:
                if abs(x - cx) + abs(y - cy) + h == H:
                    cnt += 1
            else:
                cnt += 1

        if cnt == n:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(n))

for cx in range(0, 101):
    for cy in range(0, 101):

        for x, y, h in XYH:
            if h != 0:
                H = abs(x - cx) + abs(y - cy) + h
                break

        if all([H == abs(x - cx) + abs(y - cy) + h and h != 0 for x, y, h in XYH]):
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(N))

def judge(cx, cy):
    x, y, h = XYH[0]
    H = abs(x - cx) + abs(y - cy) + h
    for x, y, h in XYH[1:]:
        if H != abs(x - cx) + abs(y - cy) + h and h != 0:
            return False
    return H

for cx in range(0, 101):
    for cy in range(0, 101):
        H = judge(cx, cy)
        if H != False:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
import sys

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

for xx in range(101):
    for yy in range(101):
        fl = 1
        a = []
        for i in range(n):
            temp = abs(x[i]-xx) + abs(y[i]-yy) + h[i]
            a.append(temp)
            le = len(a)
                
            if le > 1:
                if a[le-1] != a[le-2]:
                    fl = 0
                        
        if fl == 1:
            print(xx,yy,max(a))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

for xx in range(101):
    for yy in range(101):
        fl = 1
        a = []
        for i in range(n):
            if h[i] != 0:
                temp = abs(x[i]-xx) + abs(y[i]-yy) + h[i]
                a.append(temp)
                le = len(a)
                
                if le > 1:
                    if a[le-1] != a[le-2]:
                        fl = 0
                        
        if fl == 1:
            print(xx,yy,max(a))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
H = np.zeros(N)
a = [0] * N
for i in range(N):
    a[i] = list(map(int,input().split()))
for i in range(101):
    for j in range(101):
        for k in range(N):
            x = a[k][0]
            y = a[k][1]
            h = a[k][2]
            H[k] = h + abs(x - i) + abs(y - j)
            if k == N-1:
                flag = True
                for l in range(N-1):
                    if H[l] != H[l+1]:
                        flag = False
                if flag:
                    print(i, j, int(H[0]))
                    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = list(tuple(map(int, input().split())) for _ in range(N))

def judge(cx, cy):
    x, y, h = XYH[0]
    H = abs(x - cx) + abs(y - cy) + h
    for x, y, h in XYH[1:]:
        if H != abs(x - cx) + abs(y - cy) + h:
            return False
    return H

for cx in range(0, 101):
    for cy in range(0, 101):
        H = judge(cx, cy)
        if H != False:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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


def set_height(i,x,y):
	ans = z[i][2] + abs(z[i][0] - x) + abs(z[i][1] - y)
	return ans


answer = 0
for j in range(0,101):
	for k in range(0,101):
		flag = 1
		for l in range(0,n):
			if z[l][2] != 0:
				answer = set_height(l,j,k)
				break

		for l in range(0,n):
			if z[l][2] == 0:
				if answer > set_height(l,j,k):	
					flag = 0
					break
			else:
				if answer != set_height(l,j,k):
					flag = 0
					break
		if flag == 1 and answer > 0 and answer <= 10**9:
			test = map(str,(j,k,answer))
			print(" ".join(test))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = [list(map(int, input().split())) for _ in range(n)]
ans = [0]
if not n == 1:
    for i in range(101):
        for j in range(101):
            c = s[0][2] + abs(i - s[0][0]) + abs(j - s[0][1])
            d = 0
            for k in range(n):
                if abs(i - s[k][0]) + abs(j - s[k][1]) != c - s[k][2]:
                    d = 1
                    break
            if d == 0:
                ans = [i, j, c]
                break
        if len(ans) == 3:
            break
else:
    ans = s[0]
print(" ".join(map(str, ans)))

Submission status: Wrong Answer

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

def set_height(i,x,y):
	ans = z[i][2] + abs(z[i][0] - x) + abs(z[i][1] - y)
	return ans


answer = 0
for j in range(0,101):
	for k in range(0,101):
		answer=set_height(0,j,k)
		flag = 1
		for l in range(1,n):
			if answer!= set_height(l,j,k):
				flag = 0
				break
		if flag == 1 and answer <= 10**9:
			test = map(str,(j,k,answer))
			print(" ".join(test))

Submission status: Wrong Answer

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

def set_height(i,x,y):
	ans = z[i][2] + abs(z[i][0] - x) + abs(z[i][1] - y)
	return ans


answer = 0
for j in range(0,101):
	for k in range(0,101):
		answer=set_height(0,j,k)
		flag = 0
		for l in range(1,n):
			if answer!= set_height(l,j,k):
				flag = 0
				break
			else:
				flag = 1
		if flag == 1:
			test = map(str,(j,k,answer))
			print(" ".join(test))