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


for cx in range(101):
    for cy in range(101):
        flag=1
        tmp=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
        for i in range(1,N):
            if xyh[i][2]==0 and abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)<=tmp:
                flag=0
                break
            if tmp!=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2] and xyh[i][2]!=0:
                flag=0
                break
        if flag:
            print(cx, cy, tmp)
            exit(0)

Submission status: Wrong Answer

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


for cx in range(101):
    for cy in range(101):
        flag=1
        tmp=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
        for i in range(1,N):
            if tmp!=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2] and xyh[i][2]!=0:
                flag=0
                break
        if flag:
            print(cx, cy, tmp)
            exit(0)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
N = int(input())

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


def calcCenterHeight(X, Y, Cx, Cy, Ch):
    return Ch + abs(X - Cx) + abs(Y - Cy)


for X in range(0, 101):
    for Y in range(0, 101):
        a = {calcCenterHeight(X, Y, Cx, Cy, Ch) for Cx, Cy, Ch in list}
        if len(a) == 1:
            print(X, Y, a.pop())

Submission status: Wrong Answer

Solution code:
n = int(input())
data=[]
for i in range(0,n):
    x, y, h = map(int,input().split())
    data.append((x,y,h))
data = sorted(data,key=lambda x:x[2],reverse=True)
st_x, st_y, st_h = data[0]
 
 
def get_search_area(x,y,n):
    area_list=[]
    for i in range(-n,n+1):
        for j in range(-n,n+1):
            if abs(i) == n or abs(j) == n:
                xi = x+i
                yi = y+j
                if 0<= xi <= 100 and 0 <= yi <= 100:
                    area_list.append((x+i, y+j, abs(i)+abs(j) ))
    return area_list
 
def meets_all_conditions(top, top_h,data):
    top_x, top_y, top_z = top
    top_h += top_z
    for item in data:
        pt_x, pt_y, pt_h = item
        tmp = top_h - abs(pt_x - top_x) - abs(pt_y - top_y)               
        if tmp > 0 and pt_h != tmp:
            #print(pt_h, tmp ,"False")
            return False    
    #print("True")
    return True
    
def main():    
    for i in range(200):
        #print(i)
        a = get_search_area(st_x,st_y,i)
        #print(a)
        for item in a:
            if meets_all_conditions(item, st_h , data):
                print("{} {} {}".format(item[0],item[1],st_h+item[2]))
                return
    return
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
data=[]
for i in range(0,n):
    x, y, h = map(int,input().split())
    data.append((x,y,h))
data = sorted(data,key=lambda x:x[2],reverse=True)
st_x, st_y, st_h = data[0]


def get_search_area(x,y,n):
    area_list=[]
    for i in range(-n,n+1):
        for j in range(-n,n+1):
            if abs(i) == n or abs(j) == n:
                xi = x+i
                yi = y+j
                if 0<= xi <= 100 and 0 <= yi <= 100:
                    area_list.append((x+i, y+j, abs(i)+abs(j) ))
    return area_list

def meets_all_conditions(top, top_h,data):
    top_x, top_y, top_z = top
    top_h += top_z
    for item in data:
        pt_x, pt_y, pt_h = item
        tmp = top_h - abs(pt_x - top_x) - abs(pt_y - top_y)               
        if tmp >= 0 and pt_h != tmp:
            #print(pt_h, tmp ,"False")
            return False    
    #print("True")
    return True
    
def main():    
    for i in range(200):
        #print(i)
        a = get_search_area(st_x,st_y,i)
        #print(a)
        for item in a:
            if meets_all_conditions(item, st_h , data):
                print("{} {} {}".format(item[0],item[1],st_h+item[2]))
                return
    return
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
data=[]
for i in range(0,n):
    x, y, h = map(int,input().split())
    data.append((x,y,h))
data
       
data = sorted(data,key=lambda x:x[2],reverse=True)
st_x, st_y, st_h = data[0]


def get_search_area(x,y,n):
    area_list=[]
    for i in range(-n,n+1):
        for j in range(-n,n+1):
            xi = x+i
            yi = y+j
            if 0<= xi <= 100 and 0 <= yi <= 100:
                area_list.append((x+i, y+j, abs(i)+abs(j) ))
    return area_list

def meets_all_conditions(top, top_h,data):
    top_x, top_y, top_z = top
    top_h += top_z
    for item in data:
        pt_x, pt_y, pt_h = item
        if pt_h != top_h - abs(pt_x - top_x) - abs(pt_y - top_y):
            #print(pt_h,top_h - abs(pt_x - top_x) - abs(pt_y - top_y),"False")
            return False    
    #print("True")
    return True
    
def main():    
    for i in range(200):
        #print(i)
        a = get_search_area(st_x,st_y,i)
        #print(a)
        for item in a:
            if meets_all_conditions(item, st_h , data):
                print("{} {} {}".format(item[0],item[1],st_h+item[2]))
                return
    return
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
 
data=[]
for i in range(0,n):
    x, y, h = map(int,input().split())
    data.append((x,y,h))
data
       
data = sorted(data,key=lambda x:x[2],reverse=True)
st_x, st_y, st_h = data[0]
 
 
def get_search_area(x,y,n):
    area_list=[]
    for i in range(-n,n+1):
        for j in range(-n,n+1):
            xi = x+i
            yi = y+j
            if 0<= xi <= 100 and 0 <= yi <= 100:
                area_list.append((x+i,y+j))
    return area_list
 
def meets_all_conditions(top, top_h,data):
    top_x, top_y = top
    for item in data:
        pt_x, pt_y, pt_h = item
        if pt_h != top_h - abs(pt_x - top_x) - abs(pt_y - top_y):
           # print(pt_h,top_h - abs(pt_x - top_x) - abs(pt_y - top_y),"False")
            return False    
    #print("True")
    return True
    
 
for i in range(200):
    #print(i)
    hi = i + st_h
    a = get_search_area(st_x,st_y,i)
    #print(a)
    for item in a:
        #print(item)
        if meets_all_conditions(item, hi , data):
            print("{} {} {}".format(item[0],item[1],hi))
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
 
data=[]
for i in range(0,n):
    x, y, h = map(int,input().split())
    data.append((x,y,h))
data
       
data = sorted(data,key=lambda x:x[2],reverse=True)
st_x, st_y, st_h = data[0]
 
 
def get_search_area(x,y,n):
    area_list=[]
    for i in range(-n,n+1):
        for j in range(-n,n+1):
            xi = x+i
            yi = y+j
            if 0<= xi <= 100 and 0 <= yi <= 100:
                area_list.append((x+i,y+j))
    return area_list
 
def meets_all_conditions(top, top_h,data):
    top_x, top_y = top
    for item in data:
        pt_x, pt_y, pt_h = item
        if pt_h != top_h - abs(pt_x - top_x) - abs(pt_y - top_y):
           # print(pt_h,top_h - abs(pt_x - top_x) - abs(pt_y - top_y),"False")
            return False    
    #print("True")
    return True
    
 
for i in range(101):
    #print(i)
    hi = i + st_h
    a = get_search_area(st_x,st_y,i)
    #print(a)
    for item in a:
        #print(item)
        if meets_all_conditions(item, hi , data):
            print("{} {} {}".format(item[0],item[1],hi))
            break

Submission status: Wrong Answer

Solution code:
n = int(input())

data=[]
for i in range(0,n):
    x, y, h = map(int,input().split())
    data.append((x,y,h))
data
       
data = sorted(data,key=lambda x:x[2],reverse=True)
st_x, st_y, st_h = data[0]


def get_search_area(x,y,n):
    area_list=[]
    for i in range(-n,n+1):
        for j in range(-n,n+1):
            xi = x+i
            yi = y+j
            if 0<= xi <= 100 and 0 <= yi <= 100:
                area_list.append((x+i,y+j))
    return area_list

def meets_all_conditions(top, top_h,data):
    top_x, top_y = top
    for item in data:
        pt_x, pt_y, pt_h = item
        if pt_h != top_h - abs(pt_x - top_x) - abs(pt_y - top_y):
           # print(pt_h,top_h - abs(pt_x - top_x) - abs(pt_y - top_y),"False")
            return False    
    #print("True")
    return True
    

for i in range(2):
    #print(i)
    hi = i + st_h
    a = get_search_area(st_x,st_y,i)
    #print(a)
    for item in a:
        #print(item)
        if meets_all_conditions(item, hi , data):
            print("{} {} {}".format(item[0],item[1],hi))
            break

Submission status: Wrong Answer

Solution code:
# coding: utf-8

N = int(input().strip())

input_tuples = []
selected_tuple = None

for _ in range(N):
    x, y, h = [int(s) for s in input().strip().split()]
    if selected_tuple is None and x > 0:
        selected_tuple = ((x, y, h))
    else:
        input_tuples.append((x, y, h))

for cx in range(0, 101):
    for cy in range(0, 101):
        H = selected_tuple[2] + \
            abs(selected_tuple[0] - cx) + abs(selected_tuple[1] - cy)

        for x, y, h in input_tuples:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            break
        continue
    else:
        continue
    break

print("{} {} {}".format(cx, cy, H))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

N = int(input().strip())

input_tuples = []
selected_tuple = None

for _ in range(N):
    x, y, h = [int(s) for s in input().strip().split()]
    if selected_tuple is None and x > 0:
        selected_tuple = ((x, y, h))
    else:
        input_tuples.append((x, y, h))

for cx in range(0, 101):
    for cy in range(0, 101):
        H = selected_tuple[2] + \
            abs(selected_tuple[0] - cx) + abs(selected_tuple[1] - cy)

        for x, y, h in input_tuples:
            if h != H - abs(x - cx) - abs(y - cy):
                break
        else:
            break
        continue
    else:
        continue
    break

print("{} {} {}".format(cx, cy, H))

Submission status: Wrong Answer

Solution code:
N = int(input())
x = [None for _ in range(N)]
y = [None for _ in range(N)]
h = [None for _ in range(N)]
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())
    if h[i] > 0:
        h_ = h[i]
for cx in range(0, 101):
    for cy in range(0, 101):
        hh = max(h_ + abs(x[i] - cx) + abs(y[i] - cy), 0)
        flag = True
        for i in range(N):
            h_i = max(hh - abs(x[i] - cx) - abs(y[i] - cy), 0)
            if h_i != h[i]:
                flag = False
        if flag:
            print(cx, cy, hh)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x = [None for _ in range(N)]
y = [None for _ in range(N)]
h = [None for _ in range(N)]
hh = [0 for _ in range(N)]
flag = False
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())
for cx in range(0, 101):
    for cy in range(0, 101):
        for i in range(N):
            hh[i] = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
        if (min(hh) == max(hh)) and (min(hh) >= 1):
            print(cx, cy, hh[0])
            exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]
points = sorted(points, key=lambda p: -p[2])
for c_x in range(101):
    for c_y in range(101):
        h = points[0][2] + abs(points[0][0] - c_x) + abs(points[0][1] - c_y)
        flag = True
        for point in points[1:]:
            if point[2] != 0 and point[2] + abs(point[0] - c_x) + abs(point[1] - c_y) != h:
                frag = False
                break
        else:
            print(c_x, c_y, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]
for c_x in range(101):
    for c_y in range(101):
        h = points[0][2] + abs(points[0][0] - c_x) + abs(points[0][1] - c_y)
        flag = True
        for point in points[1:]:
            if point[2] != 0 and point[2] + abs(point[0] - c_x) + abs(point[1] - c_y) != h:
                frag = False
                break
        else:
            print(c_x, c_y, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
points = [list(map(int, input().split())) for _ in range(N)]
for c_x in range(101):
    for c_y in range(101):
        h = points[0][2] + abs(points[0][0] - c_x) + abs(points[0][1] - c_y)
        flag = True
        for point in points[1:]:
            if point[2] + abs(point[0] - c_x) + abs(point[1] - c_y) != h:
                frag = False
                break
        else:
            print(c_x, c_y, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    if h_n >= 1:
        x.append(x_n)
        y.append(y_n)
        h.append(h_n)

def all_same(a):
    if all(a[i]==a[i+1] for i in range(0,len(a)-1)):
        return True
    else:
        return False

for C_x in range(101):
    for C_y in range(101):
        H=[]
        for i in range(len(x)):
            H.append(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y))
        H.sort()
        if all_same(H):
            print(C_x,C_y,H[0])

Submission status: Wrong Answer

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

def all_same(a):
    if all(a[i]==a[i+1] for i in range(0,len(a)-1)):
        return True
    else:
        return False

for C_x in range(101):
    for C_y in range(101):
        H=[]
        for i in range(len(x)):
            H.append(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y))
        H.sort()
        if all_same(H):
            print(C_x,C_y,H[0])

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def main():
    n = int(input())

    coordinates = []
    for _ in range(n):
        coordinates.append(list(map(int, input().split())))

    for coordinate in coordinates:
        if coordinate[2] > 0:
            xx = coordinate[0]
            yy = coordinate[1]
            hh = coordinate[2]
            break

    for px in range(101):
        for py in range(101):
            ph = hh + abs(xx - px) + abs(yy - py)

            if ph <= 0:
                continue

            suit = True
            for coordinate in coordinates:
                if coordinate[2] != ph - abs(coordinate[0] - px) - abs(coordinate[1] - py):
                    suit = False
                    break

            if suit == True:
                print(px, py, ph)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh = [[0, 0, 0] for i in range(N)]

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

finish = False
for cx in range(N):
    for cy in range(N):
        top = 0
        for x, y, h in xyh:
            if h != 0:
                top = abs(x-cx)+abs(y-cy)+h
        for x, y, h in xyh:
            finish = True
            if max(top - abs(x-cx)-abs(y-cy), 0) != h:
                finish = False
                break
        if finish == True:
            print ('{} {} {}'.format(cx, cy, top))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh = [[0, 0, 0] for i in range(N)]

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

finish = False
for cx in range(N):
    for cy in range(N):
        top = 0
        for x, y, h in xyh:
            if h != 0:
                top = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
        for x, y, h in xyh:
            finish = True
            if max(top - abs(x-cx)-abs(y-cy), 0) != h:
                finish = False
                break
        if finish == True:
            print ('{} {} {}'.format(cx, cy, top))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

xyh = [[0, 0, 0] for i in range(N)]

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

finish = False
for cx in range(N):
    for cy in range(N):
        top = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
        for x, y, h in xyh:
            finish = True
            if (top - abs(x-cx)-abs(y-cy)) != h:
                finish = False
                break
        if finish == True:
            print ('{} {} {}'.format(cx, cy, top))
            exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[0] * FIELD_SIZE for n in range(FIELD_SIZE)]
determined_flag = False

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if n == 0:
                H[cx][cy] = ch
                if h[n] != 0:
                    determined_flag = True

            elif determined_flag:
                if h[n] != 0:
                    if ch == H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0
                    determined_flag = True
                else:
                    if ch >= H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0

            else:
                if h[n] != 0:
                    if ch <= H[cx][cy]:
                        H[cx][cy] = ch
                    else:
                        H[cx][cy] = 0
                    determined_flag = True
                else:
                    H[cx][cy] = min(H[cx][cy], ch)

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] >= 1:
            print(cx, cy, H[cx][cy])

Submission status: Wrong Answer

Solution code:

N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[0] * FIELD_SIZE for n in range(FIELD_SIZE)]
determined_flag = False

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if n == 0:
                H[cx][cy] = ch
                if h[n] != 0:
                    determined_flag = True

            elif determined_flag:
                if h[n] != 0:
                    if ch == H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0
                else:
                    if ch >= H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0
                    determined_flag = True

            else:
                if h[n] != 0:
                    if ch <= H[cx][cy]:
                        H[cx][cy] = ch
                    else:
                        H[cx][cy] = 0
                else:
                    H[cx][cy] = min(H[cx][cy], ch)

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] >= 1:
            print(cx, cy, H[cx][cy])

Submission status: Wrong Answer

Solution code:
N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[-1] * FIELD_SIZE for n in range(FIELD_SIZE)]

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):
            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if H[cx][cy] == -1 or H[cx][cy] == ch:
                H[cx][cy] = ch
            else:
                H[cx][cy] = None

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] is not None:
            print(cx, cy, H[cx][cy])

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    x.append(x_n)
    y.append(y_n)
    h.append(h_n)
for C_x in range(101):
    for C_y in range(101):
        H=h[0]+abs(x[0]-C_x)+abs(y[0]-C_y)
        if H <1:
            break
        if all(H==h[i]+abs(x[i]-C_x)+abs(y[i]-C_y) for i in range(N)):
            print(C_x,C_y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    x.append(x_n)
    y.append(y_n)
    h.append(h_n)
for C_x in range(101):
    for C_y in range(101):
        H=h[0]+abs(x[0]-C_x)+abs(y[0]-C_y)
        if all(H==h[i]+abs(x[i]-C_x)+abs(y[i]-C_y) for i in range(N)):
            print(C_x,C_y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    x.append(x_n)
    y.append(y_n)
    h.append(h_n)
for C_x in range(101):
    for C_y in range(101):
        H=h[1]+abs(x[1]-C_x)+abs(y[1]-C_y)
        if all(H==h[i]+abs(x[i]-C_x)+abs(y[i]-C_y) for i in range(N)):
            print(C_x,C_y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    x.append(x_n)
    y.append(y_n)
    h.append(h_n)
for C_x in range(101):
    for C_y in range(101):
        if all(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y)==h[i+1]+abs(x[i+1]-C_x)+abs(y[i+1]-C_y) for i in range(N-1)):
            if h[1]+abs(x[1]-C_x)+abs(y[1]-C_y) >1 or h[1]+abs(x[1]-C_x)+abs(y[1]-C_y)==1:
                H=h[1]+abs(x[1]-C_x)+abs(y[1]-C_y)
                print(C_x,C_y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    x.append(x_n)
    y.append(y_n)
    h.append(h_n)
for C_x in range(101):
    for C_y in range(101):
        if all(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y)==h[i+1]+abs(x[i+1]-C_x)+abs(y[i+1]-C_y) for i in range(N-1)):
            H=h[1]+abs(x[1]-C_x)+abs(y[1]-C_y)
            print(C_x,C_y,H)

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = [LGIS() for _ in range(GI())]

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if h == 0:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                for x, y, h in sols:
                    if h:
                        continue
                    if H <= abs(x - cx) + abs(y - cy):
                        break
                else:
                    print(cx, cy, H)
                    return

main()

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = [LGIS() for _ in range(GI())]

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if h == 0:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                for x, y, h in sols:
                    if h:
                        continue
                    if H > abs(x - cx) + abs(y - cy):
                        break
                else:
                    print(cx, cy, H)
                    return

main()

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())
 
def main():
    sols = [LGIS() for _ in range(GI())]
 
    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                if h == 0:
                    continue
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return
 
main()

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = [LGIS() for _ in range(GI())]

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                factor = abs(x - cx) + abs(y - cy)
                H = h + factor
                if H < 1:
                    continue
                if h == 0:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return

main()

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = [LGIS() for _ in range(GI())]

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                factor = abs(x - cx) + abs(y - cy)
                H = h + factor
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return

main()

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = [LGIS() for _ in range(GI())]

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                factor = abs(x - cx) + abs(y - cy)
                H = h + factor
                if H < 1:
                    continue
                if h == 0 and H <= factor:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return

main()

Submission status: Wrong Answer

Solution code:
import sys

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

n = int(input())
x = []
y = []
h = []
for _ in range(n):
	xi, yi, hi = map(int, input().split())
	if hi == 0:
		continue
	x.append(xi)
	y.append(yi)
	h.append(hi)

for cx in range(101):
	for cy in range(101):
		height = get_height(h[0], x[0], y[0], cx, cy)
		is_valid = True
		for i in range(1, len(x)):
			if height != get_height(h[i], x[i], y[i], cx, cy):
				is_valid = False
				break
		if is_valid:
			print(cx, cy, height)
			sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

n = int(input())
x = []
y = []
h = []
for _ in range(n):
	xi, yi, hi = map(int, input().split())
	if hi == 0:
		continue
	x.append(xi)
	y.append(yi)
	h.append(hi)

for cx in range(101):
	for cy in range(101):
		height = get_height(h[0], x[0], y[0], cx, cy)
		for i in range(1, len(x)):
			if height != get_height(h[i], x[i], y[i], cx, cy):
				break
		else:
			print(cx, cy, height)
			sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

for cx in range(101):
	for cy in range(101):
		height = None
		for i in range(n):
			dx = abs(x[i] - cx)
			dy = abs(y[i] - cy)
			if h[i] == 0:
				continue
			thisheight = h[i] + dx + dy
			if height is not None and height != thisheight:
				break
			height = thisheight
		else:
			# all are in line with this cx, cy
			if height is None:
				height = 1 # heightsup must be 1
			print(cx, cy, height)
			sys.exit()