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)]
if n==1:
    print(*xyh[0])
    exit()
for i in range(101):
    for j in range(101):
        a = -1
        ok = True
        for x,y,h in xyh:
            if h>0:
                if a==-1:
                    a = h+abs(x-i)+abs(y-j)
                elif h+abs(x-i)+abs(y-j)!=a:
                    ok = False
        if ok:
            print(i,j,a)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        a = -1
        ok = True
        for x,y,h in xyh:
            if h>0:
                if a==-1:
                    a = h+abs(x-i)+abs(y-j)
                elif h+abs(x-i)+abs(y-j)!=a:
                    ok = False
        if ok:
            print(i,j,a)
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        x,y,h = xyh[0]
        a = h+abs(x-i)+abs(y-j)
        ok = True
        for x,y,h in xyh[1:]:
            if h+abs(x-i)+abs(y-j)!=a:
                ok = False
        if ok:
            print(i,j,a)
            exit()
print(-1)

Submission status: Wrong Answer

Solution code:
from itertools import product
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(list(map(int, input().split())))
    for a in A:
        if a[2] != 0:
            t = a
            break
    for x, y in product(range(0, 101), repeat = 2):
        H = t[2] + abs(t[0] - x) + abs(t[1] - y)
        for a in A:
            if a[2] == 0:
                continue
            elif a[2] != 0 and a[2] == H - abs(a[0] - x) - abs(a[1] - y):
                continue
            elif a[2] != H - abs(a[0] - x) - abs(a[1] - y):
                break
        else:
            ansx, ansy = x, y
            break
    H = t[2] + abs(t[0] - ansx) + abs(t[1] - ansy)
    print('{} {} {}'.format(ansx, ansy, H))



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        high = sh + abs(sx - i) + abs(sy - j)
        judge = True
        for x, y, h in lis:
            if h > 0 and high != h + abs(x - i) + abs(y - j):
                judge = False
                break
            elif high > abs(x - i) + abs(y - j):
                judge = False
                break
        if judge:
            print(i, j, sh + abs(sx - i) + abs(sy - j))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        high = sh + abs(sx - i) + abs(sy - j)
        judge = True
        for x, y, h in lis:
            if h > 0 and high != h + abs(x - i) + abs(y - i):
                judge = False
                break
            elif h == 0 and high > abs(x - i) + abs(y - j):
                judge = False
                break
        if judge:
            print(i, j, sh + abs(sx - i) + abs(sy - j))
            exit()

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], reverse=True)

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


for cx in range(101):
    for cy in range(101):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0 and h > 0:
                ch = esth(x, y, h, cx, cy)
            else:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        count = 0
        for x, y, h in lis:
            judge = True
            if h > 0 and sh + abs(sx - i) + abs(sy - j) != h + abs(x - i) + abs(y - i):
                break
            elif sh +  abs(sx - i) + abs(sy - j) > h + abs(x - i) + abs(y - j):
                break
            else:
                count += 1
        if count == len(lis):
            print(i, j, sh + abs(sx - i) + abs(sy - j))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        for x, y, h in lis:
            judge = True
            if h > 0 and sh + abs(sx - i) + abs(sy - j) != h + abs(x - i) + abs(y - i):
                break
            elif sh +  abs(sx - i) + abs(sy - j) > h + abs(x - i) + abs(y - j):
                break
        else:
            print(i, j, sh + abs(sx - i) + abs(sy - j))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        
        for x, y, h in lis:
            judge = True
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
           
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > h +abs(cx - x) + abs(cx - y):
              
                break
        else:
            print(cx, cy, sh + abs(sx - cx) + abs(sy - cy))
            
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        
        for x, y, h in lis:
            judge = True
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
                judge = False
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > h +abs(cx - x) + abs(cx - y):
                judge = False
                break
        if judge:
            print(cx, cy, sh + abs(sx - cx) + abs(sy - cy))
            
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        judge = True
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
                judge = False
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > h +abs(cx - x) + abs(cx - y):
                judge = False
                break
        if judge:
            print(cx, cy, sh + abs(sx - cx) + abs(sy - cy))
            
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        sx, sy, sh = x, y, h
    lis.append([x, y, h])
for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        judge = True
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
                judge = False
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > h +abs(cx - x) + abs(cx - y):
                judge = False
                break
        if judge:
            print(cx, cy, sh + abs(sx - cx) + abs(sy - cy))
            
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        lis.append([x, y, h])
        sx, sy, sh = x, y, h

for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        judge = True
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
                judge = False
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > h +abs(cx - x) + abs(cx - y):
                judge = False
                break
        else:
            print(cx, cy, sh + abs(sx - cx) + abs(sy - cy))
            
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        lis.append([x, y, h])
        sx, sy, sh = x, y, h

for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        judge = True
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
                judge = False
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > h +abs(cx - x) + abs(cx - y):
                judge = False
                break
        if judge:
            print(cx, cy, sh + abs(sx - cx) + abs(sy - cy))
            
            exit()

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

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

if xyh[0][2] == 0:
    minx, maxx = 100, 0
    miny, maxy = 100, 0
else:
    minx, maxx = 0, 100
    miny, maxy = 0, 100

for x, y, h in xyh:
    if h==0:
        minx = min(minx, x)
        maxx = max(maxx, x)
        miny = min(miny, y)
        maxy = max(maxy, y)
    else:
        break

xyh = xyh[::-1]

for cx in range(minx, maxx+1):
    for cy in range(miny, maxy+1):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0 and h > 0:
                ch = esth(x, y, h, cx, cy)
            elif h > 0:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

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], reverse=True)

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


for cx in range(101):
    for cy in range(101):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0:
                ch = esth(x, y, h, cx, cy)
            else:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

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], reverse=True)

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


for cx in range(101):
    for cy in range(101):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0 and h > 0:
                ch = esth(x, y, h, cx, cy)
            elif h > 0:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

Submission status: Wrong Answer

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

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


for cx in range(101):
    for cy in range(101):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0 and h > 0:
                ch = esth(x, y, h, cx, cy)
            elif h > 0:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

Submission status: Wrong Answer

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

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


for cx in range(101):
    for cy in range(101):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0 and h > 0:
                ch = esth(x, y, h, cx, cy)
            else:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

Submission status: Wrong Answer

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

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


for cx in range(101):
    for cy in range(101):
        f = True
        ch = 0
        for x, y, h in xyh:
            if ch == 0:
                ch = esth(x, y, h, cx, cy)
            else:
                if ch != esth(x, y, h, cx, cy):
                    f = False
                    break
        if f:
            print('{} {} {}'.format(cx, cy, ch))
            break

Submission status: Wrong Answer

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

def isOK(x, y, h, cx, cy, ch):
    return h == max(ch - abs(x-cx) - abs(y-cy), 0)

for ch in range(1, 101):
    for cx in range(100):
        for cy in range(100):
            f = True
            for x, y, h in xyh:
                if not isOK(x, y, h, cx, cy, ch):
                    f = False
                    break
            if f:
                print('{} {} {}'.format(cx, cy, ch))
                break

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if K == 0:
                hight = h + abs(cx - x) + abs(cy -y)
            else:
                if hight != h + abs(cx - x) + abs(cy -y):
                    
                    break
            if K == len(lis) - 1:
                print(cx, cy, hight)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        lis.append([x, y, h])
for i in range(101):
    for j in range(101):
        judge = True
        cx, cy = i, j
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if K == 0:
                hight = h + abs(cx - x) + abs(cy -y)
            else:
                if hight != h + abs(cx - x) + abs(cy -y):
                    judge = False
                    break
        if judge:
            print(cx, cy, hight)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = [list(map(int, input().split())) for _ in range(N)]
lis.sort(key=lambda x: x[2], reverse=True)
for i in range(101):
    for j in range(101):
        judge = True
        cx, cy = i, j
        for K in range(N):
            x, y, h = lis[K]
            if K == 0:
                hight = h + abs(cx - x) + abs(cy -y)
            else:
                if hight != h + abs(cx - x) + abs(cy -y):
                    judge = False
                    break
        if judge:
            print(cx, cy, hight)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
for i in range(n):
    temp = list(map(int,input().split()))
    if temp[2] > 0:
        xyh.append(temp)
x,y,h = xyh[0][0],xyh[0][1],xyh[0][2]
for i in range(101):
    for j in range(101):
        for k in xyh:
            if k[2]+abs(k[0]-j)+abs(k[1]-i) != h+abs(x-j)+abs(y-i):
                break
        else:
            print(j,i,h+abs(x-j)+abs(y-i))
            exit()

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    c = [0] * n
    for i in range(n):
        a[i],b[i],c[i] = readInt()
    for i in range(101):
        for j in range(101):
            for k in range(max(c),min(c)+105):
                res = False
                for l in range(n):
                    if max(k-abs(a[l]-i)-abs(b[l]-j),0)!=c[l]:
                        res = True
                        break
                if res:
                    continue
                else:
                    print(i,j,k)
                    return
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    a = [0] * n
    b = [0] * n
    c = [0] * n
    for i in range(n):
        a[i],b[i],c[i] = readInt()
    for i in range(101):
        for j in range(101):
            for k in range(max(c),max(c)+105):
                res = False
                for l in range(n):
                    if k-abs(a[l]-i)-abs(b[l]-j)!=c[l]:
                        res = True
                    if res:
                        break
                if res:
                    continue
                else:
                    print(i,j,k)
                    return
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc112


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

    x, y, h = [None] * N, [None] * N, [None] * N

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            first = True
            for i in range(N):
                # print(cx, cy, i)
                if h[i] > 0:
                    H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
                    if first:
                        first = False
                        pre_H = H
                    else:
                        if H != pre_H:
                            break
            if H == pre_H:
                print(cx, cy, H)
                return None


main()
# print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
data = []
for _ in range(n):
    x,y,h = map(int,input().split())
    data.append((x,y,h))
for x in range(101):
    for y in range(101):
        c = -1
        for a,b,h in data:
            if c == -1:
                c = h+abs(a-x)+abs(b-y)
            else:
                if c != h+abs(a-x)+abs(y-b):
                    break
        else:
            print(x,y,c)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

d = {}

x, y, h = map(int, input().split())
count = 0

while True:
  if(h == 0):
    x, y, h = map(int, input().split())
    count+= 1
    continue
  else:
    for i in range(101):
      for j in range(101):
        d[(i, j)] = abs(i- x)+ abs(j- y)+ h
    count+= 1
    break

for k in range(N- count):
  x, y, h = map(int, input().split())
  if(h == 0):
    continue
  else:
    for i in range(101):
      for j in range(101):
        if((i, j) in d):
          if(d[(i, j)] != abs(i- x)+ abs(j- y)+ h):
            del d[(i, j)]

if(len(d) == 1):            
  zahyou, height = list(d.items())[0]
else:  
  zahyou, height = list(d.items())[20]
  
print("{0[0]} {0[1]} {1}".format(zahyou, height))

Submission status: Wrong Answer

Solution code:
N = int(input())

d = {}

x, y, h = map(int, input().split())
count = 0

while True:
  if(h == 0):
    x, y, h = map(int, input().split())
    count+= 1
    continue
  else:
    for i in range(101):
      for j in range(101):
        d[(i, j)] = abs(i- x)+ abs(j- y)+ h
    count+= 1
    break

for k in range(N- count):
  x, y, h = map(int, input().split())
  if(h == 0):
    continue
  else:
    for i in range(101):
      for j in range(101):
        if((i, j) in d):
          if(d[(i, j)] != abs(i- x)+ abs(j- y)+ h):
            del d[(i, j)]

if(len(d) == 1):            
  zahyou, height = list(d.items())[0]
else:  
  zahyou, height = list(d.items())[10]
  
print("{0[0]} {0[1]} {1}".format(zahyou, height))

Submission status: Wrong Answer

Solution code:
N = int(input())

d = {}

x, y, h = map(int, input().split())
count = 0

while True:
  if(h == 0):
    x, y, h = map(int, input().split())
    count+= 1
    continue
  else:
    for i in range(101):
      for j in range(101):
        d[(i, j)] = abs(i- x)+ abs(j- y)+ h
    count+= 1
    break

for k in range(N- count):
  x, y, h = map(int, input().split())
  if(h == 0):
    continue
  else:
    for i in range(101):
      for j in range(101):
        if((i, j) in d):
          if(d[(i, j)] != abs(i- x)+ abs(j- y)+ h):
            del d[(i, j)]

if(len(d) == 1):            
  zahyou, height = list(d.items())[0]
else:  
  zahyou, height = list(d.items())[1]
  
print("{0[0]} {0[1]} {1}".format(zahyou, height))

Submission status: Wrong Answer

Solution code:
N = int(input())

d = {}

x, y, h = map(int, input().split())
count = 0

while True:
  if(h == 0):
    x, y, h = map(int, input().split())
    count+= 1
    continue
  else:
    for i in range(101):
      for j in range(101):
        d[(i, j)] = abs(i- x)+ abs(j- y)+ h
    count+= 1
    break

for k in range(N- count):
  x, y, h = map(int, input().split())
  if(h == 0):
    continue
  else:
    for i in range(101):
      for j in range(101):
        if((i, j) in d):
          if(d[(i, j)] != abs(i- x)+ abs(j- y)+ h):
            del d[(i, j)]
          
zahyou, height = list(d.items())[0]
print("{0[0]} {0[1]} {1}".format(zahyou, height))

Submission status: Wrong Answer

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

takasa = [[-1] * (101) for _ in range(101)]
for i in range(n):
    x, y, h = XYH[i]
    if h == 0:
        takasa[x][y] = 0
    for j in range(101):
        for k in range(101):
            if takasa[j][k] == -1:
                takasa[j][k] = abs(x - j) + abs(y - k) + h
            else:
                if takasa[j][k] == abs(x - j) + abs(y - k) + h:
                    continue
                else:
                    takasa[j][k] = -2
for i in range(101):
    for j in range(101):
        if takasa[i][j] > 0:
            print(i, j, takasa[i][j])
            exit()

Submission status: Wrong Answer

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

takasa = [[-1] * (101) for _ in range(101)]
for i in range(n):
    x, y, h = XYH[i]
    if h == 0:
        continue
    for j in range(101):
        for k in range(101):
            if takasa[j][k] == -1:
                takasa[j][k] = abs(x - j) + abs(y - k) + h
            else:
                if takasa[j][k] == abs(x - j) + abs(y - k) + h:
                    continue
                else:
                    takasa[j][k] = -2
for i in range(101):
    for j in range(101):
        if takasa[i][j] > 0:
            print(i, j, takasa[i][j])
            exit()

Submission status: Wrong Answer

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

takasa = [[-1] * (101) for _ in range(101)]
for i in range(n):
    x, y, h = XYH[i]
    if h == 0:
        continue
    cnt = 0
    for j in range(101):
        for k in range(101):
            if takasa[j][k] == -1:
                takasa[j][k] = abs(x - j) + abs(y - k) + h
            else:
                if takasa[j][k] == abs(x - j) + abs(y - k) + h:
                    cnt += 1
                else:
                    takasa[j][k] = -2
    if cnt == 1:
        break
for i in range(101):
    for j in range(101):
        if takasa[i][j] > 0:
            print(i, j, takasa[i][j])
            exit()

Submission status: Wrong Answer

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

takasa = [[-1] * (101) for _ in range(101)]
for i in range(n):
    x, y, h = XYH[i]
    if h == 0:
        continue
    cnt = 0
    for j in range(101):
        for k in range(101):
            if takasa[j][k] == -1:
                takasa[j][k] = abs(x - j) + abs(y - k) + h
                cnt += 1
            else:
                if takasa[j][k] == abs(x - j) + abs(y - k) + h:
                    cnt += 1
                else:
                    takasa[j][k] = -2
    if cnt == 1:
        break
for i in range(101):
    for j in range(101):
        if takasa[i][j] > 0:
            print(i, j, takasa[i][j])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
low = 0
hi = 10**9

li = []

for _ in range(n):
    x,y,h = map(int,input().split())
    if h != 0:
        li.append((x,y,h))

for i in range(101):
    for j in range(101):
        flag = True
        h = li[0][2]+abs(i-li[0][0])+abs(j-li[0][1])
        for k in range(1,len(li)):
            if li[k][2]+abs(i-li[k][0])+abs(j-li[k][1]) != h:
                flag = False
                break
        if flag:
            print(i,j,h)
            exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#print('xyh', xyh)

flag=0
for Cx in range(101):
    for Cy in range(101):
        Hcands=[]
        for i in range(N):
            x = xyh[i][0]
            y = xyh[i][1]
            h = xyh[i][2]
            #print('xyh',x,y,h)
            if h>0:
                Hcand = h + abs(x-Cx) + abs(y-Cy)
                #print('H',H)
                if Hcand>=1:
                    Hcands.append(Hcand)
        if len(set(Hcands))==1:
            print(Cx,Cy,Hcand)
            flag=1
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
x0, y0, h0 = map(int, input().split())
xyh = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(101):
    for j in range(101):
        res = 1
        for x, y, h in xyh:
            if h == max(h0+abs(x0-i)+abs(y0-j)-abs(x-i)-abs(y-j), 0):
                res *= 1
            else:
                res *= 0
        if res:
            print(i, j, h0 + abs(x0-i) + abs(y0-j))
            exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
xs = []
ys = []
hs = []
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        xs.append(x)
        ys.append(y)
        hs.append(h)
n = len(xs)

for cx in range(0, 100+1):
    for cy in range(0, 100+1):
        Hs = set()
        for i in range(n):
            calcH = max(abs(xs[i]-cx) + abs(ys[i]-cy) + hs[i], 0)
            if calcH == hs[i]:
                Hs.add(calcH)
        if len(Hs) == 1:
            print(cx, cy, Hs.pop())
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
xs = []
ys = []
hs = []
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        xs.append(x)
        ys.append(y)
        hs.append(h)
n = len(xs)

for cx in range(0, 100+1):
    for cy in range(0, 100+1):
        Hs = set()
        for i in range(n):
            calcH = max(abs(xs[i]-cx) + abs(ys[i]-cy) + hs[i], 0)
            Hs.add(calcH)
        if len(Hs) == 1:
            print(cx, cy, Hs.pop())
            sys.exit(0)