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

#
#すべての条件についてある入力からhを求める
#そのhについて、その他の条件をすべて満たせればOK
ans_x, ans_y, ans_h = -1,-1,-1
indexes = [i for i, x in enumerate(xyh) if x[2] > 0]

for cx in range(101):
    for cy in range(101):
        H = xyh[indexes[-1]][2] + abs(xyh[indexes[-1]][0] - cx) + abs(xyh[indexes[-1]][1] - cy)
        match = 1
        for i in range(N):
            h = H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy)
            if xyh[i][2] > 0 and (h != xyh[i][2]):
                match = 0
            if xyh[i][2] == 0 and (h > (abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)) ):
                match = 0
        
        if match:
            ans_x = cx
            ans_y = cy
            ans_h = H
            
print(str(ans_x) + ' ' + str(ans_y) + ' ' + str(ans_h))

Submission status: Wrong Answer

Solution code:

N = int(input())

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

#
#すべての条件についてある入力からhを求める
#そのhについて、その他の条件をすべて満たせればOK
ans_x, ans_y, ans_h = -1,-1,-1
for cx in range(101):
    for cy in range(101):
        H = xyh[-1][2] + abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)
        match = 1
        for i in range(N):
            h = H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy)
            if xyh[i][2] > 0 and (h != xyh[i][2]):
                match = 0
            if xyh[i][2] == 0 and (h > (abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)) ):
                match = 0
        
        if match:
            ans_x = cx
            ans_y = cy
            ans_h = H
            
print(str(ans_x) + ' ' + str(ans_y) + ' ' + str(ans_h))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

#
#すべての条件についてある入力からhを求める
#そのhについて、その他の条件をすべて満たせればOK
ans_x, ans_y, ans_h = -1,-1,-1
for cx in range(101):
    for cy in range(101):
        H = xyh[-1][2] + abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)
        match = 1
        for i in range(N):
            h = H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy)
            if xyh[i][2] > 0 and (h != xyh[i][2]):
                match = 0
            if xyh[i][2] == 0 and (h > 0):
                match = 0
        
        if match:
            ans_x = cx
            ans_y = cy
            ans_h = H
            
print(str(ans_x) + ' ' + str(ans_y) + ' ' + str(ans_h))

Submission status: Wrong Answer

Solution code:


N = int(input())

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

#
#すべての条件についてある入力からhを求める
#そのhについて、その他の条件をすべて満たせればOK
ans_x, ans_y, ans_h = -1,-1,-1
for cx in range(101):
    for cy in range(101):
        H = xyh[-1][2] + abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)
        match = 1
        for i in range(N):
            h = H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy)
            if xyh[i][2] > 0 and (h != xyh[i][2]):
                match = 0
        
        if match:
            ans_x = cx
            ans_y = cy
            ans_h = H
            
print(str(ans_x) + ' ' + str(ans_y) + ' ' + str(ans_h))

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    pos = [f() for i in range(n)]

    notz = 0
    for i in range(n):
        if pos[i][2]!=0:
            notz = i
            break


    for i in range(101):
        for j in range(101):
            d1 = abs(pos[notz][0] - i) + abs(pos[notz][1] - j)
            h = d1 + pos[notz][2]

            ok = True
            for k in range(1, n):
                if max(0,h - abs(pos[k][0] - i) - abs(pos[k][1] - j)) != pos[k][2]:
                    ok = False
                    break

            if ok:
                print(i,j,h)
                return




solve()

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

    pos = [f() for i in range(n)]

    for i in range(101):
        for j in range(101):
            d1 = abs(pos[0][0] - i) + abs(pos[0][1] - j)
            h = d1 + pos[0][2]

            ok = True
            for k in range(1, n):
                if max(0,h - abs(pos[k][0] - i) - abs(pos[k][1] - j)) != pos[k][2]:
                    ok = False
                    break

            if ok:
                print(i,j,h)
                return




solve()

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 += [X]
    y += [Y]
    h += [H]
a = 0
while h[a] == 0:
    a += 1 
    if a == N:
        for i in range(101):
            if i not in x:  X = i
        for i in range(101):
            if i not in y:  Y = i
        while True:
            continue
        exit()

for cx in range(101):
    for cy in range(101):
        H = h[a] + abs(x[a]-cx) + abs(y[a]-cy)
        ans = True
        R = list(range(N))[1:a] + list(range(N))[a+1:N]
        for i in R:
            if h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy),0):
                ans = False
                break
        if ans:
            print(cx,cy,H)
            break
    else:
        continue
    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 += [X]
    y += [Y]
    h += [H]
a = 0
while h[a] == 0:
    a += 1 
    if a == N:
        for i in range(101):
            if i not in x:  X = i
        for i in range(101):
            if i not in y:  Y = i
        print(X,Y,1)
        exit()

for cx in range(101):
    for cy in range(101):
        H = h[a] + abs(x[a]-cx) + abs(y[a]-cy)
        ans = True
        R = list(range(N))[1:a] + list(range(N))[a+1:N]
        for i in R:
            if h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy),0):
                ans = False
                break
        if ans:
            print(cx,cy,H)
            break
    else:
        continue
    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 += [X]
    y += [Y]
    h += [H]

for cx in range(101):
    for cy in range(101):
        H = h[0] + abs(x[0]-cx) + abs(y[0]-cy)
        ans = True
        for i in range(1,N):
            if h[i] != max(H - abs(x[i]-cx) - abs(y[i]-cy),0):
                ans = False
                break
        if ans:
            print(cx,cy,H)
            break
    else:
        continue
    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 += [X]
    y += [Y]
    h += [H]

for cx in range(101):
    for cy in range(101):
        H = h[0] + abs(x[0]-cx) + abs(y[0]-cy)
        ans = True
        for i in range(1,N):
            if h[i] != H - abs(x[i]-cx) - abs(y[i]-cy):
                ans = False
                break
        if ans:
            print(cx,cy,H)
            break
    else:
        continue
    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 += [X]
    y += [Y]
    h += [H]

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

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
info = []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    info.append((xi, yi, hi))   

answer = (-1, -1, -1)
for cx in range(101):
    for cy in range(101):
        candidate = -1
        counter = 0
        for i in info:
            if i[2] != 0:
                H = i[2] + abs(i[0] - cx) + abs(i[1] - cy)
                counter += 1
                if candidate == -1:
                    candidate = H
                elif candidate != H:
                    candidate = -1
                    break
        if counter == 1:
            for i in info:
                if i[2] == H:
                    answer = (i[0], i[1], i[2])
            break        
        elif candidate > 0:
            answer = (cx, cy, candidate)
            break
    if answer[2] > 0:
        break


print(answer[0], answer[1], answer[2])

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
info = []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    info.append((xi, yi, hi))
    if hi == 1000000000:
        print(xi, yi, hi)
        sys.exit()        

answer = (-1, -1, -1)
for cx in range(101):
    for cy in range(101):
        candidate = -1
        for i in info:
            if i[2] != 0:
                H = i[2] + abs(i[0] - cx) + abs(i[1] - cy)
                if candidate == -1:
                    candidate = H
                elif candidate != H:
                    candidate = -1
                    break
        if candidate > 0:
            answer = (cx, cy, candidate)
            break
    if answer[2] > 0:
        break
print(answer[0], answer[1], answer[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    info.append((xi, yi, hi))

# hi = H - abs(xi - Cx) - abs(yi - Cy)
# H = hi + abs(xi - Cx) + abs(yi - Cy)

answer = (-1, -1, -1)
for cx in range(101):
    for cy in range(101):
        candidate = -1
        for i in info:
            if i[2] != 0:
                H = i[2] + abs(i[0] - cx) + abs(i[1] - cy)
                if candidate == -1:
                    candidate = H
                elif candidate != H:
                    candidate = -1
                    break
        if candidate > 0:
            answer = (cx, cy, candidate)
            #break
    #if answer[2] > 0:
    #    break
print(answer[0], answer[1], answer[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    info.append((xi, yi, hi))

# hi = H - abs(xi - Cx) - abs(yi - Cy)
# H = hi + abs(xi - Cx) + abs(yi - Cy)

answer = (-1, -1, -1)
for cx in range(101):
    for cy in range(101):
        candidate = -1
        for i in info:
            if i[2] != 0:
                H = i[2] + abs(i[0] - cx) + abs(i[1] - cy)
                if candidate == -1:
                    candidate = H
                elif candidate != H:
                    candidate = -1
                    break
        if candidate > 0:
            answer = (cx, cy, candidate)
            break
    if answer[0] > 0:
        break
if answer == (-1, -1, -1):
    raise Exception()
else:
    print(answer[0], answer[1], answer[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    info.append((xi, yi, hi))

# hi = H - abs(xi - Cx) - abs(yi - Cy)
# H = hi + abs(xi - Cx) + abs(yi - Cy)

answer = (-1, -1, -1)
for cx in range(101):
    for cy in range(101):
        candidate = -1
        for i in sorted(info, key=lambda x: x[2], reverse=True):
            if i[2] != 0:
                H = i[2] + abs(i[0] - cx) + abs(i[1] - cy)
                if candidate == -1:
                    candidate = H
                elif candidate != H:
                    candidate = -1
                    break
            else:
                if H - abs(i[0] - cx) + abs(i[1] - cy) > 0:
                    candidate = -1
                    break
        if candidate > 0:
            answer = (cx, cy, candidate)
            break
    if answer[0] > 0:
        break
print(answer[0], answer[1], answer[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    info.append((xi, yi, hi))

# hi = H - abs(xi - Cx) - abs(yi - Cy)

answer = (-1, -1, -1)
for cx in range(101):
    for cy in range(101):
        top = True
        candidate = -1
        for i in info:
            if i[2] != 0:
                H = i[2] + abs(i[0] - cx) + abs(i[1] - cy)
                if candidate == -1:
                    candidate = H
                elif candidate != H:
                    candidate = -1
                    break
        if candidate > 0:
            answer = (cx, cy, candidate)
            break
    if answer[0] > 0:
        break
print(answer[0], answer[1], answer[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh.sort(key=lambda x: -x[2])

for cx in range(101):
    for cy in range(101):
        ch = None
        for x, y, h in xyh:
            t = h + abs(cx - x) + abs(cy - y)
            if h > 0:
                if ch is not None and t != ch:
                    break
                ch = t
            else:
                break
        else:
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

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

X.sort(key=lambda x: x[2])
a, b, c = X[-1]

for px in C_x:
  for py in C_y:
    h_0 = abs(a - px) + abs(b - py) + c
    if all(h_0 == max(abs(x - px) + abs(y - py) + h, 0) for x, y, h in X):
      print(px, py, h_0)
      break

Submission status: Wrong Answer

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

X.sort(key=lambda x: x[2])
a, b, c = X[-1]

for px in C_x:
  for py in C_y:
    h_0 = abs(a - px) + abs(b - py) + c
    if all(h_0 == abs(x - px) + abs(y - py) + h for x, y, h in X):
      print(px, py, h_0)
      break

Submission status: Wrong Answer

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

for px in C_x:
    for py in C_y:
        h_list = [abs(x - px) + abs(y - py) + h if h > 0 else 0 for x, y, h in X]
        h_set = set(h_list)
        if 0 in h_set:
            h_set.remove(0)
        if len(h_set) == 1:
            print(px, py, h_set.pop())
            break

Submission status: Wrong Answer

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

for px in C_x:
    for py in C_y:
        h_list = [abs(x - px) + abs(y - py) + h for x, y, h in X]
        if len(set(h_list)) == 1:
            print(px, py, h_list[0])
            break

Submission status: Wrong Answer

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


def solve(N: int, X: "List[int]", Y: "List[int]", H: "List[int]"):

    for cx in range(0,101):
        for cy in range(0,101):
            ch = -1
            bOK = True
            for x,y,h in zip(X,Y,H):
                nh = h + abs(cx-x) + abs(cy-y)

                if h == 0:
                    if ch != -1 and ch > nh:
                        bOK = False
                        break

                    continue

                if ch == -1:
                    ch = nh
                    continue
                elif ch != nh:
                    bOK = False
                    break

            if bOK and ch > 0:
                print(cx,cy,ch)





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, X: "List[int]", Y: "List[int]", H: "List[int]"):

    for cx in range(0,101):
        for cy in range(0,101):
            ch = -1
            bOK = True
            for x,y,h in zip(X,Y,H):
                if h == 0:
                    continue
                nh = h + abs(cx-x) + abs(cy-y)

                if ch == -1:
                    ch = nh
                    continue
                elif ch != nh:
                    bOK = False
                    break

            if bOK and ch > 0:
                print(cx,cy,ch)





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, X: "List[int]", Y: "List[int]", H: "List[int]"):

    for cx in range(0,101):
        for cy in range(0,101):
            ch = -1
            bOK = True
            for x,y,h in zip(X,Y,H):
                if h == 0:
                    continue
                nh = h + abs(cx-x) + abs(cy-y)

                if ch == -1:
                    ch = nh
                    continue
                elif ch != nh:
                    bOK = False
                    break

            if bOK:
                print(cx,cy,ch)





# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())
Ct = [i for i in range(101)]
Cli = list(product(Ct,Ct))
XY = []
sx,sy,sh = 0,0,0
for i in range(n):
    x,y,h = map(int,input().split())
    XY.append([x,y,h])
    if h != 0: sx,sy,sh = x,y,h
for (cx,cy) in Cli:
    #cx,cyが候補。XYが実測値のリスト
    ht = sh + abs(sx-cx) + abs(sy-cy)
#    print(cx,cy,"ht=",ht)
    for i in XY:
        if i[2] == 0: continue
        ht2 = i[2]+abs(i[0]-cx)+abs(i[1]-cy)
#        print(i[0],i[1],i[2],"ht2=",ht2,"と比較中")
        if max(ht2, 0) != ht: break
    else:
        print(cx, cy, ht)
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
hints = [tuple(map(int, input().split())) for _ in range(N)]
Hs = dict()
for i in range(0, 101):
  for j in range(0, 101):
    Hs = [h+abs(x-i)+abs(y-j) for x, y, h in hints if h!=0]
    if len(set(Hs))==1:
      print(i, j, Hs[0])

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())
Ct = [i for i in range(101)]
Cli = list(product(Ct,Ct))
XY = []
sx,sy,sh = 0,0,0
for i in range(n):
    x,y,h = map(int,input().split())
    XY.append([x,y,h])
    if h != 0: sx,sy,sh = x,y,h
for (cx,cy) in Cli:
    #cx,cyが候補。XYが実測値のリスト
    ht = sh + abs(sx-cx) + abs(sy-cy)
    for i in XY:
        ht2 = i[2]+abs(i[0]-cx)+abs(i[1]-cy)
        if max(ht2, 0) != ht: break
    else:
        print(cx, cy, ht)
        break

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())
Ct = [i for i in range(101)]
Cli = list(product(Ct,Ct))
XY = []
al = False
for i in range(n):
    x,y,h = map(int,input().split())
    if h == 0:
        if al: break
        else: al = True
    XY.append([x,y,h])
suc = False
rex, rey, ret= -1,-1,-1
for (cx,cy) in Cli:
    #cx,cyが候補。XYが実測値のリスト
    ht = XY[0][2] + abs(XY[0][0]-cx) + abs(XY[0][1]-cy)
    for i in range(1,len(XY)):
        cxy = XY[i]
        ht2 = cxy[2]+abs(cxy[0]-cx)+abs(cxy[1]-cy)
        if ht != ht2: break
        if i == len(XY)-1:
            suc = True
            rex,rey,ret = cx,cy,ht
    if suc: break
print(rex, rey, ret)

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())
Ct = [i for i in range(101)]
Cli = list(product(Ct,Ct))
XY = []
for i in range(n):
    x,y,h = map(int,input().split())
    if h == 0: continue
    XY.append([x,y,h])
suc = False
rex, rey, ret= -1,-1,-1
for (cx,cy) in Cli:
    #cx,cyが候補。XYが実測値のリスト
    ht = XY[0][2] + abs(XY[0][0]-cx) + abs(XY[0][1]-cy)
    for i in range(1,len(XY)):
        cxy = XY[i]
        ht2 = cxy[2]+abs(cxy[0]-cx)+abs(cxy[1]-cy)
        if ht != ht2: break
        if i == len(XY)-1:
            suc = True
            rex,rey,ret = cx,cy,ht
    if suc: break
print(rex, rey, ret)

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())
Ct = [i for i in range(101)]
Cli = list(product(Ct,Ct))
XY = []
for i in range(n):
    x,y,h = map(int,input().split())
    if h == 0: continue
    XY.append([x,y,h])
suc = False
rex, rey, ret= -1,-1,-1
for (cx,cy) in Cli:
    #cx,cyが候補。XYが実測値のリスト
    ht = XY[0][2] + abs(XY[0][0]-cx) + abs(XY[0][1]-cy)
    for i in range(1,len(XY)):
        cxy = XY[i]
        ht2 = cxy[2]+abs(cxy[0]-cx)+abs(cxy[1]-cy)
        if ht != ht2: break
        if i == len(XY[1:]):
            suc = True
            rex,rey,ret = cx,cy,ht
    if suc: break
print(rex, rey, ret)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
N=int(stdin.readline().rstrip())
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
h_log=0
cnt=1
for X in range(0,101):
    for Y in range(0,101):
        for data_ in data:
            if data_[2] == 0:
                cnt+=1
                continue
            H = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            if H == h_log:
                cnt+=1
            h_log = H
            
        if cnt == N:
            break
        
        cnt=1
    else:
        continue
    break
    
print(X,Y,H)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
N=int(stdin.readline().rstrip())
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
 
cnt=0
for X in range(0,101):
    for Y in range(0,101):
        for ind,data_ in enumerate(data):
            if ind == 0:
                h_log = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            H = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            if H == h_log:
                cnt+=1
            h_log = H
        if cnt == N:
            print(X,Y,H)
            sys.exit()
        cnt=0

Submission status: Wrong Answer

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


def solve(N: int, X: "List[int]", Y: "List[int]", H: "List[int]"):

    maxh = max(H) + 200
    minh = max(0,maxh-200)
    for cx in range(0,101):
        for cy in range(0,101):
            hc = -1
            bOK = True
            for x,y,h in zip(X,Y,H):
                if h > 0:
                    hcc = abs(x-cx)+abs(y-cy)+h
                    if hc > 0 and hc != hcc:
                        bOK = False
                        break
                    else:
                        hc = hcc

            if bOK:
                print(cx,cy,hc)


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for _ in range(n):
    _x, _y, _h = map(int, input().split())
    x.append(_x)
    y.append(_y)
    h.append(_h)

avg_x = int(sum(x)/n)
avg_y = int(sum(y)/n)
H = h[0] + abs(x[0]-avg_x) +abs(y[0]-avg_y)
print(avg_x, avg_y, H)

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

for i in range(0,101):
    for j in range(0,101):
        n = 0
        tmph = h[n] + abs(i-x[n]) + abs(j-y[n])
        count = 0
        for n in range(N):
            count += 1
            if h[n] != max(tmph - abs(i-x[n]) - abs(j-y[n]), 0):
                break
            if count == N:
                print(str(i) + ' ' + str(j) + ' ' + str(tmph))

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for x in zero_height:
                if H > abs(x[0] - i) + abs(x[1] - j):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for x in zero_height:
                if H > abs(x[0] - i) - abs(x[1] - j):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for k in zero_height:
                if H > abs(k[0] - i) - abs(k[1] - j):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for k in zero_height:
                if max(H - abs(k[0] - i) - abs(k[1] - j), 0):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()