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 i in range(n)]
for cx in range(101):
    for cy in range(101):
        H = set()
        flag = False
        for i in range(n):
            x, y, h = xyh[i]
            if h != 0:
                H.add(abs(x - cx) + abs(y - cy) + h)
            else:
                if len(H) > 0:
                    Hkari = list(H)[0]
                    if max(Hkari - abs(x - cx) - abs(y - cy), 0) != 0:
                        flag = True
        if flag:
            continue
        if len(H) == 1 and list(H)[0] > 0:
            print(cx, cy, list(H)[0])
            exit()

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 = set()
        for i in range(n):
            x, y, h = xyh[i]
            if h != 0:
                H.add(abs(x - cx) + abs(y - cy) + h)
            else:
                if len(H) > 0:
                    Hkari = list(H)[0]
                    if max(Hkari - abs(x - cx) - abs(y - cy), 0) != 0:
                        break
        if len(H) == 1 and list(H)[0] > 0:
            print(cx, cy, list(H)[0])
            exit()

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 = set()
        for i in range(n):
            x, y, h = xyh[i]
            H.add(abs(x - cx) + abs(y - cy) + h)
        if len(H) == 1 and list(H)[0] > 0:
            print(cx, cy, list(H)[0])
            exit()

Submission status: Wrong Answer

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

cands = []
for cy in range(101):
    for cx in range(101):
        h_tmp = None
        for x,y,h in XYH:
            d = abs(cy-y) + abs(cx-x)
            if h_tmp is None:
                h_tmp = h+d
            else:
                if h+d != h_tmp:
                    break
        else:
            cands.append((cx,cy,h_tmp))

for cx,cy,ch in cands:
    for x,y,h in XYH:
        if max(ch - abs(x-cx) - abs(y-cy), 0) != h:
            break
    else:
        print(cx,cy,ch)

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 = set()
        for i in range(n):
            x, y, h = xyh[i]
            if h != 0:
                H.add(abs(x - cx) + abs(y - cy) + h)
        if len(H) == 1 and list(H)[0] > 0:
            print(cx, cy, list(H)[0])
            exit()

Submission status: Wrong Answer

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

cands = []
for cy in range(101):
    for cx in range(101):
        x0,y0,h0 = XYH[0]
        d = abs(cy-y0) + abs(cx-x0)
        h_tmp = h0 + d
        for x,y,h in XYH[1:]:
            d = abs(cy-y) + abs(cx-x)
            if h+d != h_tmp:
                break
        else:
            cands.append((cx,cy,h_tmp))

for cx,cy,ch in cands:
    for x,y,h in XYH:
        if max(ch - abs(x-cx) - abs(y-cy), 0) != h:
            break
    else:
        print(cx,cy,ch)

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 = set()
        for i in range(n):
            x, y, h = xyh[i]
            if h != 0:
                H.add(abs(x - cx) + abs(y - cy) + h)
        if len(H) == 1:
            print(cx, cy, list(H)[0])
            exit()

Submission status: Wrong Answer

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

cands = []
for cy in range(101):
    for cx in range(101):
        x0,y0,h0 = XYH[0]
        d = abs(cy-y0) + abs(cx-x0)
        h_tmp = h0 + d
        for x,y,h in XYH[1:]:
            d = abs(cy-y) + abs(cx-x)
            if h+d != h_tmp:
                break
        else:
            cands.append((cx,cy,h_tmp))

for cx,cy,ch in cands:
    for x,y,h in XYH:
        d = abs(cy-y) + abs(cx-x)
        if h+d != ch:
            break
    else:
        print(cx,cy,ch)

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    
    P = set()
    for i in range(n):
        x,y,h = map(int,input().split())
        if h != 0:
            P.add((x,y,h))
    x,y,h = P.pop()
    for cx in range(101):
        for cy in range(101):
            H = h + abs(x-cx) + abs(y-cy)
            for p in P:
                if H != p[2] + abs(p[0]-cx) + abs(p[1]-cy):
                    break
            else:
                return cx,cy,H
        
if __name__ == '__main__':
    print(*(solve()))

Submission status: Wrong Answer

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

N = int(input().split()[0])
xyh_list = []
not_zero_h_list = []

for _ in range(N):
    x, y, h = list(map(int, input().split()))
    xyh_list.append((x, y, h))
    if h != 0:
        not_zero_h_list.append((x, y, h))

# 高さ0の情報は除く
target_x, target_y, target_h = not_zero_h_list[0]

for cx in range(0, 101):
    for cy in range(0, 101):
        # cx, cy = 2, 2
        H_list = []
        # 基準
        H = target_h + abs(target_x - cx) + abs(target_y - cy)
        H = max(0, H)
        is_ok = True

        # 他の座標の結果と一致するかどうか確認する
        for x, y, h in not_zero_h_list:
            HH = h + abs(x - cx) + abs(y - cy)
            HH = max(0, HH)
            if HH != H:
                # 一致しない
                is_ok = False
                break
        if is_ok:
            break

    if is_ok:
        break
ans = "{} {} {}".format(cx, cy, H)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True
        for i, (x,y,h) in enumerate(xyh):
            if i == 0:
                H = h + abs(x - cx) + abs(y - cy)
            else:

                if h == max(H - abs(x - cx) - abs(y - cy), 0):
                    continue
                else:
                    flag = False
                    break
        if flag:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    H = 0
    for i in range(N):
        if xyh[i][2] >= H:
            X = xyh[i][0]
            Y = xyh[i][1]
            H = xyh[i][2]
    
    flag = True
    for i in range(0, N):
        if xyh[i][2] != 0:
            if H != xyh[i][2] + abs(xyh[i][0] - X) + abs(xyh[i][1] - Y):
                flag = False
        else:
            if abs(xyh[i][0] - X) + abs(xyh[i][1] - Y) < H:
                flag = False
    
    if not flag:
        for x in range(0, 101):
            for y in range(0, 101):
                flag = True
                height = 0
                for i in range(0, N):
                    if xyh[i][2] != 0:
                        if height == 0:
                            height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                        if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                            flag = False
                            break
                    else:
                        if abs(xyh[i][0] - x) + abs(xyh[i][1] - y) < height:
                            flag = False
                            break
                if flag and height:
                    X = x
                    Y = y
                    
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    H = 0
    for i in range(N):
        if xyh[i][2] >= H:
            X = xyh[i][0]
            Y = xyh[i][1]
            H = xyh[i][2]
    
    flag = True
    for i in range(0, N):
        if xyh[i][2] != 0:
            if H != xyh[i][2] + abs(xyh[i][0] - X) + abs(xyh[i][1] - Y):
                flag = False
    
    if not flag:
        for x in range(0, 101):
            for y in range(0, 101):
                flag = True
                height = 0
                for i in range(0, N):
                    if xyh[i][2] != 0:
                        if height == 0:
                            height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                        if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                            flag = False
                            break
                    else:
                        if abs(xyh[i][0] - x) + abs(xyh[i][1] - y) < height:
                            flag = False
                            break
                if flag and height:
                    X = x
                    Y = y
                    
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    H = 0
    for i in range(N):
        if xyh[i][2] >= H:
            X = xyh[i][0]
            Y = xyh[i][1]
            H = xyh[i][2]
    
    flag = True
    for i in range(0, N):
        if xyh[i][2] != 0:
            if H != xyh[i][2] + abs(xyh[i][0] - X) + abs(xyh[i][1] - Y):
                flag = False
    
    if not flag:
        for x in range(0, 101):
            for y in range(0, 101):
                flag = True
                height = 0
                for i in range(0, N):
                    if xyh[i][2] != 0:
                        if height == 0:
                            height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                        if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                            flag = False
                            break
                if flag and height:
                    X = x
                    Y = y
                    
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    H = 0
    for i in range(N):
        if xyh[i][2] >= H:
            X = xyh[i][0]
            Y = xyh[i][1]
            H = xyh[i][2]
    
    flag = True
    for i in range(0, N):
        if H != xyh[i][2] + abs(xyh[i][0] - X) + abs(xyh[i][1] - Y):
            flag = False
    
    if not flag:
        for x in range(0, 101):
            for y in range(0, 101):
                flag = True
                height = 0
                for i in range(0, N):
                    if xyh[i][2] != 0:
                        if height == 0:
                            height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                        if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                            flag = False
                            break
                if flag and height:
                    X = x
                    Y = y
                    
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    X = xyh[0][0]
    Y = xyh[0][1]
    H = xyh[0][2]
    
    for x in range(0, 101):
        for y in range(0, 101):
            flag = True
            height = 0
            for i in range(0, N):
                if xyh[i][2] != 0:
                    if height == 0:
                        height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                    if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                        flag = False
                        break
            if flag and height:
                X = x
                Y = y
                    
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [tuple(map(int,input().split())) for _ in range(N)]
D = sorted(D,key=lambda x:x[2], reverse=True)
if D[0][2]>0:
    for cx in range(101):
        for cy in range(101):
            ind = 1
            x,y,h = D[0]
            H = abs(x-cx)+abs(y-cy)+h
            for i in range(1,N):
                x,y,h = D[i]
                if h>0 and abs(x-cx)+abs(y-cy)+h!=H:
                    ind = 0
                    break
            if ind==1:
                CX = cx
                CY = cy
                break
        if ind==1:break
else:
    hmin = 10**10
    for cx in range(101):
        for cy in range(101):
            for i in range(N):
                x,y,h = D[i]
                H = abs(cx-x)+abs(cy-y)
                if H<hmin:
                    hmin = H
                    CX = cx
                    CY = cy
    H = hmin
print(CX,CY,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [tuple(map(int,input().split())) for _ in range(N)]
D = sorted(D,key=lambda x:x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        ind = 1
        x,y,h = D[0]
        H = abs(x-cx)+abs(y-cy)+h
        for i in range(1,N):
            x,y,h = D[i]
            if h>0 and abs(x-cx)+abs(y-cy)+h!=H:
                ind = 0
                break
        if ind==1:
            CX = cx
            CY = cy
            break
    if ind==1:break
print(CX,CY,H)

Submission status: Wrong Answer

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

for cx in range(0,101):
    for cy in range(0, 101):
        ch = 0
        for i in range(0,N):
            if xyh[i][2] > 0:
                ch = xyh[i][2] + abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy)
                break
        for i in range(1, N):

            if xyh[i][2] != max(ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -  cy), 0):
                break
        else:
            print('{} {} {}'.format(cx, cy, ch))
            break
    else:
        continue
    break

Submission status: Wrong Answer

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

height = 0
for cx in range(0,101):
    for cy in range(0, 101):
        ch = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for i in range(1, N):
            if xyh[i][2] != max(ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -  cy), 0):
                break
        else:
            print('{} {} {}'.format(cx, cy, ch))
            break
    else:
        continue
    break

Submission status: Wrong Answer

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

height = 0
for cx in range(0,101):
    for cy in range(0, 101):
        ch = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for i in range(1, N):
            if xyh[i][2] != ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -  cy):
                break
        else:
            print('{} {} {}'.format(cx, cy, ch))
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    X = xyh[0][0]
    Y = xyh[0][1]
    H = xyh[0][2]
    height = 0
    
    for x in range(0, 101):
        for y in range(0, 101):
            flag = True
            for i in range(1, N):
                if xyh[i][2] != 0:
                    if height == 0:
                        height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                    if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                        flag = False
                        break
                    
            
            if flag:
                X = x
                Y = y
                    
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    X = xyh[0][0]
    Y = xyh[0][1]
    H = xyh[0][2]
    
    for x in range(0, 101):
        for y in range(0, 101):
            flag = True
            for i in range(1, N):
                if xyh[i-1][2] + abs(xyh[i-1][0] - x) + abs(xyh[i-1][1] - y) != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                    flag = False
                    break
            
            if flag == True:
                X = x
                Y = y
                    
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

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 i in range(101):
        for j in range(101):
            H = 0
            for n in range(N):
                if H == 0 and h[n] > 0:
                    H = h[n] + abs(x[n] - i) + abs(y[n] - j)
                elif h[n] != max(H - abs(x[n] - i) - abs(y[n] - j), 0):
                    break
            else:
                print(i,j,H)
                exit()


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 i in range(101):
        for j in range(101):
            flag = True
            for n in range(N):
                if h[n] == 0:
                    continue
                if flag:
                    H = h[n] + abs(x[n] - i) + abs(y[n] - j)
                    flag = False
                else:
                    if H == h[n] + abs(x[n] - i) + abs(y[n] - j):
                        continue
                    else:
                        break
            else:
                for n in range(N):
                    if h[n] == 0:
                        if H != h[n] + abs(x[n] - i) + abs(y[n] - j):
                            break
                else:        
                    print(i,j,H)
                    exit()


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 i in range(101):
        for j in range(101):
            flag = True
            for n in range(N):
                #if h[n] == 0:
                #    continue
                if flag and (h[n] + abs(x[n] - i) + abs(y[n] - j)) >= 0:
                    H = h[n] + abs(x[n] - i) + abs(y[n] - j)
                    flag = False
                else:
                    if (h[n] + abs(x[n] - i) + abs(y[n] - j)) >= 0:
                        if H == h[n] + abs(x[n] - i) + abs(y[n] - j):
                            continue
                        else:
                            break
                    else:
                        continue
            else:
                print(i,j,H)
                exit()


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 i in range(101):
        for j in range(101):
            flag = True
            for n in range(N):
                #if h[n] == 0:
                #    continue
                if flag and (h[n] + abs(x[n] - i) + abs(y[n] - j)) >= 0:
                    H = h[n] + abs(x[n] - i) + abs(y[n] - j)
                    flag = False
                else:
                    if (h[n] + abs(x[n] - i) + abs(y[n] - j)) >= 0 and H == h[n] + abs(x[n] - i) + abs(y[n] - j):
                        continue
                    else:
                        break
            else:
                print(i,j,H)
                exit()


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 i in range(101):
        for j in range(101):
            flag = True
            for n in range(N):
                #if h[n] == 0:
                #    continue
                if flag:
                    H = h[n] + abs(x[n] - i) + abs(y[n] - j)
                    flag = False
                else:
                    if H == h[n] + abs(x[n] - i) + abs(y[n] - j):
                        continue
                    else:
                        break
            else:
                print(i,j,H)
                exit()


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 i in range(101):
        for j in range(101):
            flag = True
            for n in range(N):
                if h[n] == 0:
                    continue
                if flag:
                    H = h[n] + abs(x[n] - i) + abs(y[n] - j)
                    flag = False
                else:
                    if H == h[n] + abs(x[n] - i) + abs(y[n] - j):
                        continue
                    else:
                        break
            else:
                print(i,j,H)
                exit()


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
p = []
    
p=[[int(i)for i in input().split()] for _ in range(n)]
# p.sort(key=lambda x: x[2])
a,b,c=p[-1]
for y in range(101):
    for x in range(101):
        h=c+abs(a-x)+abs(b-y)
        if all(k==max(h-abs(i-x)-abs(y-j),0) for i,j,k in p):
            print(x,y,h)
            exit()

Submission status: Wrong Answer

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

m = 0
mx = 0
my = 0

for cx in range(101):
    for cy in range(101):
        flag = True
        x, y, h = a[0]
        H = max(abs(x-cx) + abs(y-cy) + h, 0)
        for i in range(n):
            xx, yy, hh = a[i]
            if hh != max(H - abs(xx - cx) - abs(yy - cy), 0):
                flag = False

        if flag == True:
            mx = cx
            my = cy
            m = H

print(str(mx) + ' ' + str(my) + ' ' + str(m))

Submission status: Wrong Answer

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

m = 0
mx = 0
my = 0
flag = True
for cx in range(101):
    for cy in range(101):
        flag = True
        x, y, h = a[0]
        H = abs(x-cx) + abs(y-cy) + h
        for i in range(n):
            xx, yy, hh = a[i]
            if hh != max(H - abs(xx - cx) - abs(yy - cy), 0):
                flag = False
                break
        if flag == True:
            mx = cx
            my = cy
            m = H
            break
    if flag == True:
        break

print(str(mx) + ' ' + str(my) + ' ' + str(m))

Submission status: Wrong Answer

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

m = 0
mx = 0
my = 0
for cx in range(101):
    for cy in range(101):
        flag = True
        x, y, h = a[0]
        H = abs(x-cx) + abs(y-cy) + h
        for i in range(n):
            x, y, h = a[i]
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                flag  = False
        if flag == True:
            mx = cx
            my = cy
            m = H

print(str(mx) + ' ' + str(my) + ' ' + str(m))

Submission status: Wrong Answer

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

m = 0
mx = 0
my = 0
for cx in range(101):
    for cy in range(101):
        H = []
        for i in range(n):
            x, y, h = a[i]
            H.append(abs(x-cx) + abs(y-cy) + h)

        if len(set(H)) == 1:
            m = H[0]
            mx = cx
            my = cy

print(str(mx) + ' ' + str(my) + ' ' + str(m))

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[[int(i) for i in input().split()] for j in range(n)]

for i in range(101):
    for j in range(101):
        h=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for k in xyh:
            if h==k[2]+abs(k[0]-i)+abs(k[1]-j):
                continue
            else:
                break
        else:
            print(i,j,h)

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[[int(i) for i in input().split()] for j in range(n)]

for i in range(101):
    for j in range(101):
        h=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for k in xyh:
            if h==k[2]+abs(k[0]-i)+abs(k[1]-j):
                continue
            else:
                break
        else:
            print(i,j,h)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[[int(i) for i in input().split()] for j in range(n)]

for i in range(1,101):
    for j in range(1,101):
        h=xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j)
        for k in xyh:
            if h==k[2]+abs(k[0]-i)+abs(k[1]-j):
                continue
            else:
                break
        else:
            print(i,j,h)
            exit()