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:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
xyh=sorted(xyh,key=lambda x:x[2])
for cx in range(101):
    for cy in range(101):
        h_a=h_b=10**9+1
        minh=10**9+2
        for i in range(n):
            x,y,h=xyh[i]
            if h!=0:
                h_a=h+abs(cx-x)+abs(cy-y)
                if h_b!=10**9+1 and (h_a!=h_b or h_a>minh):
                    break
                else:
                    h_b=h_a
            else:
                minh=min(minh,abs(cx-x)+abs(cy-y))
                if minh==0:
                  break
        else:
            if h>=1:
              print(cx,cy,h_a)
              exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if c==0:continue
  x.append(a)
  y.append(b)
  h.append(c)
for i in range(101):
  for j in range(101):
    H=h[0]+abs(x[0]-i)+abs(y[0]-j)
    for a,b,c in zip(x,y,h):
      if H!=c+abs(a-i)+abs(b-j):break
    else:
      print(i,j,h[0]+abs(x[0]-i)+abs(y[0]-j))
      exit()

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
xyh=sorted(xyh,key=lambda x:x[2])
for cx in range(101):
    for cy in range(101):
        h_a=h_b=10**9+1
        minh=10**9+2
        for i in range(n):
            x,y,h=xyh[i]
            if h!=0:
                h_a=h+abs(cx-x)+abs(cy-y)
                if h_b!=10**9+1 and (h_a!=h_b or h_a>minh):
                    break
                else:
                    h_b=h_a
            else:
                minh=min(minh,abs(cx-x)+abs(cy-y))
        else:
            print(cx,cy,h_a)
            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):
      if len(set([h[k]+abs(x[k]-i)+abs(y[k]-j) for k in range(n)]))==1:
        print(i,j,h[0]+abs(x[0]-i)+abs(y[0]-j))
        exit()

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
xyh=sorted(xyh,key=lambda x:x[2])
for cx in range(101):
    for cy in range(101):
        h_a=h_b=10**9+1
        minh=10**9+2
        for i in range(n):
            x,y,h=xyh[i]
            if h!=0:
                h_a=h+abs(cx-x)+abs(cy-y)
                if h_b!=10**9+1 and (h_a!=h_b or h_a>minh):
                    break
                else:
                    h_b=h_a
            else:
                minh=min(minh,abs(cx-x)+abs(cy-y))
        else:
            print(cx,cy,h_a)

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):
    H=h[0]+abs(x[0]-i)+abs(y[0]-j)
    for k in range(n):
      if H!=h[k]+abs(x[k]-i)+abs(y[k]-j):break
    else:
      print(i,j,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==2:
  print()
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==1:
  a=3/0
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)

Submission status: Wrong Answer

Solution code:
a=1

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[None]*n
for i in range(n):
    a,b,c=map(int,input().split())
    lst[i]=[a,b,c]
if n==1:
    print(*lst[0])
    exit()
if n==2:
    lst=sorted(lst,key=lambda x:x[2])
    print(*lst[1])
    exit()

for i in range(101):
    for j in range(101):
        switch=0
        x,y,z=lst[0]
        height=z+abs(i-x)+abs(j-y)
        for k in range(1,n):
            x,y,z=lst[k]
            if abs(i-x)+abs(j-y)+z!=height:
                switch=1
                break
        if switch==0:
            print(i,j,height)

Submission status: Wrong Answer

Solution code:
n=int(input())
query=[]
for _ in range(n):
    a,b,c=map(int,input().split())
    query.append((a,b,c))
query=sorted(query, key=lambda x:x[2], reverse=True)

for cx in range(101):
  for cy in range(101):
      h=None
      flg=True
      for q in query:
        if h==None:
          h=q[2]+abs(cx-q[0])+abs(cy-q[1])
        elif q[2]!=0 and h!=q[2]+abs(cx-q[0])+abs(cy-q[1]):
          flg=False
          break
      if flg: 
        print(cx,cy,h)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N=int(input())
xyh = sorted([ list(map(int,input().split())) for _ in range(N)],key = lambda x:-x[2])

if N==1:
    print(xyh[0],xyh[1],xyh[2])
else:
    for cx in range(1,56):
        for cy in range(101):
            flag = 0
            dx = abs(cx - xyh[0][0])
            dy = abs(cy - xyh[0][1])
            hmax = xyh[0][2]+dx+dy
            for i in range(1,N):
                if max(hmax -( abs(cx - xyh[i][0])+abs(cy - xyh[i][1])),0) !=  xyh[i][2]:
                    flag = 1
                    break
            if flag == 0:
                print(cx,cy,hmax)
                exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

if N==1:
    print(xyh[0],xyh[1],xyh[2])
else:
    for cx in range(101):
        for cy in range(101):
            flag = 0
            dx = abs(cx - xyh[0][0])
            dy = abs(cy - xyh[0][1])
            hmax = xyh[0][2]+dx+dy
            for i in range(1,N):
                if hmax != xyh[i][2] + abs(cx - xyh[i][0])+abs(cy - xyh[i][1]):
                    flag = 1
                    break
            if flag == 0:
                print(cx,cy,hmax)
                exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(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
        flag=True
        for i in range(n):
            x=xyh[i][0]
            y=xyh[i][1]
            h=xyh[i][2]
            if i==0:
                hi=abs(xi-x)+abs(yi-y)+h
            if max(hi-abs(xi-x)-abs(yi-y),0)!=h:
                flag=False
        if flag:
            print(xi, yi, hi)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(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
        flag=True
        for i in range(n):
            x=xyh[i][0]
            y=xyh[i][1]
            h=xyh[i][2]
            if i==0:
                hi=abs(xi-x)+abs(yi-y)+h
            if max(hi-abs(xi-x)-abs(yi-y),0)!=h:
                flag=False
        if flag:
            print(xi, yi, hi)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]

def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [1])
		cc = collections.Counter()
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h > 0:
				Y = h + q
				if H<=Y <= 10 ** 9:
					cc[Y]+=1
				else:
					cc[10 ** 9 + 2] += 1
		if len(cc) == 1:
			for k in cc:
				return k,cx,cy

h,x,y = f(pts)

print x,y,h

Submission status: Wrong Answer

Solution code:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]

def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = max([abs(cx - x) + abs(cy - y) for x,y,h in pts if h == 0] or [1])
		cc = collections.Counter()
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h:
				#Y  - q = h
				Y = h + q
				if Y >= H:
					cc[Y]+=1
				else:
					cc[10 ** 9 + 1] += 1
		if len(cc) == 1:
			for k in cc:
				return k,cx,cy

h,x,y = f(pts)

print x,y,h

Submission status: Wrong Answer

Solution code:
import collections
n = int(raw_input())
pts = [map(int , raw_input().split()) for _ in range(n)]
res = -1
def f(pts):
	for cx,cy in [(ii,jj) for ii in range(100+1) for jj in range(100+1)]:	
		H = 10 ** 9 + 1
		fh = []
		cc = collections.Counter()
		for x,y,h in pts:
			q = abs(cx - x) + abs(cy - y)
			if h == 0:
				H = min(H, q)
				return h, cx, cy
			else:
				cc[q - h] += 1
				cc[q + h] += 1
		for k in cc:
			if k >= 0 and cc[k] == len(pts):
				return k,cx,cy
h,x,y = f(pts)

print x,y,h

Submission status: Wrong Answer

Solution code:
n = int(input())
x, y, h = zip(*[map(int, input().split()) for _ in range(n)])

h_range = {}
for cx in range(0, 101):
    for cy in range(0, 101):
        h_range[(cx, cy)] = [1, 1000000000]

for i in range(n):
    for (cx, cy) in h_range.keys():
        ch_max = h[i] + (abs(cx - x[i]) + abs(cy - y[i]))
        if h[i] == 0:
            ch_min = 0
        else:
            ch_min = ch_max
        ch_range = h_range[(cx, cy)]
        h_range[(cx, cy)] = [max(ch_min, ch_range[0]), min(ch_max, ch_range[1])]

for (cx, cy) in h_range.keys():
    ch_range = h_range[(cx, cy)]
    if ch_range[0] <= ch_range[1]:
        print('{} {} {}'.format(cx, cy, ch_range[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
x, y, h = zip(*[map(int, input().split()) for _ in range(n)])

h_range = {}
for cx in range(0, 101):
    for cy in range(0, 101):
        h_range[(cx, cy)] = [1, 1000000000]

for i in range(n):
    for (cx, cy) in h_range.keys():
        ch_max = h[i] + (abs(cx - x[i]) + abs(cy - y[i]))
        if h[i] == 0:
            ch_min = 0
        else:
            ch_min = ch_max
        ch_range = h_range[(cx, cy)]
        h_range[(cx, cy)] = [max(ch_min, ch_range[0]), min(ch_max, ch_range[1])]

for (cx, cy) in h_range.keys():
    ch_range = h_range[(cx, cy)]
    if ch_range[0] <= ch_range[1]:
        for ch in range(ch_range[0], ch_range[1] + 1):
            print('{} {} {}'.format(cx, cy, ch))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
sx,sy,sh=a[0][0],a[0][1],a[0][2]
for y in range(101):
    for x in range(101):
        h=sh+abs(x-sx)+abs(y-sy)
        f=1
        #一つでも条件に合致していなかったらフラグを折る
        for i in range(n):
            if max(abs(x-a[i][0])+abs(y-a[i][1])+a[i][2],0)!=h:
                f=0
        #立ってたら終わり
        if f==1:
            print(x,y,h)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
sx,sy,sh=a[0][0],a[0][1],a[0][2]
for y in range(101):
    for x in range(101):
        h=sh+abs(x-sx)+abs(y-sy)
        f=1
        #一つでも条件に合致していなかったらフラグを折る
        for i in range(n):
            if abs(x-a[i][0])+abs(y-a[i][1])+a[i][2]!=h:
                f=0
        #立ってたら終わり
        if f==1:
            print(x,y,h)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
sx,sy,sh=a[0][0],a[0][1],a[0][2]
for y in range(101):
    for x in range(101):
        h=sh+abs(x-sx)+abs(y-sy)
        f=1
        for i in range(n):
            if abs(x-a[i][0])+abs(y-a[i][1])+a[i][2]!=h:
                f=0
        if f==1:
            print(x,y,h)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
info =[]

for n in range(N):
    info.append(list(map(int,input().split())))

def chech(Cx,Cy,x,y,h):
    if h > 0:
        H = h + abs(x-Cx)+abs(y-Cy)
        c_list.append(H)
    return 
    
for Cx in range(101):
    for Cy in range(101):
        c_list=[]
        for i in info:
            x,y,h=i
            c_=chech(Cx,Cy,x,y,h)

        if len(set(c_list))==1:
            print(Cx,Cy,c_list[0])

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):
        top = 0
        bl = True
        for x, y, h in xyh:
            if h == 0:
                continue

            top_cand = h + abs(x - cx) + abs(y - cy)

            if top == 0 and top_cand:
                top = top_cand
            elif top != 0 and top != top_cand:
                bl = False

        if bl and top:
            print(cx, cy, top)
            exit()

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):
        top = 0
        bl = True
        for x, y, h in xyh:
            if h == 0:
                continue

            top_cand = h + abs(x - cx) + abs(y - cy)

            if top == 0:
                top = top_cand
            elif top != top_cand:
                bl = False

        if bl and top:
            print(cx, cy, top)
            exit()

Submission status: Wrong Answer

Solution code:
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):

        prev = None
        flg = False
        for x, y, h in XYH:
            cur_h = h + abs(x - cx) + abs(y - cy)

            if prev is not None:
                if prev != cur_h:
                    flg = True
                    break

            prev = cur_h

        if not flg:
            print(cx, cy, cur_h)
            exit()

Submission status: Wrong Answer

Solution code:
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):

        prev = None
        flg = False
        for x, y, h in XYH:
            cur_h = max(h + abs(x - cx) + abs(y - cy), 0)

            if prev is not None:
                if prev != cur_h:
                    flg = True
                    break

            prev = cur_h

        if not flg:
            print(cx, cy, cur_h)
            exit()

Submission status: Wrong Answer

Solution code:
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):

        prev = None
        flg = False
        for x, y, h in XYH:
            if h == 0:
                continue

            cur_h = h + abs(x - cx) + abs(y - cy)

            if prev is not None:
                if prev != cur_h:
                    flg = True
                    break

            prev = cur_h

        if prev is None:
            for x, y, h in XYH:
                cur_h = h + abs(x - cx) + abs(y - cy)
                if prev is not None:
                    frg = True
                    break
                    
                prev = cur_h

        if not flg:
            print(cx, cy, cur_h)
            exit()

Submission status: Wrong Answer

Solution code:
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):

        prev = None
        flg = False
        for x, y, h in XYH:
            if h == 0:
                continue

            cur_h = h + abs(x - cx) + abs(y - cy)

            if prev is not None:
                if prev != cur_h:
                    flg = True
                    break

            prev = cur_h

        if not flg:
            print(cx, cy, cur_h)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
tmp = []
lis = []
for i in range(n):
    x,y,h = map(int,input().split())
    if h >= 1:
        tmp.append([x,y,h])
    lis.append([x,y,h])
for i in range(101): # i = x
    for j in range(101): # j = y
        flag = True
        high = tmp[0][2]+abs(i-tmp[0][0])+abs(j-tmp[0][1])
        for x,y,h in lis:
            if abs(x-i)+abs(y-j)+h!=high:
                flag = False
                break
        if flag:
            print(i,j,high)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n = int(input())
xyh = [None]*n
for i in range(n):
    x,y,h = map(int, input().split())
    xyh[i] = (x,y,h)
ans = []
x,y,h = max(xyh, key=lambda p: p[2])
for i in range(101):
    for j in range(101):
        H = h + abs(x-i) + abs(y-j)
        bad = False
        for x,y,h in xyh:
            if max(0, H - abs(x-i) - abs(y-j))!=h:
                bad = True
                break
        if bad:
            pass
        else:
            ans = (i,j,H)
            break
    if not bad:
        break
print(" ".join(map(str, ans)))

Submission status: Wrong Answer

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

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


for x in range(0, 101):
    for y in range(0, 101):
        H_less = 10**9
        H = -1
        flag = 0
        for x_, y_, h_ in xyh:
            if h_ == 0:
                H_less = min(abs(x_-x)+abs(y_-y), H_less)
            else:
                h_tmp = h_ + abs(x_-x) + abs(y_-y)
                if H != -1:
                    if H != h_tmp:
                        flag = 1
                        break
                H = h_tmp
        if flag == 1:
            continue
        # print(H, H_less)
        if H > H_less:
            continue
        print(x, y, H)
        exit()

Submission status: Wrong Answer

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

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


for x in range(0, 101):
    for y in range(0, 101):
        H_less = 100
        H = -1
        flag = 0
        for x_, y_, h_ in xyh:
            if h_ == 0:
                H_less = min(abs(x_-x)+abs(y_-y), H_less)
            else:
                h_tmp = h_ + abs(x_-x) + abs(y_-y)
                if H != -1:
                    if H != h_tmp:
                        flag = 1
                        break
                H = h_tmp
        if flag == 1:
            continue
        if H > H_less:
            continue
        print(x, y, H)
        exit()
        # print(H, H_less)

Submission status: Wrong Answer

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

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


for x in range(0, 101):
    for y in range(0, 101):
        H_less = 100
        H = -1
        flag = 0
        for x_, y_, h_ in xyh:
            if h_ == 0:
                H_less = min(abs(x_-x)+abs(y_-y), H_less)
            else:
                h_tmp = h_ + abs(x_-x) + abs(y_-y)
                if H != -1:
                    if H != h_tmp:
                        flag = 1
                        break
                H = h_tmp
        if flag == 1:
            continue
        print(x, y, H)
        # print(H, H_less)

Submission status: Wrong Answer

Solution code:
N, *XYH = map(int, open(0).read().split())
XYH = [(x, y, h) for x, y, h in zip(*[iter(XYH)] * 3)]
pos_i = -1
for i, (_, _, h) in enumerate(XYH):
    if h > 0:
        pos_i = i
        break
for i in range(101):
    for j in range(101):
        t_x, t_y, t_h = XYH[pos_i]
        tmp_summit = t_h + abs(i - t_x) + abs(j - t_y)
        for x, y, h in XYH:
            if h > 0 and tmp_summit - h != abs(i - x) + abs(j - y):
                break
            elif h == 0 and tmp_summit < abs(i - x) + abs(j - y):
                break
        else:
            print(i, j, tmp_summit)
            exit()

Submission status: Wrong Answer

Solution code:
N, *XYH = map(int, open(0).read().split())
XYH = [(x, y, h) for x, y, h in zip(*[iter(XYH)] * 3) if h > 0]
for i in range(101):
    for j in range(101):
        summits = []
        for x, y, h in XYH:
            summits.append(h + abs(i - x) + abs(j - y))
        if all(summits[0] == summit for summit in summits):
            print(i, j, summits[0])
            exit()

Submission status: Wrong Answer

Solution code:
N, *XYH = map(int, open(0).read().split())
X = XYH[::3]
Y = XYH[1::3]
H = XYH[2::3]
for i in range(101):
    for j in range(101):
        tmp_summit = H[0] + abs(X[0] - i) + abs(Y[0] - j)
        if all(
            h == tmp_summit - abs(x - i) - abs(y - j)
            for x, y, h in zip(X[1:], Y[1:], H[1:])
        ):
            print(i, j, tmp_summit)
            exit()

Submission status: Wrong Answer

Solution code:
N, *XYH = map(int, open(0).read().split())
for i in range(101):
    for j in range(101):
        summits = []
        for x, y, h in zip(*[iter(XYH)] * 3):
            summits.append(h + abs(i - x) + abs(j - y))
        if [summits[0]] * N == summits:
            print(i, j, summits[0])
            exit()

Submission status: Wrong Answer

Solution code:
def calc_ch(cx, cy, i):
    x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
    ch = max(abs(cx-x) + abs(cy-y) + h, 0)
    if h == 0 or ch == 0:
        if i == n-1:
            ch, i = -1, -1
        else:
            ch, i = calc_ch(cx, cy, i+1)
    return ch, i


n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh = sorted(xyh, key=lambda x:(x[2]))

for cx in range(101):
    for cy in range(101):
        flg = True
        ch0, s = calc_ch(cx, cy, 0)
        # print(cx, cy, ch0)
        if ch0 == -1:
            continue
        for i in range(s,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            ch = max(abs(cx-x) + abs(cy-y) + h, 0)
            if ch == 0 and ch > abs(cx-x) + abs(cy-y):
                flg = False
                break
            if ch != ch0:
                flg = False
                break
        if flg:
            ans = cx, cy, ch0
            break
    if flg:
        break
# print(cx, cy)
print(*ans)

Submission status: Wrong Answer

Solution code:
def calc_ch(cx, cy, i):
    x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
    ch = max(abs(cx-x) + abs(cy-y) + h, 0)
    if h == 0 or ch == 0:
        if i == n-1:
            ch, i = -1, -1
        else:
            ch, i = calc_ch(cx, cy, i+1)
    return ch, i


n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh = sorted(xyh, key=lambda x:(x[2]))

for cx in range(101):
    for cy in range(101):
        flg = False
        ch0, s = calc_ch(cx, cy, 0)
        # print(cx, cy, ch0)
        if ch0 == -1:
            continue
        for i in range(s,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            ch = max(abs(cx-x) + abs(cy-y) + h, 0)
            if ch == 0 and ch > abs(cx-x) + abs(cy-y):
                break
            if ch != ch0:
                break
            if i == n-1:
                flg = True
        if flg:
            ans = cx, cy, ch0
            break
    if flg:
        break
# print(cx, cy)
print(*ans)

Submission status: Wrong Answer

Solution code:
def calc_ch(cx, cy, i):
    x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
    ch = max(abs(cx-x) + abs(cy-y) + h, 0)
    if h == 0 or ch == 0:
        if i == n-1:
            ch, i = -1, -1
        else:
            ch, i = calc_ch(cx, cy, i+1)
    return ch, i


n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh = sorted(xyh, key=lambda x:(x[2]))

for cx in range(101):
    for cy in range(101):
        flg = False
        ch0, s = calc_ch(cx, cy, 0)
        # print(cx, cy, ch0)
        if ch0 == -1:
            continue
        for i in range(s,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            if h == 0:
                continue
            ch = max(abs(cx-x) + abs(cy-y) + h, 0)
            if ch != ch0:
                break
            if i == n-1:
                flg = True
        if flg:
            anscx, anscy = cx, cy
            ansh = ch0
            break
    if flg:
        break
# print(cx, cy)
print(anscx, anscy, ansh)

Submission status: Wrong Answer

Solution code:
def calc_ch(cx, cy, i):
    x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
    ch = max(abs(cx-x) + abs(cy-y) + h, 0)
    if h == 0 or ch == 0:
        if i == n-1:
            ch, i = -1, -1
        else:
            ch, i = calc_ch(cx, cy, i+1)
    return ch, i


n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh = sorted(xyh, key=lambda x:(x[2]))

for cx in range(101):
    for cy in range(101):
        flg = False
        ch0, s = calc_ch(cx, cy, 0)
        # print(cx, cy, ch0)
        if ch0 == -1:
            continue
        for i in range(s,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            if h == 0:
                continue
            ch = max(abs(cx-x) + abs(cy-y) + h, 0)
            if ch != ch0:
                break
            if i == n-1:
                flg = True
        if flg:
            anscx, anscy = cx, cy
            ansh = ch0
            break
    if flg:
        break
# print(cx, cy)
print(anscx, anscy, ch0)

Submission status: Wrong Answer

Solution code:
n = int(input())
coord = []

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

flag = False

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        H = coord[0][0] + abs(coord[0][1] - cx) + abs(coord[0][2] - cy)

        for i in range(1, n):
            if coord[i][0] > 0 and H != coord[i][0] + abs(coord[i][1] - cx) + abs(
                coord[i][2] - cy
            ):
                flag = False

            if coord[i][0] == 0 and H > abs(coord[i][1] - cx) + abs(coord[i][2] - cy):
                flag = False

        if flag is True:
            print(cx, cy, H)
            exit(0)

print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
coord = []

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

coord.sort()

flag = False

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        H = coord[0][0] + abs(coord[0][1] - cx) + abs(coord[0][2] - cy)

        for i in range(1, n):
            if coord[i][0] > 0 and H != coord[i][0] + abs(coord[i][1] - cx) + abs(coord[i][2] - cy):
                flag = False
            
            if coord[i][0] == 0 and H > abs(coord[i][1] - cx) + abs(coord[i][2] - cy):
                flag = False

        if flag is True:
            print(cx, cy, H)
            exit(0)

print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
coord = []

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

coord.sort()

flag = False

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        H = coord[0][0] + abs(coord[0][1] - cx) + abs(coord[0][2] - cy)

        for i in range(1, n):
            if H != coord[i][0] + abs(coord[i][1] - cx) + abs(coord[i][2] - cy):
                flag = False
                break

        if flag is True:
            print(cx, cy, H)
            exit(0)

print(-1)