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())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
def dist(cx,cy,x,y):
    return(abs(cx-x)+abs(cy-y))
for cx in range(cm+1):
    for cy in range(cm+1):
        H = -1
        Hm = 10000000000
        contra = False
        for i in range(N):
            Hi = h[i] + dist(cx,cy,x[i],y[i])
            if h[i] == 0:
                Hm = min(Hi,Hm)
                if H != -1 and H < Hm:
                    contra = True
            else:
                if Hi > Hm:
                    contra = True
                else:
                    Hm = min(Hm,Hi)
                if H == -1:
                    H = Hi
                else:
                    if H!=Hi:
                        contra = True
        if contra == False:
            if H!=-1:
                print(cx,cy,H)                
            else:
                print(cx,cy,Hm)
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
N =int(input())
co = []
for i in range(N):
    co.append(list(map(int,input().split())))
inv = []
kotae =[]
for i in range(101):
    for j in range(101):
        for l in range(N):
            x = co[l][0]
            y = co[l][1]
            h = co[l][2]
            dis = abs(i-x) +abs(j-y)
            inv.append(dis + h)
        if inv.count(inv[0]) == N:
            print(i,j,dis + h)
            inv=[]
        else:
            inv = []

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
def dist(cx,cy,x,y):
    return(abs(cx-x)+abs(cy-y))
for cx in range(cm+1):
    for cy in range(cm+1):
        H = -1
        Hm = 10000000000
        contra = False
        for i in range(N):
            Hi = h[i] + dist(cx,cy,x[i],y[i])
            if h[i] == 0:
                Hm = min(Hi,Hm)
                if H != -1 and H < Hm:
                    contra = True
            else:
                if Hi > Hm:
                    contra = True
                else:
                    Hm = min(Hm,Hi)
                if H == -1:
                    H = Hi
                else:
                    if H!=Hi:
                        contra = True
        if contra == False:
            print(cx,cy,H)                
            exit()

Submission status: Wrong Answer

Solution code:
import itertools

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)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n):
            if max(H[0] - abs(x[i] - cx) - abs(y[i] - cy), 0) != h[i]:
                continue
        break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
arr = np.array(arr)

mx = arr[:,1:].max()
for i in range(101):
    for j in range(101):
        for k in range(mx,mx+19):
            flag = True
            for ls in arr:
                if(k-abs(i-ls[0])-abs(j-ls[1])!=ls[2]):
                    break
            else:
                print (i,j,k)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
def dist(cx,cy,x,y):
    return(abs(cx-x)+abs(cy-y))
for cx in range(cm+1):
    for cy in range(cm+1):
        H = -1
        Hm = 10000000000
        contra = False
        for i in range(N):
            Hi = h[i] + dist(cx,cy,x[i],y[i])
            if h[i] == 0:
                Hm = min(Hi,Hm)
                if H != -1 and H < Hm:
                    contra = True
            if h[i] != 0:
                if Hi > Hm:
                    contra = True
                else:
                    Hm = Hi
                if H == -1:
                    H = Hi
                else:
                    if H!=Hi:
                        contra = True
        if contra == False:
            print(cx,cy,H)                
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if l==k or l==0:
            l=k
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else: break
    try:
        print('{} {} {}'.format(m[0],m[1],m[2]))
        break
    except NameError:
        continue

Submission status: Wrong Answer

Solution code:
import sys
N = int(input().strip())
grid = []
ref = 0
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
    if array[2]>0:
      ref = i
x = 0
y = 0
while y <= 100:
  x = 0
  while x <= 100:
    flag = 0
    h0 = grid[ref][2]+abs(x-grid[ref][0])+abs(y-grid[ref][1])
    for arrays in grid:
      h = h0-abs(x-arrays[0])-abs(y-arrays[1])
      if h != arrays[2]:
        flag = 1
    if flag == 0:
      print(x,y,h0)
      sys.exit()
    x += 1
  y += 1

Submission status: Wrong Answer

Solution code:
N = int(input())

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []
first = True

for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        xy = tmpxy
        H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

Submission status: Wrong Answer

Solution code:
import itertools

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)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        if 0 in h:
            if H[0] <= 200:
                break
        else:
            break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
if n>=4:
  for x in range(101):
    for y in range(101):
      a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
      c=0
      for z in range(1,n):
        if l[z][2]==0:c+=1
        if l[z][2]>0 and abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]==a:c+=1
        if c==n-1:
          print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
          break
else:
  for x in range(101):
    for y in range(101):
      a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
      c=0
      for z in range(1,n):
        if abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]==a:c+=1
        if c==n-1:
          print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
          break

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
def dist(cx,cy,x,y):
    return(abs(cx-x)+abs(cy-y))
for cx in range(cm+1):
    for cy in range(cm+1):
        H = -1
        Hm = 1000000000
        contra = False
        for i in range(N):
            Hi = h[i] + dist(cx,cy,x[i],y[i])
            if h[i] == 0:
                Hm = min(Hi,Hm)
                if H != -1 and H < Hm:
                    contra = True
                    break
            if h[i] != 0:
                if Hi > Hm:
                    contra = True
                    break
                else:
                    Hm = Hi
                if H == -1:
                    H = Hi
                else:
                    if H!=Hi:
                        contra = True
                        break
        if contra == False:
            print(cx,cy,H)                
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = [list(map(lambda x:int(x),input().split())) for i in range(n)]
lists2 = []
if n == 1:
    print(lists[0][0],lists[0][1],lists[0][2])
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)>0:
            H = lists[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i)
            for k in range(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[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i))
                elif 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[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i))

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

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

def abs(n):
    n = int(n)
    if n >= 0:
        return n
    else:
        return -n
j = 0
C_x = 0
C_y = 0
while(j == 0):
    H = abs(L[0][0] - C_x) + abs(L[0][1] - C_y) + L[0][2]
    for i in L:
        if  H - abs(i[0] - C_x) - abs(i[1] - C_y) > 0:
            if i[2] == H - abs(i[0] - C_x) - abs(i[1] - C_y):
                j = 1
            else:
                j = 0
                if C_x == 100:
                    C_x = 0
                    C_y += 1
                else:
                    C_x += 1
                break
        elif i[2] == 0:
            j = 1

print(C_x, end=' ')
print(C_y, end=' ')
print(H)

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)

hlist = []
argx = []
argy = []
for k in range(N):
    tmplist = []
    tmpx = []
    tmpy = []
    for i in range(101):
        for j in range(101):
            tmplist.append(max(h[k] +abs( x[k] - i ) + abs (y[k]  - j),0))
            tmpx.append(i)
            tmpy.append(j)

    hlist.append(tmplist)
    argx.append(tmpx)
    argy.append(tmpy)

for i in range(10201):
        lis = []
        for k in range(N):
            lis.append(hlist[k][i])
        if lis.count(hlist[k][i]) == N:
            print(argx[k][i],argy[k][i],hlist[k][i],sep=" ")
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
    c=0
    for z in range(1,n):
      if l[z][2]==0:c+=1
      if l[z][2]>0 and abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]==a:c+=1
      if c==n-1:
        print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
        break

Submission status: Wrong Answer

Solution code:
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    
    if hi==0:
        xymap[xi][yi]=-2
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]<=a:
                    pass
                else:
                    xymap[x][y]=-2
    else:
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])

Submission status: Wrong Answer

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

halt = False
for i in range(100+1):
    for j in range(100+1):
        x, y, h = data[0]
        H = h + abs(x - i) + abs(y - j)
        for x, y, h in data[1:]:
            if h != max(0, H - abs(x- i) - abs(y - j)):
                break
        else:
            print(i, j, H)
            halt = True
        if halt:
            break
    if halt:
        break

Submission status: Wrong Answer

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


for i in range(101):
	for j in range(101):
		height = abs(i-x[0]) + abs(j-y[0]) + h[0]
		flag = 0
		for k in range(n):	#h=0なる場合を考慮していない。
			
			if h[k] != max(height-( abs(i-x[k]) + abs(j-y[k]) ), 0):
				flag = 1
				break
			
		if flag == 0:
			ans = [i,j,height]
			break
		
	
print('{0} {1} {2}'.format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = []
ans_c = 0
for i in range(101):
    for j in range(101):
        H = -1
        judge = True
        for k in range(N):
            if info[k][2] == 0:
                continue
            dis = abs(i - info[k][0]) + abs(j - info[k][1])
            if H == -1:
                H = info[k][2] + dis
            else:
                if H != (info[k][2] + dis):
                    judge = False
        if judge == True:
            ans_c += 1
            add_data = [i,j,H]
            ans.append(add_data)


for i in range(ans_c):
    judge = True
    for k in range(N):
        judge = True
        if info[k][2] == 0:
            h = max(ans[i][0] - (abs(ans[i][0] - info[k][0]) + abs(ans[i][1] - info[k][1])),0)
            if h != 0:
                judge = False
    if judge == True:
        ans[0][0] = ans[i][0]
        ans[0][1] = ans[i][1]
        ans[0][2] = ans[i][2]
print("{} {} {}".format(ans[0][0],ans[0][1],ans[0][2]))

Submission status: Wrong Answer

Solution code:
n = int(input())
ma = []
for i in range(101):
    ma.append([0] * 101)
for i in range(n):
    x, y, h = map(int, input().split())
    if i == 0:
        for j in range(101):
            for k in range(101):
                ma[j][k] = h + abs(j - x) + abs(k - y)
    else:
        for j in range(101):
            for k in range(101):
                if ma[j][k] == h + abs(j - x) + abs(k - y) or ma[j][k] - abs(j - x) - abs(k - y) <= 0 == h:
                    k = k
                else:
                    ma[j][k] = 0
ans = 0
for i in range(101):
    if sum(ma[i]) != 0:
        print(i, ma[i].index(sum(ma[i])), sum(ma[i]))
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []
first = True
for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
    w=0
    for z in range(1,n):
      if l[z][2]>0 and abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]!=a:
        w=0
        break
      else:w=1
      if w==1:
        print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
        break

Submission status: Wrong Answer

Solution code:
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    
    if hi==0:
        xymap[xi][yi]=-2
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]<=a and xymap[x][y]!=-2:
                    pass
                else:
                    xymap[x][y]=-2
    else:
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])

Submission status: Wrong Answer

Solution code:
N = int(input())

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []

for i, xyh in enumerate(in_list):
    x, y, h = xyh[0], xyh[1], xyh[2]
    if i == 0:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
xyh0 = []
for i in range(0,n):
    X,Y,h = map(int,input().split())
    if h != 0:
        xyh.append((X,Y,h))
    else:
        xyh0.append((X,Y))
ans = []
for i in range(0,101):
    for j in range(0,101):
        flag = "f"
        if len(xyh)>0:
            x,y,h = xyh[0]
            H = h + abs(x-i)+abs(y-j)
            flag = "t"
        for x,y,h in xyh:
            if H !=  h + abs(x-i)+abs(y-j):
                flag = "f"
                break
        if flag == "t":
            ans.append((i,j,H))
if len(ans) > 0:
    for i,j,H in ans:
        flag = "t"
        for x,y in xyh0:
            if H < h + abs(x-i)+abs(y-j):
                flag = "f"
                break
        if flag == "t":
            ans = [(i,j,H)]
        if len(ans) == 1:
            break
x,y,h = ans[0]
print(x,y,h)













#

Submission status: Wrong Answer

Solution code:
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

x, y, h = P[-1]
max_h = h + 200
max_h = min(max_h, 10**9)

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h, P[-1][2]-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            th = max(hh-dx-dy, 0)
            if th != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
num = [[-1] * 101 for i in range(101)]
for i in range(n):
  a = list(map(int,input().split()))
  lis.append(a)
  num[a[0]][a[1]] = a[2]
for x in range(101):
  for y in range(101):
    if num[x][y] != -1:
      nu = num[x][y]
    else:
      cou = 0
      while abs(x-lis[cou][0])+abs(y-lis[cou][1])+lis[cou][2] <= 0:
        cou += 1
      nu = abs(x-lis[cou][0])+abs(y-lis[cou][1])+lis[cou][2]

    for i in range(n):
      if nu != abs(x-lis[i][0])+abs(y-lis[i][1])+lis[i][2]:
        break
      if i == n-1:
        print(x,y,nu)

Submission status: Wrong Answer

Solution code:
N = int(input())

X = []
Y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())

    X.append(a)
    Y.append(b)
    h.append(c)

for Cx in range(101):
    p = False
    for Cy in range(101):
        w = True
        previous = 1
        for i in range(N):
            H = h[i] + abs(X[i] - Cx) + abs(Y[i] - Cy)

            if h[i] > 0:
                if previous == 1:
                    previous = H
                elif H != previous:
                    w = False
                    break
        
        if w:
            answer = [Cx,Cy,H]
            p = True
            break

    if p:
        break

print(answer[0],answer[1],answer[2])

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
s_max=2000000000
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
					s_max=20000
					break
			else:
				if abs(x[i]-C_X)+abs(y[i]-C_Y) < s_max: s_max=abs(x[i]-C_X)+abs(y[i]-C_Y)
			if s_max < s:
				s=0
				s_max=20000
				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:
xlst = []
ylst = []
hlst = []
n = range(int(input()))
for i in n:          
    xx, yy, hh = map(int, input().split())
    xlst += [xx]
    ylst += [yy]
    hlst += [hh]
for cx in range(101):
    for cy in range(101):
        hhlst = [hlst[i] + abs(xlst[i]-cx) + abs(ylst[i]-cy) for i in n]
        if len(list(set(hhlst))) == 1:
            print(cx, cy, max(hhlst))
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

x, y, h = P[-1]
max_h = h + 200
max_h = min(max_h, 10**9)

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h, P[-1][2]-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            if (h == 0 and hh > dx + dy) or hh - dx - dy != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))

Submission status: Wrong Answer

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

R.sort(reverse=True)

def solve():
    for cx in range(101):
        for cy in range(101):
            h, x, y = R[0]
            H = h + abs(x - cx) + abs(y - cy)
            for i in range(1, N):
                h, x, y = R[i]
                if h != 0:
                    tempH = h + abs(x - cx) + abs(y - cy)
                    if tempH != H:
                        break
            else:
                print(cx, cy, H)
                return

solve()

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
s_max=2000000000
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
			else:
				if abs(x[i]-C_X)+abs(y[i]-C_Y) < s_max: s_max=abs(x[i]-C_X)+abs(y[i]-C_Y)
			if s_max < s:
				s=0
				s_max=20000
				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(input())
xyh = sorted([list(map(int,input().split())) for _ in range(N)], key=lambda x:x[2], reverse=True)
N = len(xyh)

XY = [[True] * 101 for _ in range(101)]

for i in range(N-1):
    tmp = xyh[i][2] - xyh[i+1][2]
    for x in range(101):
        for y in range(101):
            if not XY[y][x]: 
                continue
            if xyh[i+1][2] != 0 and abs(x-xyh[i][0]) + abs(y-xyh[i][1]) + tmp != abs(x-xyh[i+1][0]) + abs(y-xyh[i+1][1]):
                XY[y][x] = False
            elif xyh[i+1][2] == 0 and abs(x-xyh[i][0]) + abs(y-xyh[i][1]) + tmp > abs(x-xyh[i+1][0]) + abs(y-xyh[i+1][1]):
                XY[y][x] = False

X = None
Y = None
H = 0
for x in range(101):
    for y in range(101):
        if XY[y][x] and H < abs(x-xyh[0][0]) + abs(y-xyh[0][1]) + xyh[0][2]:
            H = abs(x-xyh[0][0]) + abs(y-xyh[0][1]) + xyh[0][2]
            X = x
            Y = y

print(X,Y,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
num = [[-1] * 101 for i in range(101)]
if n == 1:
  a = list(map(int,input().split()))
  print(a[0],a[1],a[2])
  exit()
for i in range(n):
  a = list(map(int,input().split()))
  lis.append(a)
  num[a[0]][a[1]] = a[2]
for x in range(101):
  for y in range(101):
    if num[x][y] != -1:
      nu = num[x][y]
    else:
      nu = abs(x-lis[0][0])+abs(y-lis[0][1])+lis[0][2]
    for i in range(n):
      if nu != abs(x-lis[i][0])+abs(y-lis[i][1])+lis[i][2]:
        break
      if i == n-1:
        print(x,y,nu)

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
cand = []
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]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>50:
    print(x[h == 1][-1], y[h==1][-1], 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
num = [[-1] * 101 for i in range(101)]
for i in range(n):
  a = list(map(int,input().split()))
  lis.append(a)
  num[a[0]][a[1]] = a[2]
for x in range(101):
  for y in range(101):
    if num[x][y] != -1:
      nu = num[x][y]
    else:
      nu = abs(x-lis[0][0])+abs(y-lis[0][1])+lis[0][2]
    for i in range(n):
      if nu != abs(x-lis[i][0])+abs(y-lis[i][1])+lis[i][2]:
        break
      if i == n-1:
        print(x,y,nu)

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


            if flag:
                print(Cx, Cy, H)
                return

solve()

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 or h == 0:
                continue
            tmp.add((cx, cy, ch))
    if tmp == set():
        continue
    elif ans == set():
        ans = tmp
        continue
    ans = ans & tmp
ans = list(ans)[0]
print(ans[0], ans[1], ans[2])