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 i in range(N):
    xx, yy ,hh = (int(i) for i in input().split())
    X.append(xx)
    Y.append(yy)
    H.append(hh)

reslis = []
for i in range(101):
    for j in range(101):
        temp = None
        for k in range(N):
            if H[k] != 0:
                if temp and temp != abs(X[k] - i) + abs(Y[k] - j) + H[k]:
                    break
                else:
                    temp = abs(X[k] - i) + abs(Y[k] - j) + H[k]
        else:
            a, b ,c = i, j, temp

for i in H:
    if i:
        break
else:
    a, b, c = (50, 50, 100)

print("{} {} {}".format(a, b, c))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    xx, yy ,hh = (int(i) for i in input().split())
    X.append(xx)
    Y.append(yy)
    H.append(hh)

reslis = []
for i in range(101):
    for j in range(101):
        temp = None
        for k in range(N):
            if H[k] != 0:
                if temp and temp != abs(X[k] - i) + abs(Y[k] - j) + H[k]:
                    break
                else:
                    temp = abs(X[k] - i) + abs(Y[k] - j) + H[k]
        else:
            a, b ,c = i, j, temp
            reslis.append((a ,b, c))

a, b, c = reslis[-1]
print("{} {} {}".format(a, b, c))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    xx, yy ,hh = (int(i) for i in input().split())
    X.append(xx)
    Y.append(yy)
    H.append(hh)

reslis = []
for i in range(101):
    for j in range(101):
        temp = None
        for k in range(N):
            if H[k] != 0:
                if temp and temp != abs(X[k] - i) + abs(Y[k] - j) + H[k]:
                    break
                else:
                    temp = abs(X[k] - i) + abs(Y[k] - j) + H[k]
        else:
            a, b ,c = i, j, temp
            print("{} {} {}".format(a, b, c))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    xx, yy ,hh = (int(i) for i in input().split())
    X.append(xx)
    Y.append(yy)
    H.append(hh)

reslis = []
for i in range(101):
    for j in range(101):
        temp = None
        for k in range(N):
            if H[k] != 0:
                if temp and temp != abs(X[k] - i) + abs(Y[k] - j) + H[k]:
                    break
                else:
                    temp = abs(X[k] - i) + abs(Y[k] - j) + H[k]
        else:
            a, b ,c = i, j, temp
            reslis.append((a,b,c))

print(reslis[0])

Submission status: Wrong Answer

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

for i in range(100 + 1):
    for j in range(100 + 1):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if 1 > h:
            continue
        ok = True
        for k in range(1, n):
            if xyh[k][2] != max(0, h - abs(xyh[k][0] - i) - abs(xyh[k][1] - j)):
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)

Submission status: Wrong Answer

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

for i in range(100 + 1):
    for j in range(100 + 1):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if h > 1000000000 & 1 > h:
            continue
        ok = True
        for k in range(1, n):
            if xyh[k][2] != max(0, h - abs(xyh[k][0] - i) - abs(xyh[k][1] - j)):
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)

Submission status: Wrong Answer

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

for i in range(100 + 1):
    for j in range(100 + 1):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if h > 1000000000:
            continue
        ok = True
        for k in range(1, n):
            if xyh[k][2] != max(0, h - abs(xyh[k][0] - i) - abs(xyh[k][1] - j)):
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
import math, sys
n = int(input())
xyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))

for i in range(100 + 1):
    for j in range(100 + 1):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if h > 1000000000:
            continue
        ok = True
        for k in range(1, len(xyh)):
            if xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j) != h:
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
import math, sys
n = int(input())
xyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))

for i in range(100 + 1):
    for j in range(100 + 1):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if h > 100:
            continue
        ok = True
        for k in range(1, len(xyh)):
            if xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j) != h:
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
import math, sys
n = int(input())
xyh = []
for _ in range(n):
    xyh.append(list(map(int, input().split())))

for i in range(100 + 1):
    for j in range(100 + 1):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        ok = True
        for k in range(1, len(xyh)):
            if xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j) != h:
                ok = False
                break
        if ok:
            print(str(i) + ' ' + str(j) + ' ' + str(h))
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

l = []
a = {}
b = {}

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

for cx in range(100+1):
    for cy in range(100+1):
              
        count = 0
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 
            if preheight != height:
                break
            count = count + 1

        if count >= len(l) :
            if preheight in a:
                a[preheight] += 1
                b[preheight] = [cx,cy]
            else:
                a[preheight] = 1
                b[preheight] = [cx,cy]

for ans in a.keys() :
    if a[ans] == 1 :
        print(b[ans][0],b[ans][1],ans)
        exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(100+1):
    for cy in range(100+1):
              
        count = 0
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 
            if preheight != height:
                break

            count = count + 1

        if count >= len(l) :
            print(cx,cy,preheight)
            exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(100+1):
    for cy in range(100+1):
   
        if l[0][2] <= 0:
            continue
            
        count = 0
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 

            if height < 1 :
                break

            if preheight != height:
                break

            count = count + 1

        if count >= len(l) :
            print(cx,cy,preheight)
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

xyhs.sort(key=lambda x:x[2], reverse = True)
for cx in range(101):
	for cy in range(101):
		H = h + abs(x - cx) + abs(y - cy)
				
		for xyh in xyhs[1:]:
			x, y, h = xyh

			if h == 0:
				if H > abs(x - cx) + abs(y - cy):
					break
			else:
				if H != h + abs(x - cx) + abs(y - cy):
					break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
	for cy in range(101):
		H = None
				
		for xyh in xyhs:
			x, y, h = xyh

			if H is None:
				if h == 0:
					continue
				H = h + abs(x - cx) + abs(y - cy)
				continue

			if h == 0:
				if H > abs(x - cx) + abs(y - cy):
					break
			else:
				if H != h + abs(x - cx) + abs(y - cy):
					break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(100+1):
    for cy in range(100+1):
   
        count = 0
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 

            if height < 1 :
                break

            if max(height - abs(ll[0]-cx) - abs(ll[1]-cy),0) == 0:
                if ll[2] != 0 :
                    break

            if preheight != height:
                break

            preheight = height
            count = count + 1

        if count >= len(l) :
            print(cx,cy,preheight)
            exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(100+1):
    for cy in range(100+1):

        ret = True        
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 

            if height < 1 :
                ret = False
                break

            if max(height - abs(ll[0]-cx) - abs(ll[1]-cy),0) == 0:
                if ll[2] != 0 :
                    ret = False
                    break

            if preheight != height:
                ret = False
                break
            preheight = height

        if ret :
            print(cx,cy,preheight)
            exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(100+1):
    for cy in range(100+1):

        ret = True        
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 

            if height < 1 :
                ret = False
                break

            if max(height - abs(ll[0]-cx) - abs(ll[1]-cy),0) == 0:
                if ll[2] != 0 :
                    ret = False
                    break

            if preheight != height:
                ret = False
                break
            preheight = height

        if ret :
            print(cx,cy,height)
            exit(0)

Submission status: Wrong Answer

Solution code:

N = int(input())

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

xyhs.sort(key = lambda x:-x[2])

for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)
		if H >= 1:
			for xyh in xyhs[1:]:
				x, y, h = xyh
				if H != h + abs(x - cx) + abs(y - cy):
					break
			else:
				if H < 1:
					H = 1
				print(cx, cy, H)
				exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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


for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)
		if H >= 1:
			for xyh in xyhs[1:]:
				x, y, h = xyh
				if H != h + abs(x - cx) + abs(y - cy):
					break
			else:
				if H < 1:
					H = 1
				print(cx, cy, H)
				exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

if N == 1:
	x, y, h = xyhs[0]
	print(x, y, h)
	exit()

for cx in range(101):
	for cy in range(101):
		x, y, h = xyhs[0]
		H = h + abs(x - cx) + abs(y - cy)

		for xyh in xyhs[1:]:
			x, y, h = xyh
			if H != h + abs(x - cx) + abs(y - cy):
				break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
	for cy in range(101):
		H = None

		for xyh in xyhs:
			x, y, h = xyh
			if H is None:
				H = h + abs(x - cx) + abs(y - cy)
			elif H != h + abs(x - cx) + abs(y - cy):
				break
		else:
			print(cx, cy, H)
			exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
	for cy in range(101):
		H = None

		for xyh in xyhs:
			x, y, h = xyh
			if H is None:
				H = h + abs(x - cx) + abs(y - cy)
			elif H != h + abs(x - cx) + abs(y - cy):
				break
		else:
			if H < 1:
				H = 1
			print(cx, cy, H)
			exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(100+1):
    for cy in range(100+1):
        ret = True        
        preheight = abs(l[0][0]-cx) + abs(l[0][1]-cy) + l[0][2]

        for ll in l :
            height = abs(ll[0]-cx) + abs(ll[1]-cy) + ll[2] 

            if max(height - abs(ll[0]-cx) - abs(ll[1]-cy),0) == 0:
                if ll[2] != 0 :
                    ret = False
                    break

            if preheight != height:
                ret = False
                break
            preheight = height

        if ret :
            print(cx,cy,height)
            exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for cx in range(100+1):
    for cy in range(100+1):
        ret = True
        preheight = l[0][2] + abs(l[0][0]-cx) + abs(l[0][1]-cy)

        for ll in l :
            height = ll[2] + abs(ll[0]-cx) + abs(ll[1]-cy)
            if preheight != height:
                ret = False
                break
            preheight = height

        if ret :
            print(cx,cy,height)
            exit(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)

INF = float('inf')
for cx in range(101):
    for cy in range(101):
        H = INF
        Hmax = INF
        for i in range(n):
            if h[i] > 0 and H == INF:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            elif h[i] > 0 and H != h[i] + abs(x[i] - cx) + abs(y[i] - cy):
                break
            elif h[i] == 0:
                Hmax = min(Hmax, abs(x[i] - cx) - abs(y[i] - cy))
        else:
            if H <= Hmax:
                print(cx, cy, H)
                exit()
            elif H == INF and Hmax == 1:
                print(cx, cy, 1)
                exit()

Submission status: Wrong Answer

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

INF = float('inf')
for cx in range(101):
    for cy in range(101):
        H = INF
        Hmax = INF
        for i in range(n):
            if h[i]> 0 and H == INF:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            elif h[i] > 0 and H != h[i] + abs(x[i] - cx) + abs(y[i] - cy):
                break
            elif h[i] == 0:
                Hmax = abs(x[i] - cx) - abs(y[i] - cy)
        else:
            if H <= Hmax:
                print(cx, cy, H)
                exit()
            elif H == INF and Hmax == 1:
                print(cx, cy, 1)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [list(map(int, input().split())) for k in range(N)]
m = 0
for l in L:
    m = max(m,l[2])

for x in range(101):
    for y in range(101):
        for h in range(m,m+100):
            f = 1
            for l in L:
                if l[2]!=max(h-abs(l[0]-x)-abs(l[1]-y),0):
                    f = 0
                    break
            if f:
                print(x,y,h)
                exit(0)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        for h in range(201):
            f = 1
            for l in L:
                if l[2]!=max(h-abs(l[0]-x)-abs(l[1]-y),0):
                    f = 0
            if f:
                print(x,y,h)
                exit(0)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xyh = []
hmax = 0
xmax = -1
ymax = -1
for _ in range(n):
    x,y,h = li()
    if h > hmax:
        hmax = h
        xmax = x
        ymax = y
        
    xyh.append((x,y,h))
    
xans = -1
yans = -1
hans = -1
flag = False
    
for x in range(101):
    for y in range(101):
        hcent = hmax + abs(xmax-x) + abs(ymax-y)
        consis = True
        
        for xi,yi,hi in xyh:
            if hi != hcent - abs(x-xi) - abs(y-yi):
                consis = False
                
        if not consis:
            continue
                
        if consis:
            xans = x
            yans = y
            hans = hcent
            
            flag = True
            break
            
    if flag:
        break
            
            
print(xans, yans, hans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xyh = []
hmax = 0
xmax = -1
ymax = -1
for _ in range(n):
    x,y,h = li()
    if h > hmax:
        hmax = h
        xmax = x
        ymax = y
        
    xyh.append((x,y,h))
    
xans = -1
yans = -1
hans = -1
    
for x in range(101):
    for y in range(101):
        hcent = hmax + abs(xmax-x) + abs(ymax-y)
        consis = True
        
        for xi,yi,hi in xyh:
            if hi != hcent - abs(x-xi) - abs(y-yi):
                consis = False
                
        if consis:
            xans = x
            yans = y
            hans = hcent
            
print(xans, yans, hans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
n=int(input())
x,y,h=map(int,input().split())
d=set([(x,y,h)])
t=(x,y,h)
for i in range(n-1):
    x,y,h=map(int,input().split())
    d.add((x,y,h))

for i in range(101):
    for j in range(101):
        f=0
        p=abs(t[0]-i)+abs(t[1]-j)+t[2]
        for k in d:
            if p-(abs(k[0]-i)+abs(k[1]-j)+k[2])<0: f=1
            #if k[2]!=0 and abs(k[0]-i)+abs(k[1]-j)+k[2]!=p: f=1
            #if k[2]==0 and abs(k[0]-i)+abs(k[1]-j)+k[2]<p: f=1
        if f==0:
            print(i,j,p)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=map(int,input().split())
d=set([(x,y,h)])
t=(x,y,h)
for i in range(n-1):
    x,y,h=map(int,input().split())
    d.add((x,y,h))

for i in range(101):
    for j in range(101):
        f=0
        p=abs(t[0]-i)+abs(t[1]-j)+t[2]
        for q,k in enumerate(d):
            if k[2]!=0 and abs(k[0]-i)+abs(k[1]-j)+k[2]!=p: f=1
            if k[2]==0 and abs(k[0]-i)+abs(k[1]-j)+k[2]<p: f=1
        if f==0:
            print(i,j,p)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=map(int,input().split())
d=set([(x,y,h)])
t=(x,y,h)
for i in range(n-1):
    x,y,h=map(int,input().split())
    d.add((x,y,h))

for i in range(101):
    for j in range(101):
        f=0
        p=abs(t[0]-i)+abs(t[1]-j)+t[2]
        for q,k in enumerate(d):
            if k[2]!=0 and abs(k[0]-i)+abs(k[1]-j)+k[2]!=p: f=1
            if k[2]==0 and abs(k[0]-i)+abs(k[1]-j)+k[2]>p: f=1
        if f==0:
            print(i,j,p)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=map(int,input().split())
d=set([(x,y,h)])
t=(x,y,h)
for i in range(n-1):
    x,y,h=map(int,input().split())
    d.add((x,y,h))

for i in range(101):
    for j in range(101):
        f=0
        p=abs(t[0]-i)+abs(t[1]-j)+t[2]
        for q,k in enumerate(d):
            if q==0: f=0
            if abs(k[0]-i)+abs(k[1]-j)+k[2]!=p: f=1
            if q==n-1 and f==0:
                print(i,j,p)
                exit()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            ll = []
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h == 0:
                    ll.append([x,y,h])
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    if H < 1 or H != int(H):
                        break
                    continue
                if h != max((H - abs(x-cx) - abs(y-cy)), 0):
                    break
                if i == len(l) - 1:
                    for xx,yy,hh, in ll:
                        if hh != max((H - abs(xx-cx) - abs(yy-cy)), 0):
                            break
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=map(int,input().split())
d=set([(x,y,h)])
t=(x,y,h)
for i in range(n-1):
    x,y,h=map(int,input().split())
    d.add((x,y,h))

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            H = -1
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if H == -1 and h < 0:
                    continue
                if H == -1:
                    H = h + abs(x-cx) + abs(y-cy)
                    continue
                if H < 1 or H != int(H) or (h > 0 and h != H - abs(x-cx) - abs(y-cy)) or (h == 0 and h > H - abs(x-cx) - abs(y-cy)):
                    break
                if i == len(l) - 1:
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=map(int,input().split())
d=set([(x,y,h)])
t=(x,y,h)
for i in range(n-1):
    x,y,h=map(int,input().split())
    d.add((x,y,h))

for i in range(5):
    for j in range(5):
        f=0
        p=abs(t[0]-i)+abs(t[1]-j)+t[2]
        for k in d:
            if abs(k[0]-i)+abs(k[1]-j)+k[2]!=p:
                f=1
                break
        if f==0:
            print(i,j,p)
            exit()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if i == 0:
                    H = h + abs(x-cx) + abs(y-cy)
                    continue
                if H < 1 or H != int(H) or h != H - abs(x-cx) - abs(y-cy):
                    break
                if i == len(l) - 1:
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            for i, xyh in enumerate(l):
                x,y,h = xyh
                if i == 0:
                    H = h + abs(x-cx) + abs(y-cy)
                    continue
                if h != H - abs(x-cx) - abs(y-cy):
                    break
                if i == len(l) - 1:
                    print(cx,cy,H)
                    return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=map(int,input().split())
d=set([(x,y,h)])
t=(x,y,h)
for i in range(n-1):
    x,y,h=map(int,input().split())
    d.add((x,y,h))

for i in range(101):
    for j in range(101):
        p=abs(t[0]-i)+abs(t[1]-j)+h
        f=0
        for k in d:
            if abs(k[0]-i)+abs(k[1]-j)+k[2]!=p:
                f=1
                break
        if f==0:
            print(i,j,p)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
sample = -1
reg = -1
reg2 = 1
for i in range(0, N):
    XYH = list(map(int, input().split()))
    x.append(XYH[0])
    y.append(XYH[1])
    h.append(XYH[2])

for i in range(0, 101):
    for j in range(0, 101):
        sample = -1
        reg = -1
        reg2 = 1
        reg3 = 1
        for k in range(0, N):
            if sample == -1 and h[k] > 0:
                reg = k
                sample = h[k] + abs(x[k] - i) + abs(y[k] - j)
            elif sample != -1 and h[k] > 0:
                if h[k] + abs(x[k] - i) + abs(y[k] - j) != sample:
                    reg2 = -1
            elif sample != -1 and h[k] == 0:
                if sample - abs(x[k] - i) - abs(y[k] - j) > 0:
                    reg2 = -1
            if reg != 0 and k == N - 1:
                for l in range(k):
                    if sample - abs(x[l] - i) - abs(y[l] - j) > 0:
                        reg2 = -1
                if reg2 == 1:
                    print(i, " ", j, " ", sample)
            if reg == 0 and k == N - 1:
                if reg2 == 1:
                    print(i, " ", j, " ", sample)
            if k == N - 1 and sample == -1:
                for m in range(0, 201):
                    reg3 = 1
                    for n in range(0, N):
                        if m - abs(x[n] - i) - abs(y[n] - j) > 0:
                            reg3 = -1
                    if reg3 ==1:
                        print(i, " ", j, " ", sample)

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
sample = -1
reg = -1
reg2 = 1
for i in range(0, N):
    XYH = list(map(int, input().split()))
    x.append(XYH[0])
    y.append(XYH[1])
    h.append(XYH[2])

for i in range(0, 101):
    for j in range(0, 101):
        sample = -1
        reg = -1
        reg2 = 1
        for k in range(0, N):
            if sample == -1 and h[k] > 0:
                reg = k
                sample = h[k] + abs(x[k] - i) + abs(y[k] - j)
            elif sample != -1 and h[k] > 0:
                if h[k] + abs(x[k] - i) + abs(y[k] - j) != sample:
                    reg2 = -1
            elif sample != -1 and h[k] == 0:
                if sample - abs(x[k] - i) - abs(y[k] - j) > 0:
                    reg2 = -1
            if reg != 0 and k == N - 1:
                for l in range(k):
                    if sample - abs(x[l] - i) - abs(y[l] - j) > 0:
                        reg2 = -1
                if reg2 == 1:
                    print(i, " ", j, " ", sample)
            if reg == 0 and k == N - 1:
                if reg2 == 1:
                    print(i, " ", j, " ", sample)