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:
def check_value(Cx,Cy,H):
    for i in range(1,N):
        if h[i] + abs(x[i]-Cx) + abs(y[i]-Cy) != H:
            return False
    return True    
    
x = []
y = []
h = []
N = int(input())
for i in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
    
for Cx in range(101):
    for Cy in range(101):
        if h[0] < 0 - abs(x[0]-Cx) - abs(y[0]-Cy):
            H = 0
        else:
            H = h[0] + abs(x[0]-Cx) + abs(y[0]-Cy)
        if check_value(Cx,Cy,H):
            print(Cx,Cy,H)
            exit()
        else:
            continue

Submission status: Wrong Answer

Solution code:
n = int(input())
info = [list(map(int, input().split())) for _ in range(n)]
for Cx in range(101):
    for Cy in range(101):
        flag = False
        check = []
        for x, y, h in info:
            if h == 0:
                continue
            check.append(h+abs(x-Cx)+abs(y-Cy))
        if len(set(check)) == 1:
            flag = True
            ans_h = check[0]
            for x, y, h in info:
                if ans_h != max(h+abs(x-Cx)+abs(y-Cy), 0):
                    flag=False
        if flag:
            print(Cx, Cy, ans_h)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
info = [list(map(int, input().split())) for _ in range(n)]
for Cx in range(101):
    for Cy in range(101):
        check = []
        for x, y, h in info:
            if h == 0:
                continue
            check.append(h+abs(x-Cx)+abs(y-Cy))
        if len(set(check)) == 1:
            print(Cx, Cy, check[0])
            exit()

Submission status: Wrong Answer

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


def main():
    N = int(input())
    x = [None] * N
    y = [None] * N
    h = [None] * N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    # Cx, Cyを全探索する
    for i in range(101):
        for j in range(101):
            flag = True
            H = set()
            for k in range(N):
                if h[k] == 0:
                    continue
                tmpH = h[k] + abs(x[k]-i) + abs(y[k]-j)
                if tmpH < 1:
                    continue
                H.add(tmpH)
                if len(H) > 1:
                    flag = False
                    break
            if flag:
                print(i,j,list(H)[0])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def main():
    N = int(input())
    x = [None] * N
    y = [None] * N
    h = [None] * N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    # Cx, Cyを全探索する
    for i in range(101):
        for j in range(101):
            flag = True
            H = set()
            for k in range(N):
                if h[k] == 0:
                    continue
                H.add(h[k] + abs(x[k]-i) + abs(y[k]-j))
                if len(H) > 1:
                    flag = False
                    break
            if flag:
                print(i,j,list(H)[0])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def main():
    N = int(input())
    x = [None] * N
    y = [None] * N
    h = [None] * N
    for i in range(N):
        x[i], y[i], h[i] = map(int, input().split())
    
    # Cx, Cyを全探索する
    for i in range(101):
        for j in range(101):
            flag = True
            H = h[0] + abs(x[0]-i) + abs(y[0]-j)
            for k in range(1,N):
                if H != h[k] + abs(x[k]-i) + abs(y[k]-j):
                    flag = False
                    break
            if flag:
                print(i,j,H)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])

ans = []
for i in range(101):
    for j in range(101):
        height = []
        flag = True
        for k in range(N):
            minusx = abs(i - info[k][0])
            minusy = abs(j - info[k][1])
            if info[k][2] != 0 or (minusx <= 1 or minusy <= 1):
                h = info[k][2] + minusx + minusy
                if len(height) > 0 and h != height[-1]:
                    flag = False
                    break
                height.append(h)
        if flag and height[0] > 0:
            ans = [i, j, height[0]]
print(*ans)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])

ans = []
for i in range(101):
    for j in range(101):
        height = []
        flag = True
        for k in range(N):
            minusx = abs(i - info[k][0])
            minusy = abs(j - info[k][1])
            if info[k][2] != 0:
                h = info[k][2] + minusx + minusy
                if len(height) > 0 and h != height[-1]:
                    flag = False
                    break
                height.append(h)
        if flag and height[0] > 0:
            ans = [i, j, height[0]]
print(*ans)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])

ans = []
for i in range(101):
    for j in range(101):
        X = i
        Y = j
        height = []
        flag = True
        for k in range(N):
            minusx = abs(X - info[k][0])
            minusy = abs(Y - info[k][1])
            if info[k][2] != 0:
                h = info[k][2] + minusx + minusy
                if len(height) > 0 and h != height[-1]:
                    flag = False
                    break
                height.append(h)
        if flag:
            ans = [i, j, height[0]]
print(*ans)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
info = []
for i in range(N):
    x, y, h = getNM()
    info.append([x, y, h])

ans = []
for i in range(101):
    for j in range(101):
        X = i
        Y = j
        height = []
        flag = True
        for k in range(N):
            minusx = abs(X - info[k][0])
            minusy = abs(Y - info[k][1])
            h = info[k][2] + minusx + minusy
            if k != 0 and h != height[-1]:
                flag = False
                break
            height.append(h)
        if flag:
            ans = [i, j, height[0]]
print(*ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
XYH = TIR(n)
XYH.sort(key=itemgetter(2), reverse=True)
H = INF
CX = INF
CY = INF
for cx in range(100+1):
    for cy in range(100+1):
        tmp = INF
        for x, y, h in XYH:
            if h == 0:
                continue
            if tmp == INF:
                tmp = h+abs(x-cx)+abs(y-cy)
            elif h != max(tmp - abs(x-cx) - abs(y-cy), 0):
                break
        else:
            H = tmp
            CX = cx
            CY = cy
print("{} {} {}".format(CX, CY, H))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
XYH = TIR(n)
H = INF
CX = INF
CY = INF
for cx in range(100+1):
    for cy in range(100+1):
        tmp = INF
        for x, y, h in XYH:
            if h == 0:
                continue
            if tmp == INF:
                tmp = h+abs(x-cx)+abs(y-cy)
            elif h != max(tmp - abs(x-cx)- abs(y-cy), 0):
                break
        else:
            H = tmp
            CX = cx
            CY = cy
print("{} {} {}".format(CX, CY, H))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n = I()
XYH = TIR(n)
H = INF
CX = INF
CY = INF
for cx in range(100+1):
    for cy in range(100+1):
        tmp = INF
        for x, y, h in XYH:
            if h == 0:
                continue
            if tmp == INF:
                tmp = h+abs(x-cx)+abs(y-cy)
            elif tmp != h+abs(x-cx)+abs(y-cy):
                break
        else:
            H = tmp
            CX = cx
            CY = cy
print("{} {} {}".format(CX, CY, H))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[]
for i in range(n):
    lis.append(LI())
lis.sort(key=lambda x:x[2],reverse=True)
x1,y1,h1,x2,y2,h2=lis[0][0],lis[0][1],lis[0][2],lis[1][0],lis[1][1],lis[1][2]
cand=[]
for i in range(101):
    for j in range(101):
        if h1-h2==abs(i-x2)+abs(j-y2)-abs(i-x1)-abs(j-y1):
            cand.append([i,j])
#print(cand)

candx=[]
for j in range(len(cand)):
    H=abs(cand[j][0]-x1)+abs(cand[j][1]-y1)+h1
    #print(H)
    count=0
    for i in range(1,n):
        if lis[i][2]==0:
            count+=1
        elif H==lis[i][2]+abs(cand[j][0]-lis[i][0])+abs(cand[j][1]-lis[i][1]):
            count+=1
    #print(count)
    if count==n-1:
        candx.append([cand[j][0],cand[j][1],H])
#print(candx)
for li in candx:
    flag=True
    for i in range(n):
        if lis[i][2]<0:
            if -abs(li[0]-lis[i][0])-abs(li[1]-lis[i][1])+li[2]>=0:
                flag=False
    if flag==True:
        print(*li)
        sys.exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[]
for i in range(n):
    lis.append(LI())
lis.sort(key=lambda x:x[2],reverse=True)
x1,y1,h1,x2,y2,h2=lis[0][0],lis[0][1],lis[0][2],lis[1][0],lis[1][1],lis[1][2]
cand=[]
for i in range(101):
    for j in range(101):
        if h1-h2==abs(i-x2)+abs(j-y2)-abs(i-x1)-abs(j-y1):
            cand.append([i,j])
#print(cand)

candx=[]
for j in range(len(cand)):
    H=abs(cand[j][0]-x1)+abs(cand[j][1]-y1)+h1
    #print(H)
    count=0
    for i in range(1,n):
        if lis[i][2]==0:
            count+=1
        elif H==lis[i][2]+abs(cand[j][0]-lis[i][0])+abs(cand[j][1]-lis[i][1]):
            count+=1
    #print(count)
    if count==n-1:
        candx.append([cand[j][0],cand[j][1],H])
#print(candx)
for li in candx:
    flag=True
    for i in range(n):
        if lis[i][2]<0:
            if -abs(li[0]-lis[i][0])-abs(li[1]-lis[i][1])+li[2]>=0:
                flag=False
    if flag==True:
        print(*li)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        hmax = 0
        for item in xyh:
            h = item[2] + abs(x - item[0]) + abs(y - item[1])
            if h > 0:
                hmax = h
                break
        is_ok = True
        for item in xyh:
            if max(0, hmax - abs(x - item[0]) - abs(y - item[1])) != item[2]:
                is_ok = False
        if is_ok:
            print(x, y, hmax)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        hmax = 0
        for item in xyh:
            h = item[2] + abs(x - item[0]) + abs(y - item[1])
            hmax = max(hmax, h)
        is_ok = True
        for item in xyh:
            if max(0, hmax - abs(x - item[0]) - abs(y - item[1])) != item[2]:
                is_ok = False
        if is_ok:
            print(x, y, hmax)
            exit()

Submission status: Wrong Answer

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

for i in range(101):
  for j in range(101):
    ans=[]
    for k in t:
      d = abs(k[0]-i)+ abs(k[1]-j)
      h_tmp = d + k[2]
      if ans==[]:
        ans.append(k+[d,h_tmp])
      else:
        if d>ans[-1][-1] and k[2]==0:
          pass
        else:
          if h_tmp!=ans[-1][-1]:
            break
    else:
      print(i,j,ans[-1][-1])
      exit()

Submission status: Wrong Answer

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

t.sort(key=lambda x:x[2],reverse=True)

for i in range(101):
  for j in range(101):
    ans=[]
    for k in t:
      d = abs(k[0]-i)+ abs(k[1]-j)
      h_tmp = d + k[2]
      if ans==[]:
        ans.append(k+[d,h_tmp])
      else:
        if d>ans[-1][-1]:
          pass
        else:
          if h_tmp!=ans[-1][-1]:
            break
    else:
      print(i,j,ans[-1][-1])
      exit()

Submission status: Wrong Answer

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

for i in range(101):
  for j in range(101):
    ans=[]
    for k in range(N):
      dist = abs(x[k]-i)+ abs(y[k]-j)
      height = h[k] + dist
      #print(x[k],y[k],dist,height)
      if len(ans)>0 and height!=ans[0][1]:
        if ans[0][0]==0:
          ans[0]=[h[k],height]
        elif h[k]==0:
          pass
        else:
          break
      else:
        if len(ans)==0:
          ans.append( [ h[k],height ] ) 
        else:
          if ans[0][0]==0:
            ans[0]=[h[k],height]
          else:
            pass
    else:
      print(i,j,ans[0][1])
      exit()

Submission status: Wrong Answer

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

for i in range(101):
  for j in range(101):
    ans=[]
    for k in range(N):
      dist = abs(x[k]-i)+ abs(y[k]-j)
      height = h[k] + dist
      #print(x[k],y[k],dist,height)
      if len(ans)>0 and height!=ans[0][1]:
        if ans[0][0]==0:
          ans[0]=[h[k],height]
        elif h[k]==0:
          pass
        else:
          break
      else:
        ans.append( [ h[k],height ] ) 
    else:
      print(i,j,ans[0][1])
      exit()

Submission status: Wrong Answer

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

for i in range(101):
  for j in range(101):
    ans=[]
    for k in range(N):
      dist = abs(x[k]-i)+ abs(y[k]-j)
      height = h[k] + dist
      print(x[k],y[k],dist,height)
      if len(ans)>0 and height!=ans[0][1]:
        if ans[0][0]==0:
          ans[0]=[h[k],height]
        elif h[k]==0:
          pass
        else:
          break
      else:
        ans.append( [ h[k],height ] ) 
    else:
      print(i,j,ans[0][1])
      exit()

Submission status: Wrong Answer

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

for i in range(55,56):
  for j in range(80,81):
    ans=[]
    for k in range(N):
      dist = abs(x[k]-i)+ abs(y[k]-j)
      height = h[k] + dist
      #print(x[k],y[k],dist,height)
      if len(ans)>0 and height!=ans[0][1]:
        if ans[0][0]==0:
          ans[0]=[h[k],height]
        elif h[k]==0:
          pass
        else:
          break
      else:
        ans.append([h[k],height])
    else:
      print(i,j,ans[0][1])
      exit()

Submission status: Wrong Answer

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

for i in range(55,56):
  for j in range(80,81):
    ans=set()
    for k in range(N):
      if h[k]>0:
        dist = abs(x[k]-i)+ abs(y[k]-j)
        height = h[k] + dist
        #print(x[k],y[k],dist,height)
        if len(ans)>0 and height not in ans:
          break
        else:
          ans.add(height)
    else:
      print(i,j,ans.pop())
      exit()

Submission status: Wrong Answer

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

for i in range(101):
  for j in range(101):
    ans=set()
    for k in range(N):
      dist = abs(x[k]-i)+ abs(y[k]-j)
      height = h[k] + dist
      if len(ans)>0 and height not in ans:
        break
      else:
        ans.add(height)
    else:
      print(i,j,ans.pop())
      exit()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n=int(input())
XYH=[tuple(map(int,input().split())) for i in range(n)]
# XYH.sort(key=itemgetter(2),reverse=True)
# print(XYH)
for cy in range(101):
    for cx in range(101):
        hc=XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
        for x,y,h in XYH[1:]:
            if h!=max(0,hc-abs(x-cx)-abs(y-cy)):
                break
        else:
            print(cx,cy,hc)

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [[0] * 101 for _ in range(101)]
xyh = [tuple(map(int, input().split())) for _ in range(n)]
xyh = sorted(xyh, key=lambda x: x[2], reverse=True)

for xi in range(101):
    for yi in range(101):
        hi = 0
        allok = True
        for i in range(n):
            x,y,h = xyh[i]
            if i == 0:
                hi = abs(xi - x) + abs(yi - y) + h
            if hi - abs(xi - x) - abs(yi - y) != h:
                allok = False
        if allok:
            print(xi, yi, hi)

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [[0] * 101 for _ in range(101)]
xyh = [tuple(map(int, input().split())) for _ in range(n)]

for xi in range(101):
    for yi in range(101):
        hi = 0
        allok = True
        for i in range(n):
            x,y,h = xyh[i]
            if i == 0:
                hi = abs(xi - x) + abs(yi - y) + h
            if hi - abs(xi - x) - abs(yi - y) != h:
                allok = False
        if allok:
            print(xi, yi, hi)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        c = (cx, cy)
        H = []
        for x, y, h in xyh:
            if h == 0:
                continue
            H.append(h+abs(x-cx)+abs(y-cy))
        if len(set(H)) == 1:
            ans = [cx, cy, H[0]]
            break
    else:
        continue
    break

print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int,input().split())))
H = []
for cx in range(0,101):
    for cy in range(0,101):
        hantei = False
        for i in range(n):
            if xyh[i][2] > 0:
                if not H:
                    H.append(xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]))
                else:
                    hantei = True
                    if xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]) != H[0]:
                        H.pop(0)
                        break
        else:
            if H[0] <= 100 and hantei: 
                print(cx,cy,H[0])
                exit()
else:
    mx = 0
    for i in range(n):
        if mx < xyh[i][2]:
            ansind = i
            mx = xyh[i][2]
    print(xyh[ansind][0],xyh[ansind][1],xyh[ansind][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int,input().split())))
H = []
for cx in range(0,101):
    for cy in range(0,101):
        for i in range(n):
            if xyh[i][2] > 0:
                if not H:
                    H.append(xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]))
                else:
                    if xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]) != H[0]:
                        H.pop(0)
                        break
        else:
            print(cx,cy,H[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int,input().split())))
H = []
for cx in range(0,101):
    for cy in range(0,101):
        if cx == 100 and cy == 0:
            print('ans')
        for i in range(n):
            if xyh[i][2] >= 0:
                if not H:
                    H.append(xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]))
                else:
                    if xyh[i][2] + abs(cx-xyh[i][0]) + abs(cy-xyh[i][1]) != H[0]:
                        H.pop(0)
                        break
        else:
            print(cx,cy,H[0])
            exit()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        xyh.append((x, y, h))

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

            for x, y, h in xyh:
                tmp = H - abs(x - cx) - abs(y - cy)
                if tmp == h:
                    continue
                else:
                    break
            else:
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        xyh.append((x, y, h))

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

            for x, y, h in xyh[i + 1 :]:
                tmp = H - abs(x - cx) - abs(y - cy)
                if tmp == h:
                    continue
                else:
                    break
            else:
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())

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


for cx in range(101):
    for cy in range(101):
        for xyh in XYH:
            if xyh[2] > 0:
                H = abs(cx - xyh[0]) + abs(cy - xyh[1]) + xyh[2]
                break
        for xyh in XYH:
            _x, _y, _h = xyh
            if H - _h == abs(cx-_x) + abs(cy-_y):
                continue
            break
        else:
            print(cx, cy, H)
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())

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


for cx in range(101):
    for cy in range(101):
        for xyh in XYH:
            H = abs(cx - xyh[0]) + abs(cy - xyh[1]) + xyh[2]
            if H > 0:
                break
        for xyh in XYH:
            _x, _y, _h = xyh
            if H - _h == abs(cx-_x) + abs(cy-_y):
                continue
            break
        else:
            print(cx, cy, H)
            sys.exit(0)