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

info_list = []

def abs(x):
    if x < 0:
        return -x
    else:
        return x

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

def solve():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            flag = True
            H = -1
            for x, y, h in info_list:
                #print(x, y, h)
                if h > 0:
                    if H == -1:
                        H = h + abs(x - Cx) + abs(y - Cy)
                    else:
                        if H != h + abs(x - Cx) + abs(y - Cy):
                            flag = False
                            break
                else:
                    if 0 <= abs(x - Cx) + abs(y - Cy):
                        flag = False
                        break
            if flag:
                print(Cx, Cy, H)
                return

solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
x=[]
y=[]
h=[]
for i in range(0,n):
    a,b,c = map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
 
 
 
for i in range(0,101):
    for j in range(0,101):
        tmph=0
        flag = True
        for k in range(0,n):
            if tmph == 0 and h[k] != 0:
                tmph=abs(x[k]-i)+abs(y[k]-j)+h[k]
            calch = abs(x[k]-i)+abs(y[k]-j)+h[k]
            if tmph != calch and h[k] != 0:
                flag = False
                break
        if flag == False:
            continue
        elif tmph == 0:
            flag2 = True
            for c in range(0,101):
                if i == x[c] and j == y[c]:
                    flag2 = False
                    break
            if flag2:
                ansx = i
                ansy = j
                ansh = 1
        else:
            ansx=i
            ansy=j
            ansh=tmph
 
print(ansx,ansy,ansh)

Submission status: Wrong Answer

Solution code:
n = int(input())
X = [[int(i) for i in input().split()] for j in range(n)]

x_s = 0
x_e = 100
y_s = 0
y_e = 100

for x, y, z in X:
    for x2, y2, z2 in X:
        if (x, y) == (x2, y2):
            continue
        d = abs(x-x2) + abs(y-y2)
        if d == z - z2:
            if x != x2:
                if x <= x2:
                    x_e = min(x_e, x) #左側
                else:
                    x_s = max(x_s, x) #右側
            if y != y2:
                if y <= y2:
                    y_e = min(y_e, y) #上川
                else:
                    y_s = max(y_e, y) #下側

        else:
            if x != x2:
                if x <= x2:
                    x_s = max(x_s, x) #左側
                else:
                    x_e = min(x_e, x) #右側
            if y != y2:
                if y <= y2:
                    y_s = max(y_e, y) #上川
                else:
                    y_e = min(y_e, y) #下側

x, y, z = X[0]
print(x_s, y_s, z + abs(x_s - x) + abs(y_s - y))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff = 0
if max(h)-min(h)==0 and min(h)>=204:
    diff=min(h)-5
h=[i-diff for i in h]
# print(h)
def pattern(cx,cy,H):
    for i in range(n):
        # print(cx,x[i],cy,y[i],H,h[i],max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

X = [None] * N
Y = [None] * N
H = [None] * N

x_max = 0
y_max = 0
h_max = 0
R = []

for n in range(N):
    X[n], Y[n], H[n] = map(int, input().split())
    if h_max <= H[n]:
        x_max, y_max, h_max = X[n], Y[n], H[n]

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True
        for n in range(N):
            if n == 0:
                ch = H[n] + abs(X[n] - cx) + abs(Y[n] - cy)
            if max(ch - abs(X[n] - cx) - abs(Y[n] - cy), 0) != H[n]:
                flag = False
                break
        if flag == True:
            R.append([cx, cy, ch])

if len(R) > 0:
    print(R[0][0], R[0][1], R[0][2])
else:
    print(x_max, y_max, h_max)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
x = 0
y = 0
while y <= 100:
  x = 0
  while x <= 100:
    lis = []
    lis2 = []
    for arrays in grid:
      if arrays[2]>=1:
        lis.append(arrays[2]+abs(x-arrays[0])+abs(y-arrays[1]))
        lis2.append(arrays)
    if len(lis)>=2 and min(lis)==max(lis):
      print(x,y,max(0,arrays[2]+abs(x-arrays[0])+abs(y-arrays[1])))
      sys.exit()
    x += 1
  y += 1

Submission status: Wrong Answer

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

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

for cx in range(101):
    for cy in range(101):
        hight = abs(cx-x[0]) + abs(cy-y[0]) + h[0]
        flag=1
        for i in range(1,n):
            if max(hight - (abs(cx-x[i]) + abs(cy-y[i])), 0) != h[i]:
                flag=0
        if flag==1:
            print("{} {} {}".format(cx, cy, hight))

Submission status: Wrong Answer

Solution code:
def H(h,cx,cy,x,y):
    return h+abs(cx-x)+abs(cy-y)

n = int(input())
arr=[]
for i in range(n):
    arr.append(list(map(int, input().split())))
isSame = True
isEnd = False
for cx in range(0,101):
    for cy in range(0,101):
        h_prev=-1
        for a in arr:
            if a[2]>=0:
                h= H(a[2],cx,cy,a[0],a[1])
                if h_prev==-1:
                    h_prev=h
                if h!=h_prev:
                    isSame=False
                    break
                else:
                    h_prev=h
        if isSame==True:
            print("{} {} {}".format(cx,cy,h))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    ex,ey,eh = map(int,input().split())
    if eh != 0:
        l.append([ex,ey,eh])

def func(cx,cy,l1,l2):
    ans1 = -abs(l1[0]-cx)+abs(l2[0]-cx)-abs(l1[1]-cy)+abs(l2[1]-cy)
    ans2 = l1[2]-l2[2]
    if ans1 == ans2:
        return True
    else:
        return False

def func2(cx,cy,l):
    ans = l[2] + abs(l[0]-cx) +  abs(l[1]-cy)
    return ans

cx = -1
cy = -1
flag = False
for i in range(101):
    for j in range(101):
        for k in range(len(l)-1):
            flag2 = False
            for g in range(k+1, len(l)):
                if func(i,j,l[k],l[g]):
                    if (k == len(l)-2) and (g == len(l)-1):
                        cx = i
                        cy = j
                        flag = True
                        break
                else:
                    flag2 = True
                    break
            if flag or flag2:
                break
        if flag:
            break
    if flag:
        break
h = func2(cx,cy,l[0])

print(cx, cy, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

x=[]
y=[]
h=[]

for i in range(N):
	x_i,y_i,h_i = list(map(int,input().split()))
	x.append(x_i)
	y.append(y_i)
	h.append(h_i)

s = 0
flag = 0
x_a=0
y_a=0
h_a=0

for C_X in range(101):
	for C_Y in range(101):
		for i in range(N):
			if h[i]!=0:
				if s==0:
					s = abs(x[i]-C_X)+abs(y[i]-C_Y)+h[i]
					#print("%d %d %d set" % (C_X,C_Y,s))
				elif abs(x[i]-C_X)+abs(y[i]-C_Y)+h[i] != s:
					#print("%d %d %d failed" % (C_X,C_Y,s))
					s=0
					break
			elif abs(x[i]-C_X)+abs(y[i]-C_Y) < s:
				s=0
				break
			if i==N-1:
				h_a=s
				flag=2
				break
		if flag:
			y_a=C_Y
			break
	if flag:
		x_a=C_X
		break

print("%d %d %d" % (x_a,y_a,h_a))

Submission status: Wrong Answer

Solution code:
N = int(raw_input())

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

for Cx in range(101):
    for Cy in range(101):
        H = None
        count = 0
        for x, y, h in pairs:
            tmp_H = h + abs(x - Cx) + abs(y - Cy)
            if tmp_H <= 0 or tmp_H == H:
                count += 1
            elif H is None:
                H = tmp_H
                count += 1
            else:
                break
        if count == N:
            print '%s %s %s' % (Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
xyh = np.array([tuple(map(int, input().split())) for i in range(N)])

x_arr = xyh[:,0]
y_arr = xyh[:,1]
h_arr = xyh[:,2]

for x in range(0,101):
    for y in range(0,101):
        s = set(abs(x_arr-x) + abs(y_arr-y) + h_arr)
        if len(s) == 1:
            print(x,y,list(s)[0])

Submission status: Wrong Answer

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = None

x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H = abs(c_x - x) + abs(c_y - y) + h
                elif H != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if len(x_y_h_tmp) == len([xyh for xyh in x_y_h if abs(c_x - xyh[0]) + abs(c_y - xyh[1] + xyh[2]) >= 0]):
                    Cx = c_x
                    Cy = c_y
                    print("{0} {1} {2}".format(Cx, Cy, H))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product

for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            break
print(cx,cy,np.max(temp2[h > 0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
x, y, h = [], [], []
x2, y2, h2 = [], [], []
for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi == 0:
        x2.append(xi)
        y2.append(yi)
        h2.append(hi)
    else:
        x.append(xi)
        y.append(yi)
        h.append(hi)


def fn(H, X, Y, Cx, Cy):
    return H + abs(Cx - X) + abs(Cy - Y)

heights = []
for Cx in range(101):
    for Cy in range(101):
        H = fn(h[0], x[0], y[0], Cx, Cy)
        heights.append([H, Cx, Cy])
        if len(h) == 1:
            continue
        flag = True
        for i in range(1, len(h)):
            if H != fn(h[i], x[i], y[i], Cx, Cy):
                flag = False
                break
        if flag:
            print(Cx, Cy, H)
            exit()

print(h[0])

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)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(min(X), max(X)+1):
    for Cy in range(min(Y), max(Y)+1):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and h == H[i] + abs(X[i]-Cx) + abs(Y[i]-Cy):
            i += 1
        if i == N:
            print(Cx, Cy, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

ba=[]
for i in range(N):
  x,y,h=map(int, input().split())
  ba.append(((x,y),h))
  
ba.sort(key=lambda x: x[1])
ba.reverse()
#print(ba)

if ba[0][1]-ba[1][1]==2:
  print(ba[0][0][0],end=" ")
  print(ba[0][0][1],end=" ")
  print(ba[0][1],end="")
elif ba[0][1]==ba[1][1] and ba[1][1]-ba[2][1]==1:
  
  dx=ba[0][0][0]+ba[1][0][0]/2
  dy=ba[0][0][1]+ba[1][0][1]/2
  cx=0
  if ba[2][0][0]-dx > 0:
    cx=ba[2][0][0]-1
  else:
    cx=ba[2][0][0]+1
    
  cy=0
  if ba[2][0][1]-dy > 0:
    cy=ba[2][0][1]-1
  else:
    cy=ba[2][0][1]+1
  
  ch=ba[0][1]+1
  print(cx,end=" ")
  print(cy,end=" ")
  print(ch,end="")
  
elif ba[0][1]==ba[1][1] and ba[0][1]==ba[1][1]:
  cx=round((ba[0][0][0]+ba[1][0][0]+ba[2][0][0])/3)
  cy=round((ba[0][0][1]+ba[1][0][1]+ba[2][0][1])/3)
  ch=ba[0][1]+1
  print(cx,end=" ")
  print(cy,end=" ")
  print(ch,end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
x =[]
y =[]
h =[]
for i in range(N):
    x1, y1, h1 = [int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    h.append(h1)

for i in range(101):
    for j in range(101):
        flag = True
        for k in range(N):
            if k == 0:
                temp = max(abs(x[k]-i) + abs(y[k]-j) + h[k],0)

            if temp != max(abs(x[k]-i) + abs(y[k]-j) + h[k],0):
                flag = False

        if flag == True:
            print(i,j,temp)

Submission status: Wrong Answer

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

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

def check(cx,cy):
    for i in range(n):
        x,y,h = card[i]
        if h == 100:
            print("{} {} {}".format(x,y,h))
            exit()
        if i == 0:
            H = abs(x-cx)+abs(y-cy)+h  

        if h == max((H-abs(x-cx)-abs(y-cy)),0):
            continue
        else:
            return False
    else:
        return True
    
for i in range(101):
    for j in range(101):
        if check(i,j):
            ax = i
            ay = j
            
            x1,y1,h1 = card[0]
            ah = abs(x1-i)+abs(y1-j)+h1

            print("{} {} {}".format(ax,ay,ah))
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
a = [list(map(int,input().split())) for i in range(N)]
if N == 1:
    for j in range(101):
        for k in range(101):
            first = a[0][2] + np.abs(a[0][0] - j) + np.abs(a[0][1] - k)
            if a[0][2] == np.max(first - np.abs(a[0][0] - j) - np.abs(a[0][1] - k), 0):
                print("{} {} {}\n".format(j, k, first))
    sys.exit()
    
for j in range(101):
    for k in range(101):
        first = a[0][2] + np.abs(a[0][0] - j) + np.abs(a[0][1] - k)
        for i in range(N):
            if first != a[i][2] + np.abs(a[i][0] - j) + np.abs(a[i][1] - k):
                break
        else:
            for i in range(N):
                if  a[i][2] != np.max(first - np.abs(a[i][0] - j) - np.abs(a[i][1] - k), 0):
                    break
            else:
                print("{} {} {}\n".format(j, k, first))

Submission status: Wrong Answer

Solution code:
import numpy as np

def calc(mat, h, N):
    mat = np.array(mat)
    h = np.array(h)
    #for i in range(N):

if __name__ == "__main__":
    N = int(input())
    x = []
    y = []
    h = []
    for i in range(N):
        x1, y1, h1 = [int(i) for i in input().split()]
        x.append(x1)
        y.append(y1)
        h.append(h1)
    mat = []
    for i in range(N):
        mat.append([x[i], y[i]])

    calc(mat, h, N)

Submission status: Wrong Answer

Solution code:
def get_coord(C):
    for xi in range(0, 101):
        for yi in range(0, 101):
            H = 10 ** 9 + 1
            success = True
            for i in range(0, len(C)):
                d = abs(xi - C[i][0]) + abs(yi - C[i][1])
                if i == 0:
                    th = H - d
                    H -= th - C[i][2]
                else:
                    nh = H - d
                    if nh > 0:
                        if C[i][2] == nh:
                            continue
                        else:
                            success = False
                            break
                    else:
                        if C[i][2] == 0:
                            continue
                        else:
                            success = False
                            break

            if success:
                return (xi, yi)
    return (-1, -1)


def solve(C):
    C.sort(key=lambda x: x[2])
    x, y = get_coord(C)
    for c in C:
        if c[2] != 0:
            h = abs(x - c[0]) + abs(y - c[1]) + c[2]
            return [str(x), str(y), str(h)]


if __name__ == "__main__":
    N = int(input())
    C = []
    for n in range(N):
        d = input().split(" ")
        C.append((int(d[0]), int(d[1]), int(d[2])))
    print(" ".join(solve(C)))

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = []
for cx in range(101): #Cx 0~100
    for cy in range(101): #Cy 0~100
        h = []
        for i in range(n):
            #x[i], y[i], h[i]のときの高さHを求める
            #H = |x[i] - Cx| + |y[i] - Cy| + h[i]
            h.append(max(abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2], 0))

        # Hがすべて一致するときのCx, Cyが答えである
        if len(set(h)) == 1:
            ans.append(cx)
            ans.append(cy)
            ans.append(h[0])
            print(ans[0], ans[1], ans[2])

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
for i in range(N):
  x1=list(map(int,input().split()))
  list1.append(x1)
flag=0
for i in range(101):
  for j in range(101):
    list2=[]
    for k in range(N):
      Hx=list1[k][2]+abs(list1[k][0]-i)+abs(list1[k][1]-j)
      if Hx-abs(list1[k][0]-i)-abs(list1[k][1]-j)<0:
        continue
      else:
        list2.append(Hx)
    if len(set(list2))==1:
      list3=[0]
      for l in range(N):
         d=Hx-abs(list1[l][0]-i)-abs(list1[l][1]-j)
         list3.append(d)
      if min(list3)>=0:
         print(i,j,Hx)
         flag=1
      else:
        pass
    else:
      pass
    if flag==1:
      break
  if flag==1:
    break

Submission status: Wrong Answer

Solution code:
def cal(X,Y,H):

    zerolist=[]
    for i in range(0,101): #C_x
        for j in range(0,101): #C_y
            temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
            for l in range(1,N):
                if(H[l]<0):
                    zerolist.append(l)
                else:
                    s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                    if(temp==s):
                        temp=s
                    else:
                        break
            else:
                for k in zerolist:
                    if(temp-abs(X[k]-i)-abs(Y[k]-j)>0):
                        break
                else:
                    return print("{} {} {}".format(i,j,temp))
N=int(input())
X=[]
Y=[]
H=[]
for i in range(N):
    x,y,h=list(map(int,input().split()))
    X.append(x)
    Y.append(y)
    H.append(h)
cal(X,Y,H)

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        H = 0
        for l in lst:
            if l[2] != 0:
                if H == 0:
                    H = abs(cx-l[0]) + abs(cy-l[1]) + l[2]
                elif abs(cx-l[0]) + abs(cy-l[1]) + l[2] != H:
                    break
        else:
            print(cx, cy, H)
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())

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

for Cx in range(101):
    for Cy in range(101):
        H = None
        count = 0
        for x, y, h in pairs:
            tmp_H = h + abs(x - Cx) + abs(y - Cy)
            if tmp_H == 0 or tmp_H == H:
                count += 1
            elif H is None:
                H = tmp_H
                count += 1
            else:
                break
        if count == N:
            print '%s %s %s' % (Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
C = [(x, y) for x in range(101) for y in range(101)]
p = [list(map(int, input().split())) for _ in range(N)]
ans = []
def find(H):
    for cx in range(101):
        for cy in range(101):
            for x, y, h in p:
                if h > max(H - abs(x - cx) - abs(y - cy), 0):
                    break
            else:
                return True
    return False

lo = 0
hi = 10 ** 9
while hi - lo > 1:
    mid = (hi + lo) // 2
    if find(mid):
        hi = mid
    else:
        lo = mid

for cx in range(101):
    for cy in range(101):
        for x, y, h in p:
            if h != max(hi - abs(x - cx) - abs(y - cy), 0):
                break
        else:
            print(cx, cy, hi)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

info_list = []

def abs(x):
    if x < 0:
        return -x
    else:
        return x

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

def solve():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            flag = True
            H = -1
            for x, y, h in info_list:
                #print(x, y, h)
                if h > 0:
                    if H == -1:
                        H = h + abs(x - Cx) + abs(y - Cy)
                    else:
                        if H != h + abs(x - Cx) + abs(y - Cy):
                            flag = False
                            break
                else:
                    if 1 <= abs(x - Cx) + abs(y - Cy):
                        flag = False
                        break
            if flag:
                print(Cx, Cy, H)
                return

solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for _ in range(n)]
xyh = sorted(xyh, reverse = True, key = lambda z: z[2])
# print(xyh)

for i in range(101):
    for j in range(101):
        x_0, y_0, h_0 = xyh[0]
        H = h_0 + abs(y_0-i) + abs(x_0-j)
        valid = True
        for x, y, h in xyh[1:]:
            if h == 0:
                continue
            if h+abs(y-i)+abs(x-j) != H:
                valid = False
                break
        if valid:
            ans = str(j)+' '+str(i)+' '+str(H)
            print(ans)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
infos = [[int(v) for v in input().split()] for _ in range(N)]

LEN = 101

field = [[0 for _ in range(LEN)] for __ in range(LEN)]

def predict_h(info,xy):
    return info[2] + abs(info[0] - xy[0]) + abs(info[1] - xy[1])

def distance(xy,info):
    return abs(xy[0] - info[0]) + abs(xy[1] - info[1])

ans = [0,0,0]

for i in range(LEN):
    for j in range(LEN):

        flag = True
        height = predict_h(infos[0],[i,j])
        for info in infos:
            if height - distance(info,(i,j)) == info[2] :
                continue
            else:
                flag = False
                break
            
        
        
        if flag:
            if height >= ans[2]:
                ans = [i,j,height]

        

            
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff=min(min(h),max(h)-min(h))
h=[i-diff for i in h]
# print(h)
def pattern(cx,cy,H):
    for i in range(n):
        # print(cx,x[i],cy,y[i],H,h[i],max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Submission status: Wrong Answer

Solution code:

def check(cx, cy, H, x, y, h):
    if (h == 0) and (abs(cx-x)+abs(cy-y) > H):
        return True
    if H-h == abs(cx-x)+abs(cy-y):
        return True
    else:
        return False

def a():
    N = int(input())
    xs = []
    ys = []
    hs = []
    for _ in range(N):
        i = input().split(' ')
        xs.append(int(i[0]))
        ys.append(int(i[1]))
        hs.append(int(i[2]))
    for cx in range(101):
        for cy in range(101):
            H = abs(cx-xs[0])+abs(cy-ys[0])+hs[0]
            #print('{} {} {}'.format(cx, cy, H))
            flag_stop = False
            for x, y, h in zip(xs, ys, hs):
                if not check(cx, cy, H, x, y, h):
                    flag_stop = True
                    break
            if flag_stop:
                continue
            else:
                print('{} {} {}'.format(cx, cy, H))
                return
a()

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = [list(map(lambda x:int(x),input().split())) for i in range(n)]
lists2 = []
for i in range(n):
    lists2.append(lists[i][2])
for i in range(101):
    for j in range(101):
        if lists[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i)>=1:
            H = lists[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i)
            for k in range(1,n):
                if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) >0:
                    if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) != H:
                        break
                    else :
                        if k == n-1 and max(lists2) <= H :
                            print(i,j,lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i))

Submission status: Wrong Answer

Solution code:
N = int(input())
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))
H = 0
h = 0
flag = False
for i in range(101):
    for j in range(101):
        H = xyz[0][2] + abs(xyz[0][0]-i) + abs(xyz[0][1]-j)
        for k in xyz:
            h = H -abs(k[0]-i)-abs(k[1]-j)
            if h < 0:
                h = 0
            if h == k[2]:
                continue
            else:
                break
        else:
            if H != 0:
                flag = True
                print("{} {} {}".format(i, j, H))
                break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
n = int(input())

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)
    
end = 0
if n >=3:
    for x in range(101):
        for y in range(101):
            H = info[0][2] + abs(x-info[0][0]) + abs(y-info[0][1])
            if info[1][2] == H - abs(x-info[1][0]) - abs(y- info[1][1]) and info[2][2] == H - abs(x-info[2][0]) - abs(y- info[2][1]):
                end = 1
                print(x,y,H)
                break
        if end == 1:
            break
elif n ==2:
    info = sorted(info, key = lambda x:x[2])
    if info[0][0] > info[1][0]:
        h = info[1][2] + info[1][0]
        x = 0
    else:
        h = info[1][2] + 100- info[1][0]
        x = 100
    if info[0][1] > info[1][1]:
        h += info[1][1]
        y = 0
    else:
        h += 100 - info[1][1]
        y =100
    ans = list(map(str,(x,y,h)))
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
#x = []
#y = []
#h = []
l = []
for i in range(n):
    ex,ey,eh = map(int,input().split())
    #x.append(ex)
    #y.append(ey)
    #h.append(eh)
    if eh != 0:
        l.append([ex,ey,eh])

def func(cx,cy,l1,l2):
    ans1 = -abs(l1[0]-cx)+abs(l2[0]-cx)-abs(l1[1]-cy)+abs(l2[1]-cy)
    ans2 = l1[2]-l2[2]
    if ans1 == ans2:
        return True
    else:
        return False

def func2(cx,cy,l):
    ans = l[2] + abs(l[0]-cx) +  abs(l[1]-cy)
    return ans

cx = -1
cy = -1
flag = False
for i in range(101):
    for j in range(101):
        for k in range(len(l)-1):
            if func(i,j,l[k],l[k+1]):
                if k == len(l)-2:
                    cx = i
                    cy = j
                    flag = True
                    break
            else:
                break
        if flag:
            break
    if flag:
        break
h = func2(cx,cy,l[0])

print(cx, cy, h)

Submission status: Wrong Answer

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

# 中心座標(Cx,Cy)を全通り試す
for Cx in range(101):
    for Cy in range(101):
        Hs = [h + abs(Cx - x) + abs(Cy - y) for x, y, h in xyhs]
        if len(set(Hs)) == 1:
            print(Cx, Cy, Hs[0])
            exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xi, yi, hi = list(map(int, input().split()))
    x.append(xi)
    y.append(yi)
    h.append(hi)


for cx, cy in itr.product(range(101),range(101)):
    hh = set([])  
    for i in range(n):
        if h[i] > 0:
            hh.add(abs(x[i]-cx)+abs(y[i]-cy)+h[i])
            #print(cx, cy, i, hh)
            if  len(hh) > 1:
                break
    else:
        if len(hh) == 1:
            print(cx, cy, hh.pop())
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = set()
for i in range(N):
    tmp = set()
    x, y, h = map(int, input().split())
    for cx in range(0,101):
        for cy in range(0, 101):
            ch = abs(x-cx) + abs(y-cy) + h
            if ch < 1:
                continue
            tmp.add((cx, cy, ch))
    if ans == set():
        ans = tmp
        continue
    # elif tmp == set():
    #     continue
    ans = ans & tmp
if ans == set():
    print(0, 0, 1)
else:
    ans = list(ans)[0]
    print(ans[0], ans[1], ans[2])