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())
get = []
height = []

xa = 0
ya = 0
ha = 0

for ii in range(n):
    get.append(list(map(int,input().split())))

# get[n,0] xn-1 / get[n,1] yn-1 / get[n,2] hn-1
#print(get)


for cx in range(101):
    for cy in range(101):
        for jj in range(len(get)):
            x = get[jj][0]
            y = get[jj][1]
            h = get[jj][2]
            if h != 0:
                height.append(str(h+abs(x-cx)+abs(y-cy)))

        #print(height.count(height[0]))
        #print(len(height))

        
        if height.count(height[0]) == len(height):
            xa = cx
            ya = cy
            ha = height[0]
            #print(xa,ya,ha)
        #print(height)
        height.clear()


print(xa,ya,ha)

Submission status: Wrong Answer

Solution code:
n = int(input())
get = []
height = []

xa = 0
ya = 0
ha = 0

for ii in range(n):
    get.append(list(map(int,input().split())))

# get[n,0] xn-1 / get[n,1] yn-1 / get[n,2] hn-1
#print(get)


for cx in range(101):
    for cy in range(101):
        for jj in range(len(get)):
            x = get[jj][0]
            y = get[jj][1]
            h = get[jj][2]
            height.append(str(h+abs(x-cx)+abs(y-cy)))

        #print(height.count(height[0]))
        #print(len(height))

        
        if height.count(height[0]) == len(height):
            xa = cx
            ya = cy
            ha = height[0]
            #print(xa,ya,ha)
        #print(height)
        height.clear()


print(xa,ya,ha)

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
x, y, h = [], [], []
for _ in range(N):
    xi, yi, hi = s_inpl()
    x.append(xi)
    y.append(yi)
    h.append(hi)

# [0, 100]に座標があるので
MAX = 100;

ans_x, ans_y, ans_h = -1, -1, -1
for pos_y in range(MAX+1):
    for pos_x in range(MAX+1):
        # 頂上がどのくらいの高さであってほしいか
        need_h = -1
        # hが0より大きいときについて考察
        for i in range(N):
            if h[i] > 0:
                # xi, yi, hiからみて，　頂点がpos_x, pos_yのときに
                # どのくらいの高さがあってほしいか求める
                tmp_h = h[i] + abs(pos_y-y[i]) + abs(pos_x-x[i])
                if need_h == -1:
                    need_h = tmp_h
                else:
                    if need_h != tmp_h:
                        need_h = -2
                        break
        # だめだったら別のpos_x, pos_yを探す
        if need_h == -2:
            continue

        # hが1のときについて考察
        # need_hにおいて矛盾が起こらないかを調べる
        for i in range(N):
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - pos_x)
                if need_h > dist:
                    need_h = -2

        if need_h == -2:
            continue
        ans_x, ans_y, ans_h = pos_x, pos_y, need_h

print("{} {} {}".format(ans_x, ans_y, ans_h))

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
x, y, h = [], [], []
for _ in range(N):
    xi, yi, hi = s_inpl()
    x.append(xi)
    y.append(yi)
    h.append(hi)

# [0, 100]に座標があるので
MAX = 100;

for pos_y in range(MAX+1):
    for pos_x in range(MAX+1):
        # 頂上がどのくらいの高さであってほしいか
        need_h = -1
        # hが0より大きいときについて考察
        for i in range(N):
            if h[i] > 0:
                # xi, yi, hiからみて，　頂点がpos_x, pos_yのときに
                # どのくらいの高さがあってほしいか求める
                tmp_h = h[i] + abs(pos_y-y[i]) + abs(pos_x-x[i])
                if need_h == -1:
                    need_h = tmp_h
                else:
                    if need_h != tmp_h:
                        need_h = -2
                        break
        # だめだったら別のpos_x, pos_yを探す
        if need_h == -2:
            continue

        # hが1のときについて考察
        # need_hにおいて矛盾が起こらないかを調べる
        for i in range(N):
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - pos_x)
                if need_h > dist:
                    need_h = -2

        if need_h == -2:
            continue

        break
print("{} {} {}".format(pos_x, pos_y, need_h))

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N = i_inpl()
x, y, h = [], [], []
for _ in range(N):
    xi, yi, hi = s_inpl()
    x.append(xi)
    y.append(yi)
    h.append(hi)

# [0, 100]に座標があるので
MAX = 100;

for pos_y in range(MAX+1):
    for pos_x in range(MAX+1):
        # 頂上がどのくらいの高さであってほしいか
        need_h = -1
        # hが0より大きいときについて考察
        for i in range(N):
            if h[i] > 0:
                # xi, yi, hiからみて，　頂点がpos_x, pos_yのときに
                # どのくらいの高さがあってほしいか求める
                tmp_h = h[i] + abs(pos_y-y[i]) + abs(pos_x-x[i])
                if need_h == -1:
                    need_h = tmp_h
                else:
                    if need_h != tmp_h:
                        need_h = -2
                        break
        # だめだったら別のpos_x, pos_yを探す
        if need_h == -2:
            continue

        # hが1のときについて考察
        # need_hにおいて矛盾が起こらないかを調べる
        for i in range(N):
            if h[i] == 0:
                dist = abs(pos_y - y[i]) + abs(pos_x - pos_x)
                if need_h > dist:
                    need_h = -2

        if need_h == -2:
            continue

        print("{} {} {}".format(pos_x, pos_y, need_h))

Submission status: Wrong Answer

Solution code:
N=int(input())

xyh=[]
for i in range(N):
    xi,yi,hi=map(int,input().split())
    xyh.append([xi,yi,hi])
xyh.sort(reverse=True,key=lambda x:x[2])
for Cx in range(0,101):
    for Cy in range(0,101):
        for i in range(N):
            X=xyh[i][0]
            Y=xyh[i][1]
            h=xyh[i][2]
            if i==0:
                H=h+abs(X-Cx)+abs(Y-Cy)
                continue
            H_=h+abs(X-Cx)+abs(Y-Cy)
            if H!=H_:
                break
            if i==N-1:
                print(Cx,Cy,H)
                quit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
#       q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        for k in range(1,N):
            if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
            elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<p : break
            if k==N-1:
                print(i,j,p)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
#       q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        for k in range(1,N):
            if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
            elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<=p : break
            if k==N-1:
                print(i,j,p)
                sys.exit()
            if p==100 and k==N-1:
                print(i,j,p)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if p==q:
            for k in range(2,N):
                if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
                elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<=p : break
                if k==N-1:
                    print(i,j,p)
                    sys.exit()
                if p==100 and k==N-1:
                    print(i,j,p)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if p==q:
            for k in range(2,N):
                if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
                elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])>p : break
                if k==N-1:
                    print(i,j,p)
                    sys.exit()
                if p==100 and k==N-1:
                    print(i,j,p)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[1][2]==0 or a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if p==q:
            for k in range(2,N):
                if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
                elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<=p : break
                if k==N-1:
                    print(i,j,p)
                    sys.exit()
                if p==100 and k==N-1:
                    print(i,j,p)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[1][2]==[0] or a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if p==q:
            for k in range(2,N):
                if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
                elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<=p : break
                if k==N-1:
                    print(i,j,p)
                    sys.exit()
                if p==100 and k==N-1:
                    print(i,j,p)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
def checkheight(H, data, coordinate):
    cx, cy = coordinate

    for px, py, ph in data:
        if not ph + abs(px - cx) +  abs(py - cy) == H:
            return None

    return (cx, cy, H)

def makeheight(data, cx, cy):
    px, py, ph = list(filter(lambda dataset: dataset[2] > 0, data))[0]
    return ph + abs(px - cx) + abs(py - cy)


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

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


    for cx in range(101):
        for cy in range(101):
            tmpch = makeheight(data.copy(), cx, cy)

            res = checkheight(tmpch, data, (cx, cy))

            if res:
                print(*res)
                return



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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())

ansx = 0
ansy = 0
ansh = 0

for k in range(n):
    for i in range(101):
        for j in range(101):
            hcand = abs(i - x[k]) + abs(j - y[k]) + h[k]
            for l in range(n):
                if l == k: continue
                if hcand - abs(i - x[l]) - abs(j -y[l]) != h[l]:
                    break
            else:
                ansh = hcand
                ansx = i
                ansy = j

print(ansx,ansy,ansh)

Submission status: Wrong Answer

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

# x=i, y=jでは条件を満たすか?
for i in range(101):
    for j in range(101):
        # k番目のデータで"頂点の高さ"を計算
        for k in range(N):
            hAns[k] = H[k]+abs(X[k]-i)+abs(Y[k]-j)
        # 入力データが同じ答えを出したら,その座標と高さが答えになる
        # H[l]==0のときのみ、違う値になっているかもしれない
        for l in range(N):
            if H[l] == 0:
                H[l] = min(H)
        if all(hAns[c]==hAns[c+1] for c in range(len(hAns)-1)):
            print(i,j,hAns[0])
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
X,Y,H = [],[],[]
for i in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        X.append(x)
        Y.append(y)
        H.append(h)
hAns = [0]*(len(X))

# x=i, y=jでは条件を満たすか?
for i in range(101):
    for j in range(101):
        # k番目のデータで"頂点の高さ"を計算
        for k in range(len(X)):
            hAns[k] = max( H[k]+abs(X[k]-i)+abs(Y[k]-j), 0 )
        # 入力データが同じ答えを出したら,その座標と高さが答えになる
        if all(hAns[c]==hAns[c+1] for c in range(len(X)-1)):
            print(i,j,hAns[0])
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
X,Y,H = [],[],[]
for i in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        X.append(x)
        Y.append(y)
        H.append(h)
hAns = [0]*(N)

# x=i, y=jでは条件を満たすか?
for i in range(101):
    for j in range(101):
        # k番目のデータで"頂点の高さ"を計算
        for k in range(len(X)):
            hAns[k] = max( H[k]+abs(X[k]-i)+abs(Y[k]-j), 0 )
        # 入力データが同じ答えを出したら,その座標と高さが答えになる
        if all(hAns[c]==hAns[c+1] for c in range(len(X)-1)):
            print(i,j,hAns[0])
            break

Submission status: Wrong Answer

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

# x=i, y=jでは条件を満たすか?
for i in range(101):
    for j in range(101):
        # k番目のデータで"頂点の高さ"を計算
        for k in range(N):
            hAns[k] = max( H[k]+abs(X[k]-i)+abs(Y[k]-j), 0 )
        # 入力データが同じ答えを出したら,その座標と高さが答えになる
        if all(hAns[c]==hAns[c+1] for c in range(N-1)):
            print(i,j,hAns[0])
            break

Submission status: Wrong Answer

Solution code:
def checkheight(H, data, coordinate):
    cx, cy = coordinate

    for px, py, ph in data:
        if not ph + abs(px - cx) +  abs(py - cy) == H:
            return None

    return (cx, cy, H)


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

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


    for cx in range(101):
        for cy in range(101):
            px, py, ph = data[0]
            tmpch = ph + abs(px - cx) + abs(py - cy)

            res = checkheight(tmpch, data, (cx, cy))

            if res:
                print(*res)
                return



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def checkheight(H, data, coordinate):
    cx, cy = coordinate

    if data:
        for px, py, ph in data:
            if not ph + abs(px - cx) +  abs(py - cy) == H:
                return None
        else:
            return (cx, cy, H)


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

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


    for cx in range(101):
        for cy in range(101):
            px, py, ph = data[0]
            tmpch = ph + abs(px - cx) + abs(py - cy)

            res = checkheight(tmpch, data, (cx, cy))

            if res:
                print(*res)
                return



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def checkheight(H, data, coordinate):
    cx, cy = coordinate

    if data:
        for px, py, ph in data[1:]:
            if not ph == H - abs(px - cx) - abs(py - cy):
                return None
        else:
            return (cx, cy, H)


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

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


    for cx in range(101):
        for cy in range(101):
            px, py, ph = data[0]
            tmpch = ph + abs(px - cx) + abs(py - cy)

            res = checkheight(tmpch, data, (cx, cy))

            if res:
                print(*res)
                return



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def height(cx, cy):
    res = set()
    for p in points:
        if p[2] == 0:
            continue
        h = p[2] + abs(p[0] - cx) + abs(p[1] - cy)
        res.add(h)
    return list(res)

def find():
    for x in range(101):
        for y in range(101):
            hs = height(x, y)
            if len(hs) == 1:
                return [str(x), str(y), str(hs[0])]
    raise Exception()

print(' '.join(find()))

Submission status: Wrong Answer

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

def height(cx, cy):
    res = set()
    for p in points:
        if p[2] == 0:
            continue
        h = p[2] + abs(p[0] - cx) + abs(p[1] - cy)
        res.add(h)
    return list(res)

CX = 0
CY = 0
H = 0
for x in range(101):
    for y in range(101):
        hs = height(x, y)
        if len(hs) == 1:
            CX = x
            CY = y
            H = hs[0]
            break

print(' '.join([str(CX), str(CY), str(H)]))

Submission status: Wrong Answer

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

def height(cx, cy):
    res = 0
    for p in points:
        if p[2] == 0:
            continue
        h = p[2] + abs(p[0] - cx) + abs(p[1] - cy)
        if res > 0 and res != h:
            return 0
        res = h
    return res

CX = 0
CY = 0
H = 0
for x in range(101):
    for y in range(101):
        h = height(x, y)
        if h > 0:
            CX = x
            CY = y
            H = h
            break

print(' '.join([str(CX), str(CY), str(H)]))

Submission status: Wrong Answer

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

def height(cx, cy):
    res = 0
    for p in points:
        d = abs(p[0] - cx) + abs(p[1] - cy)
        if p[2] == 0:
            if res > d:
                return 0
        else:
            if res > 0 and res != p[2] + d:
                return 0
            res = p[2] + d
    return res

CX = 0
CY = 0
H = 0
for x in range(101):
    for y in range(101):
        h = height(x, y)
        if h > 0:
            CX = x
            CY = y
            H = h
            break

print(' '.join([str(CX), str(CY), str(H)]))

Submission status: Wrong Answer

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

def height(cx, cy):
    res = 0
    for p in points:
        d = abs(p[0] - cx) + abs(p[1] - cy)
        if p[2] == 0:
            if res > d:
                return 0
        else:
            if res > 0 and res != p[2] + d:
                return 0
            res = p[2] + d
    return res

CX = 0
CY = 0
H = 0
for x in range(101):
    for y in range(101):
        h = height(x, y)
        if h > 0:
            CX = x
            CY = y
            H = h
            break

print(' '.join([str(CX), str(CX), str(H)]))

Submission status: Wrong Answer

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

def height(cx, cy):
    res = 0
    for p in points:
        d = abs(p[0] - cx) + abs(p[1] - cy)
        if p[2] == 0:
            if res > d:
                return 0
        else:
            if res > 0 and res != p[2] + d:
                return 0
            res = p[2] + d
    return res

cx = 0
cy = 0
H = 0
for x in range(101):
    for y in range(101):
        h = height(x, y)
        if h > 0:
            cx = x
            cy = y
            H = h
            break

print(' '.join([str(cx), str(cy), str(H)]))

Submission status: Wrong Answer

Solution code:
from sys import exit
n=int(input())
pyramid=[]
for i in range(n):
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
flag=0
for i in range(n):
  if flag==0 and pyramid[i][2]!=0:
    flag=-1
  elif flag==-1 and pyramid[i][2]!=0:
    flag=1
if flag==-1:
  for i in range(n):
    if pyramid[i][2]!=0:
      print(pyramid[i][0],pyramid[i][1],pyramid[i][2])
      exit()
ans=[[0 for i in range(101)] for i in range(101)]
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Submission status: Wrong Answer

Solution code:
from sys import exit
n=int(input())
pyramid=[]
for i in range(n):
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
flag=0
for i in range(n):
  if flag==0 and pyramid[i][2]!=0:
    flag=-1
  elif flag==-1 and pyramid[i][2]!=0:
    flag=1
if flag==-1:
  for i in range(n):
    if pyramid[i][2]!=0:
      print(pyramid[i][0],pyramid[i][1],pyramid[i][2])
  exit()
ans=[[0 for i in range(101)] for i in range(101)]
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Submission status: Wrong Answer

Solution code:
from sys import exit
n=int(input())
pyramid=[]
for i in range(n):
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
flag=0
for i in range(n):
  if flag==0 and pyramid[i][2]!=0:
    flag=-1
  elif flag==-1 and pyramid[i][2]!=0:
    flag=1
if flag==-1:
  for i in range(n):
    if pyramid[i][2]!=0:
      print(pyramid[i][0],pyramid[i][1],pyramid[i][2])
ans=[[0 for i in range(101)] for i in range(101)]
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Submission status: Wrong Answer

Solution code:
from sys import exit
n=int(input())
pyramid=[]
if n==1:
  x,y,h=map(int,input().split())
  print(x,y,h)
  exit()
else:
  for i in range(n):
    x,y,h=map(int,input().split())
    pyramid.append([x,y,h])
ans=[[0 for i in range(101)] for i in range(101)]
flag=1
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Submission status: Wrong Answer

Solution code:
n=int(input())
pyramid=[]
for i in range(n):
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
ans=[[0 for i in range(101)] for i in range(101)]
flag=1
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Submission status: Wrong Answer

Solution code:
n=int(input())
pyramid=[]
for i in range(n):
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
ans=[[0 for i in range(101)] for i in range(101)]
flag=1
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(ans[i][j])

Submission status: Wrong Answer

Solution code:
N = int(input())
infos = [0 for i in range(N)]

for i in range(N):
    infos[i] = [int(j) for j in input().split()]

for i in range(101):
    for j in range(101):
        s = []
        for info in infos:
            x,y,h = info
            if h == 0:
                continue
            H = h + abs(x-i) + abs(y-j)
            s.append(H)
            if len(set(s)) == 2:
                break
        else:
            print(i,j,H)
            exit()

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx in range(101):
  for cy in range(101):
    hhh = []
    for i in xyh:
      xi, yi, hi = i[0], i[1], i[2]
      if hi == 0:
          break
      h = hi + abs(xi-cx) + abs(yi-cy)
      hhh.append(h)
    if len(set(hhh)) == 1:
      print(cx, cy, h)
      break

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx in range(101):
  for cy in range(101):
    hhh = []
    for i in xyh:
      xi, yi, hi = i[0], i[1], i[2]
      if hi == 0:
        if (hi-abs(xi-cx)-abs(yi-cy))<=0:
          continue
        else:
          break
      h = hi + abs(xi-cx) + abs(yi-cy)
      hhh.append(h)
    if len(set(hhh)) == 1:
      print(cx, cy, h)
      break

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi == 0:
      if (hi-abs(xi-cx)-abs(yi-cy))<=0:
        continue
      else:
        hhh.append(-i)
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    print(cx, cy, h)
    break

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi == 0:
      if (hi-abs(xi-cx)-abs(yi-cy))<=0:
        continue
      else:
        hhh.append(0)
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    print(cx, cy, h)
    break