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

k = 0
while li[k][2] == 0:
    k += 1
 
for x in range(101):
    for y in range(101):

        H = li[k][2]+abs(li[k][0]-x)+abs(li[k][1]-y)
        f = 1

        for i in range(N):
            if li[i][2] >= 1 and H != li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y):
                f = 0
                break
        if f == 1:
            print(x,y,H)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for y in range(101):

    for x in range(101):

        hp = []

        for i in range(N):
            if li[i][2] != 0:
                hp.append(li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y))

        if max(hp) == min(hp):
            check = 1
            for i in range(N):
                if x == li[i][0] and y == li[i][1] and max(hp) != li[i][2]:
                    check = 0
            if check == 1:
                break

    else:
        continue
    break


print(x,y,hp[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for y in range(101):
    for x in range(101):
        hp = []
        hm = 10**9+7
        for i in range(N):
            if li[i][2] != 0:
                hp.append(li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y))
            else:
                hm = min(hm,abs(li[i][0]-x)+abs(li[i][1]-y))
        if max(hp) == min(hp) and max(hp) <= hm:
            break
    else:
        continue
    break


print(x,y,hp[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for y in range(101):
    for x in range(101):
        hp = []
        for i in range(N):
            if li[i][2] > 0:
                hp.append(li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y))
        if max(hp) == min(hp):
            break
    else:
        continue
    break


print(x,y,hp[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for y in range(101):
    for x in range(101):
        hp = []
        for i in range(N):
            if li[i][2] != 0:
                hp.append(li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y))
        if max(hp) == min(hp):
            break
    else:
        continue
    break


print(x,y,hp[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

print(li)

for y in range(101):
    for x in range(101):
        hp = []
        for i in range(N):
            if li[i][2] != 0:
                hp.append(li[i][2]+abs(li[i][0]-x)+abs(li[i][1]-y))
        if max(hp) == min(hp):
            break
    else:
        continue
    break


print(x,y,hp[0])

Submission status: Wrong Answer

Solution code:
n = int(input())

lis = []

for i in range(n):
    array = list(map(int, input().split()))
    lis.append(array)

for i in range(101):
    for j in range(101):
        h = abs(i-lis[0][0]) + abs(j-lis[0][1]) + lis[0][2]
        flag = True
        for k in range(1, n):
            dist = abs(i - lis[k][0]) + abs(j - lis[k][1])
            if h - dist == lis[k][2]:
                continue
            else:
                flag = False
                break
        if flag is True:
            print(i, j, h)
            exit()

Submission status: Wrong Answer

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapify
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n = INT()

ans = []
x,y,h = MAP()
for i in range(101):
    for j in range(101):
        ans.append((i,j,h+abs(i-x)+abs(j-y)))

for i in range(n-1):
    tmp = []
    x,y,h = MAP()
    for j in range(101):
        for k in range(101):
            if (j,k,h+abs(j-x)+abs(k-y)) in ans:
                tmp.append((j,k,h+abs(j-x)+abs(k-y)))
    ans = tmp

print(ans)

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):
    ch = 0
    for x, y, h in xyh:
      if x==cx and y==cy:
        if ch!=0:
          if h!=ch:
            break
        else:
          ch = h
      else:
        nh = abs(x-cx) + abs(y-cy)
        if h == 0:
          if nh < ch:
            break
        else:
          nh += h
          if ch == 0:
            ch = nh
          else:
            if ch != nh:
              break
    else:
      print(cx, cy, ch)
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N    


for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

if(N==1):
    print(A[0][0],A[0][1],A[0][2])
    exit()

H=0
x=0
y=0
for i in range(101):
    for j in range(101):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j
print(x,y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N    


for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

if(N==1):
    print(A[0][0],A[0][1],A[0][2])
    exit()

H=0
x=0
y=0
for i in range(-1,102):
    for j in range(-1,102):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j

if(x==-1 or y==-1 or x==101 or y==101):
    A=sorted(A,key=lambda x: (x[2]))
    print(A[-1][0],A[-1][1],A[-1][2])
else:
    print(x,y,H)

Submission status: Wrong Answer

Solution code:
n=int(input())

zahyo=[]

for _ in range(n):
    zahyo.append(list(map(int,input().split())))

for x in range(101):
    for y in range(101):

        flag=0
        saisho=10**9+1
        H=0
        for item in zahyo:
            if item[2]==0:
                saisho=min(saisho,abs(x-item[0])+abs(y-item[1]))
            else:
                if H==0:
                    H=item[2]+abs(item[0]-x)+abs(item[1]-y)
                else:
                    H_temp=item[2]+abs(item[0]-x)+abs(item[1]-y)
                    if H_temp!=H:
                        flag=1
                        break
        if flag==0 and H<=saisho:
            print(x,y,H)

Submission status: Wrong Answer

Solution code:
n=int(input())

zahyo=[]

for _ in range(n):
    zahyo.append(list(map(int,input().split())))


for x in range(101):
    for y in range(101):

        flag=0
        saisho=10**9+1
        H=0
        for item in zahyo:
            if item[2]==0:
                saisyo=min(saisho,abs(x-item[0])+abs(y-item[1]))
            else:
                if H==0:
                    H=item[2]+abs(item[0]-x)+abs(item[1]-y)
                else:
                    H_temp=item[2]+abs(item[0]-x)+abs(item[1]-y)
                    if H_temp!=H:
                        flag=1
                        break
        if flag==0 and H<saisho:
            print(x,y,H)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        H=0
        flg=0
        for l in ll:
            if l[2] > 0:
                if H == 0:
                    H = l[2] + abs(l[0]-x) + abs(l[1]-y)
                elif H != l[2] + abs(l[0]-x) + abs(l[1]-y):
                    flg=1
                    break
        if flg==0:
        	print(x,y,H)
        	sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N    


for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

if(N==1):
    print(A[0][0],A[0][1],A[0][2])
    exit()

H=0
x=0
y=0
for i in range(101):
    for j in range(101):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j

print(x,y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N    


for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

if(N==1):
    print(A[0])

H=0
x=0
y=0
for i in range(101):
    for j in range(101):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j

print(x,y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N

for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

H=0
x=0
y=0
for i in range(101):
    for j in range(101):
        f=0
        h=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(h!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            if(h>H):
                H=h
                x=i
                y=j

print(x,y,H)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N

for i in range(N):
    A[i]=list(map(int,input().split()))
A=sorted(A,key=lambda x: (x[0],x[1]))

for i in range(101):
    for j in range(101):
        f=0
        H=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(H!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            print(i,j,H)
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]*N

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

for i in range(101):
    for j in range(101):
        f=0
        H=abs(i-A[0][0])+abs(j-A[0][1])+A[0][2]
        for k in range(N):
            if(H!=abs(i-A[k][0])+abs(j-A[k][1])+A[k][2]):
                f=1
                break 
        if(f==0):
            print(i,j,H)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        H=0
        flg=0
        for l in ll:
            if l[2] > 0:
                if H == 0:
                    H = l[2] + abs(l[0]-x) + abs(l[1]-y)
                if H != l[2] + abs(l[0]-x) + abs(l[1]-y):
                    flg=1
                    break
        if flg==0:
        	print(x,y,H)
        	sys.exit()

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)

flag = True

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

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

    return


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:
import sys
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for Cx in range(0,101):
    for Cy in range(0,101):
        p = 0
        ans = []
        for i in xyh:
            H = i[2]+abs(i[0]-Cx)+abs(i[1]-Cy)
            if H < 1:
                H = -3425
                break
            if i[2] != 0:
                ans.append(H)
        if len(set(ans)) == 1:
            print(Cx,Cy,ans[0])

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for Cx in range(0,101):
    for Cy in range(0,101):
        p = 0
        ans = []
        for i in xyh:
            H = i[2]+abs(i[0]-Cx)+abs(i[1]-Cy)
            if H < 1:
                H = -3425
                break
            if i[2] != 0:
                ans.append(H)
        if len(set(ans)) == 1:
            print(Cx,Cy,H)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for Cx in range(0,101):
    for Cy in range(0,101):
        ans = []
        for i in xyh:
            H = i[2]+abs(i[0]-Cx)+abs(i[1]-Cy)
            if H < 1:
                break
            if i[2] != 0:
                ans.append(H)
        if len(set(ans)) == 1:
            for a, i in enumerate(xyh):
                if max(H-(abs(i[0]-Cx)+abs(i[1]-Cy)), 0) != i[2]:
                    break
                elif a == N-1:
                    print(Cx, Cy, H)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for Cx in range(0,101):
    for Cy in range(0,101):
        ans = []
        for i in xyh:
            H = i[2]+abs(i[0]-Cx)+abs(i[1]-Cy)
            if i[2] != 0:
                ans.append(H)
        if len(set(ans)) == 1:
            for a, i in enumerate(xyh):
                if max(H-(abs(i[0]-Cx)+abs(i[1]-Cy)), 0) != i[2]:
                    break
                elif a == N-1:
                    print(Cx, Cy, H)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
for Cx in range(0,101):
    for Cy in range(0,101):
        ans = []
        for i in xyh:
            H = i[2]+abs(i[0]-Cx)+abs(i[1]-Cy)
            if i[2] != 0:
                ans.append(H)
        if len(set(ans)) == 1:
            print(Cx, Cy, H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True
        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)
            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        #print(i,j,hi)
        if flg:
            ans=[i,j,max(hi)]
print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True
        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)
            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        #print(i,j,hi)
        if flg:
            ans=[i,j,hi[0]]
if N==1:
    print(A)
    exit()
print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        hi=[]
        flg=True
        for a in A:
            if a[2]!=0:
                hi_=a[2]+abs(a[1]-j)+abs(a[0]-i)
                hi.append(hi_)
            if len(hi)>=2:
                if hi[-1]!=hi[-2]:
                    flg=False
        #print(i,j,hi)
        if flg:
            ans=[i,j,hi[0]]

print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = []
for _ in range(n):
  x, y, h = map(int, input().split())
  if h != 0:
    lst.append([x, y, h])
if len(lst) == 1:
  print(lst[0])
  quit()
for cx in range(101):
  for cy in range(101):
    a = True
    preh = abs(lst[0][0] - cx) + abs(lst[0][1] - cy) +lst[0][2]
    for x, y, h in lst[1:]:
      H = abs(x - cx) + abs(y - cy) + h
      if H != preh:
        a = False
        break
    if a:
      print(cx, cy, H)
      quit()

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = []
for _ in range(n):
  x, y, h = map(int, input().split())
  if h != 0:
    lst.append([x, y, h])
if len(lst) == 1:
  print(*lst)
  quit()
for cx in range(101):
  for cy in range(101):
    a = True
    preh = abs(lst[0][0] - cx) + abs(lst[0][1] - cy) +lst[0][2]
    for x, y, h in lst[1:]:
      H = abs(x - cx) + abs(y - cy) + h
      if H < 1:
        continue
      if H != preh:
        a = False
        break
    if a:
      print(cx, cy, H)
      quit()

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = []
for _ in range(n):
  x, y, h = map(int, input().split())
  if h:
    lst.append([x, y, h])
if len(lst) == 1:
  print(*lst)
  quit()
for cx in range(101):
  for cy in range(101):
    a = True
    preh = abs(lst[0][0] - cx) + abs(lst[0][1] - cy) +lst[0][2]
    for x, y, h in lst[1:]:
      H = abs(x - cx) + abs(y - cy) + h
      if H != preh:
        a = False
        break
    if a:
      print(cx, cy, H)
      quit()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    for cx in range(101):
        for cy in range(101):
            H_set = set()
            cur_h = -1
            for x, y, h in zip(X, Y, H):
                if h == 0:
                    continue
                cur_h = f(x, cx, y, cy, h)
                H_set.add(cur_h)
            if len(H_set) == 1:
                print(cx, cy, cur_h)
                return

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    for cx in range(101):
        for cy in range(101):
            H_set = set()
            cur_h = -1
            for x, y, h in zip(X, Y, H):
                # if h == 0:
                #     continue
                cur_h = f(x, cx, y, cy, h)
                H_set.add(cur_h)
            if len(H_set) == 1:
                print(cx, cy, cur_h)
                return

main()

Submission status: Wrong Answer

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

#H=0を排除,Nも減らす
removelist = []
for i in range(N):
    if XYH[i][2]==0:
        removelist.append(i)

#print(removelist)
if len(removelist)!=0:
    for r in reversed(removelist):
        XYH.pop(r)
        N-=1

#print(XYH)

for cx in range(100+1):
    for cy in range(100+1):
        
        ct=0
        ref = XYH[0][2]+abs(cx-XYH[0][0])+abs(cy-XYH[0][1])
        for i in range(N):
            buff = XYH[i][2]+abs(cx-XYH[i][0])+abs(cy-XYH[i][1])
            if buff == ref:
                ct+=1
        if ct == N:
            print(cx,cy,ref)
            exit()
print("incorrect")

Submission status: Wrong Answer

Solution code:
N = int(input())
x_y_h_list = [list(map(int, input().split())) for _ in range(N)]
x_y_h_list.sort(key=lambda x: x[2], reverse=True)

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = 0
        H = 1
        for idx, x_y_h in enumerate(x_y_h_list):
            if x_y_h[2] == 0:
                if H != x_y_h[2] + abs(cx - x_y_h[0]) + abs(
                        cy - x_y_h[1]):
                    flag = 1
                    break
                else:
                    continue
            else:
                if H == 1:
                    H = x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1])
                else:
                    if H != x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1]):
                        flag = 1
                        break
        if flag == 0:
            print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
x_y_h_list = [list(map(int, input().split())) for _ in range(N)]
x_y_h_list.sort(key=lambda x: x[2], reverse=True)

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = 0
        H = 1
        for idx, x_y_h in enumerate(x_y_h_list):

            if H == 1:
                H = x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1])
            else:
                if H != x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1]):
                    flag = 1
                    break
        if flag == 0:
            print(cx, cy, H)

Submission status: Wrong Answer

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

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = 0
        H = 1
        for idx, x_y_h in enumerate(x_y_h_list):
            if x_y_h[2] == 0:
                continue
            else:
                if H == 1:
                    H = x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1])
                else:
                    if H != x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1]):
                        flag = 1
                        break
        if flag == 0:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = 0
        H = 1
        for idx, x_y_h in enumerate(x_y_h_list):
            if x_y_h[2] == 0:
                continue
            else:
                if H == 1:
                    H = x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1])
                else:
                    if H != x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1]):
                        flag = 1
                        break
        if flag == 0:
            print(cx, cy, H)

Submission status: Wrong Answer

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

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = 0
        H = 0
        for idx, x_y_h in enumerate(x_y_h_list):
            # print(cx, cy, x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1]))
            if x_y_h[2] == 0:
                continue
            else:
                if H == 0:
                    H = x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1])
                else:
                    if H != x_y_h[2] + abs(cx-x_y_h[0]) + abs(cy-x_y_h[1]):
                        flag = 1
                        break
        if flag == 0:
            print(" ".join([str(cx), str(cy), str(H)]))

Submission status: Wrong Answer

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

from itertools import product
for cx, cy in product(range(101), repeat=2):
    H = None
    for x, y, h in xyh:
        if H is None:
            H = h + abs(x-cx) + abs(y-cy)
        else:
            if h != H - abs(x-cx) - abs(y-cy):
                break
    else:
        print(cx, cy, H)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
pyramids = [tuple(map(int,input().split())) for _ in range(N)]
for i in range(101):
  for j in range(101):
    H_set = set()
    for k in range(len(pyramids)):
      x,y,h = pyramids[k]
      if h == 0:
        continue
      H_set.add(h + abs(x - j) + abs(y - i))
    if len(H_set) == 1:
      print(j,i,list(H_set)[0])
      sys.exit()

Submission status: Wrong Answer

Solution code:
def examA():
    N = I()
    if N==1:
        ans = "Hello World"
    elif N==2:
        A = I(); B = I()
        ans = A + B
    try:
        print(ans)
    except:
        print()
    return

def examB():
    N, T = LI()
    ans =  10**9
    for _ in range(N):
        c, t = LI()
        if T>=t and ans>c:
            ans = c
    if ans==10**9:
        ans = "TLE"
    print(ans)
    return

def examC():
    N = I()
    X, Y, H = [0]*N, [0]*N, [0]*N
    for i in range(N):
        X[i], Y[i], H[i] = LI()
    for x in range(101):
        for y in range(101):
            curH = 0; flag = True
            for i in range(N):
                if H[i]==0:
                    continue
                now = H[i] + abs(x-X[i]) + abs(y-Y[i])
                if curH==0:
                    curH = now
                else:
                    if curH!=now:
                        flag = False
                        break
            if flag:
                ans = [x,y,curH]
                break
    print(" ".join(map(str,ans)))
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
B = [[int(x) for x in input().split()] for _ in range(N)]
def heighti(Cx,Cy,x,y,h):
    return abs(x-Cx) + abs(y-Cy) + h
ans = []
h0 = []
A = []
for l in B:
    if l[2] == 0:
        h0.append([l[0],l[1]])
    else:
        A.append(l)
if len(A) > 0:
    for i in range(101):
        for j in range(101):
            tempH = heighti(i,j,A[0][0],A[0][1],A[0][2])
            if tempH < 0:
                break
            else:
                flag = 1
                for k in range(1,len(A)):
                    if A[k][2] != 0 and heighti(i,j,A[k][0],A[k][1],A[k][2]) != tempH:
                        flag = 0
                        break
                if flag:
                    ans.append([i,j,tempH])
if len(ans) == 1:
    print(*ans[0])
elif len(ans) == 0:
    for i in range(101):
        for j in range(101):
            for k in range(N):
                if heighti(i,j,B[k][0],B[k][1],B[k][2]) > 0:
                    print(*[i,j,heighti(i,j,B[k][0],B[k][1],B[k][2])])
                    sys.exit()
else:
    for m in ans:
        for n in h0:
            if heighti(n[0],n[1],m[0],m[1],m[2]) > 0:
                break
        print(*m)
        sys.exit()