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

XYH = set()
flag = True
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0 and (flag is True):
        flag = False
        ex_x = x
        ex_y = y
        ex_h = h
        continue
    XYH.add((x, y, h))

flag = False
for x in range(0, 101):
    for y in range(0, 101):
        # print(x, y)
        hight = ex_h + abs(x - ex_x) + abs(y - ex_y)
        for tx, ty, th in XYH:
            if hight != th + abs(x - tx) + abs(y - ty):
                break
        else:
            print(x, y, hight)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

XYH = set()
flag = True
for i in range(N):
    x, y, h = map(int, input().split())
    if h > 0 and flag is True:
        flag = False
        ex_x = x
        ex_y = y
        ex_h = h
        continue
    XYH.add((x, y, h))

flag = False
for x in range(0, 101):
    for y in range(0, 101):
        # print(x, y)
        hight = ex_h + abs(x - ex_x) + abs(y - ex_y)
        for tx, ty, th in XYH:
            if hight != th + abs(x - tx) + abs(y - ty):
                break
        else:
            print(x, y, hight)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

XYH = set()
for i in range(N):
    x, y, h = map(int, input().split())
    XYH.add((x, y, h))

flag = False
for x in range(0, 101):
    for y in range(0, 101):
        flag = True
        for tx, ty, th in XYH:
            if flag is True:
                flag = False
                hight = th + abs(x - tx) + abs(y - ty)
            else:
                if hight != th + abs(x - tx) + abs(y - ty):
                    break
        else:
            print(x, y, hight)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aData.sort(key=lambda x:x[2],reverse=True)

aRet = []
for cx in range(0,101) :
    for cy in range(0,101) :
        aH = []
        uH = False
        for x,y,z in aData :
            d = abs(x-cx)+abs(y-cy)
            if z > 0 :
                aH.append( z + d )
            else :
                if uH :
                    uH = min(uH,d)
                else :
                    uH = d
        bF = True
        for i in range(1,len(aH)) :
            if aH[0] != aH[i] :
                bF = False
        if uH :
            if uH < aH[0] :
                bF = False
        if bF :
            print(cx,cy,aH[0])
            exit()

Submission status: Wrong Answer

Solution code:
#N=2のときは高さHが大きい方が無条件で中心座標(一意性より)
#N=1のときはそこが中心座標
#N=3の時は
#最低点+距離=最高点の場合、その最高点が中心座標
#最低点+距離<最高点ということは起きない
#最低点+距離>最高点の場合、どこかに中心座標がある

#素直に全探索で良かった。

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

#print(l)
for i in range(101):
    for j in range(101):
        a = l[0]
        h = a[2]+abs(a[0]-i)+abs(a[1]-j)
        if h<0:
          h=0
#        print(h)
        for k in l:
            if h != k[2]+abs(k[0]-i)+abs(k[1]-j):
                break
        else:
            print(str(i)+' '+str(j)+' '+str(h))

Submission status: Wrong Answer

Solution code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(101):
	for cx in range(101):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				if len(H_list) != 0:
					h_mathematical=H_list[0]-abs(cx-x_list[i])-abs(cy-y_list[i])
					if h_mathematical > 0:
						break
		if len(H_list) == N:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

Submission status: Wrong Answer

Solution code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(101):
	for cx in range(101):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				if H > 0:
					break
		if len(H_list) == N:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

Submission status: Wrong Answer

Solution code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(N+1):
	for cx in range(N+1):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				if H > 0:
					break
		if len(H_list) == N:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

Submission status: Wrong Answer

Solution code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(N+1):
	for cx in range(N+1):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				if H > 0:
					break
		else:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

Submission status: Wrong Answer

Solution code:
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

aRet = []
for cx in range(0,101):
    for cy in range(0,101):
        aH = []
        uH = False
        for x,y,z in aData:
            d = abs(x-cx)+abs(y-cy)
            if z > 0:
                aH.append( z + d)
            else:
                if uH :
                    uH = min(uH,d)
                else:
                    uH = d
        bF = True
        for i in range(1,len(aH)):
            if aH[0] != aH[i]:
                bF = False
        if uH :
            if uH < aH[0]  :
                bF = False
        if aH[0] < 0:
                bF = False
        if bF:
            print(cx,cy,aH[0])
            exit()

Submission status: Wrong Answer

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

for h in range(101):
    for w in range(101):
        x, y, z = X[0]
        d = z + abs(x-w) + abs(y-h)
        for x, y, z in X:
            d2 = z + abs(x-w) + abs(y-h)
            if z == 0:
                if d2 < d:
                    break 
            elif d2 != d:
                break
        else:
            print(w, h, d)
            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])

flag = False

for cx in range(101):
    if flag:
        break
    for cy in range(101):
        if flag:
            break
        ll = []
        flag = True
        for i in range(N):
            x,y,h = l[i]
            if h != 0:
                ll.append(h+abs(x-cx)+abs(y-cy))
            if len(ll) >= 2:
                if ll[-2]!=ll[-1]:
                    flag = False
                    break
        

print('{} {} {}'.format(cx-1,cy-1,ll[0]))

Submission status: Wrong Answer

Solution code:
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

aRet = []
for cx in range(0,101):
    for cy in range(0,101):
        aH = []
        uH = False
        for x,y,z in aData:
            d = abs(x-cx)+abs(y-cy)
            if z > 0:
                aH.append( z + d)
            else:
                if uH :
                    uH = min(uH,d)
                else:
                    uH = d
        bF = True
        for i in range(1,len(aH)):
            if aH[0] != aH[i]:
                bF = False
        if uH :
            if uH < aH[0]  :
                bF = False
        if bF:
            print(cx,cy,aH[0])
            exit()

Submission status: Wrong Answer

Solution code:
import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]

aRet = []
for cx in range(0,101):
    for cy in range(0,101):
        aH = []
        uH = False
        for x,y,z in aData:
            d = abs(x-cx)+abs(y-cy)
            if z > 0:
                aH.append( z + d)
            else:
                if uH :
                    uH = min(uH,d)
                else:
                    uH = d
        bF = True
        for i in range(1,len(aH)):
            if aH[0] != aH[i]:
                bF = False
        if uH :
            if uH != aH[0]:
                bF = False
        if bF:
            print(cx,cy,aH[0])
            exit()

Submission status: Wrong Answer

Solution code:

import sys
iN = int(input())
aData = [[int(_) for _ in sLine.split()] for sLine in sys.stdin.readlines()]
aRet = []
for cx in range(0,101):
    for cy in range(0,101):
        aH = []
        uH = False
        for x,y,z in aData:
            d = abs(x-cx)+abs(y-cy)
            if z > 0:
                aH.append( z + d)
            else:
                if uH :
                    uH = min(uH,d)
                else:
                    uH = d
        bF = True
        for i in range(1,len(aH)):
            if aH[0] != aH[i]:
                bF = False
        if bF:
            if uH:
                if uH != aH[0]:
                    continue
            print(cx,cy,aH[0])
            exit()

Submission status: Wrong Answer

Solution code:
def calcCh(cx, cy, x, y, h):
    return abs(x-cx)+abs(y-cy)+h
def calcH(cx, cy, ch, x, y, h):
    return max(ch - calcCh(cx, cy, x, y, 0), 0)
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
xyh = sorted(xyh, key = lambda x: x[2])[::-1]
lst = [[x, y] for x in range(101) for y in range(101)]
for Cx, Cy in lst:
    Ch = calcCh(Cx, Cy, *xyh[0])
    if all(Ch == calcH(Cx, Cy, Ch, *xyh[i]) for i in range(n)):
        break
print(Cx, Cy, Ch)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
for i in range(101):
    for j in range(101):
        ansh=[0]*(n+2)
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
            if h==0:ansh[k]=min([ansh[k],max(ansh[:k])])
        if len(set(ansh))==2:
             print(i,j,ansh[1])

Submission status: Wrong Answer

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

for cx in range(101):
	for cy in range(101):
		H=None
		for x,y,h in A:
			if H is None:
				H=abs(x-cx)+abs(y-cy)+h
			else:
				if H==abs(x-cx)+abs(y-cy)+h:
					pass
				else:
					break
		else:
			print cx,cy,H
			quit()

Submission status: Wrong Answer

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

D.sort(key=lambda d: d[2], reverse=True)
for cx in range(100+1):
    for cy in range(100+1):
        f = True
        for i, (x, y, h) in enumerate(D):
            if i == 0:
                ch0 = h + abs(x - cx) + abs(y - cy)
            else:
                ch = h + abs(x - cx) + abs(y - cy)
                if h != 0 and ch0 != ch:
                    f = False
        if f:
            print(cx, cy, ch0)
            exit(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
if n==1:
    print(a[0][0],a[0][1],a[0][2])
else:
    for i in range(101):
        for j in range(101):
            ansh=[0]*(n+2)
            for k,(x,y,h) in enumerate(a):
                ansh[k]=h+abs(i-x)+abs(j-y)
                if h==0:ansh[k]=min([ansh[k],max(ansh[:k])])
            if len(set(ansh))==2:
                print(i,j,ansh[1])

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:
                x_e = min(x_e, x) #左側
            elif x > x2:
                x_s = max(x_s, x) #右側
            if y < y2:
                y_e = min(y_e, y) #上川
            elif y > y2:
                y_s = max(y_s, y) #下側

if x_s == x_e and y_s == y_e:
    x, y, z = X[0]
    print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))
    exit()

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:
            continue
        if x < x2:
            x_s = max(x_s, x) #左側
        elif x > x2:
            x_e = min(x_e, x) #右側
        if y < y2:
            y_s = max(y_s, y) #上川
        elif y > y2:
            y_e = min(y_e, y) #下側

x, y, z = X[0]
print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))

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:
                x_e = min(x_e, x) #左側
            elif x > x2:
                x_s = max(x_s, x) #右側
            if y < y2:
                y_e = min(y_e, y) #上川
            elif y > y2:
                y_s = max(y_s, y) #下側

if x_s == x_e and y_s == y_e:
    x, y, z = X[0]
    print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))
    exit()

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 x < x2:
            x_s = max(x_s, x) #左側
        elif x > x2:
            x_e = min(x_e, x) #右側
        if y < y2:
            y_s = max(y_s, y) #上川
        elif y > y2:
            y_e = min(y_e, y) #下側

x, y, z = X[0]
print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
if n==1:
    print(a[0][0],a[0][1],a[0][2])
else:
    for i in range(101):
        for j in range(101):
            ansh=[0]*(n+2)
            for k,(x,y,h) in enumerate(a):
                ansh[k]=h+abs(i-x)+abs(j-y)
            if len(set(ansh))==2:
                print(i,j,ansh[1])

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:
                x_e = min(x_e, x) #左側
            elif x > x2:
                x_s = max(x_s, x) #右側
            if y < y2:
                y_e = min(y_e, y) #上川
            elif y > y2:
                y_s = max(y_s, y) #下側

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

        # if x_s >= x_e:
        #     print('xover', x, y, x2, y2)
        # if y_s >= y_e:
        #     print('yover', x, y, x2, y2)

x, y, z = X[0]
print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(-x[2],x[0]+x[1]))
if n==1:
    print(a[0][0],a[0][1],a[0][2])
else:
    for i in range(101):
        for j in range(101):
            ansh=[0]*(n+2)
            for k,(x,y,h) in enumerate(a):
                ansh[k]=h+abs(i-x)+abs(j-y)
                if h==0 and (len(set(ansh))!=2 or (x<i or y<j))  :ansh[k]=0
            if len(set(ansh))==2:
                print(i,j,ansh[1])
                break
        else:continue
        break

Submission status: Wrong Answer

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

for cx in range(100+1):
    for cy in range(100+1):
        ch = [h + abs(x - cx) + abs(y - cy) for x, y, h in D]
        if(len(set(ch)) == 1):
            print(cx, cy, ch[0])
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
points.sort(key=lambda x: x[2], reverse=True)

for Cx in range(101):
    for Cy in range(101):
        kouho = set()
        for x, y, h in points:
            if len(kouho) > 1:
                break  # 頂点が一意でない

            if h > 0:
                """観測点の高さが1以上なら頂点高を予測"""
                kouho.add(h + abs(x - Cx) + abs(y - Cy))
            else:
                """観測点の高さが0なら式を満たしているかチェック"""
                if list(kouho)[0] - abs(x - Cx) - abs(y - Cy) != 0:
                    kouho = set()
                    break

        if len(kouho) == 1:
            print('{} {} {}'.format(Cx, Cy, list(kouho)[0]))
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(x[2],-x[0]-x[1]),reverse=True)
for i in range(101):
    for j in range(101):
        ansh=[0]*(n+2)
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
            if h==0 and (len(set(ansh))!=2 or (x<i or y<j))  :ansh[k]=0
        if len(set(ansh))==2:
            print(i,j,ansh[1])
            break
    else:continue
    break

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:(x[2],-x[0]-x[1]),reverse=True)
for i in range(101):
    for j in range(101):
        ansh=[0]*(n+2)
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
            if h==0 and (len(set(ansh))!=2 or (x<i or y<j))  :ansh[k]=0
        if len(set(ansh))==2:
            print(i,j,ansh[1])

Submission status: Wrong Answer

Solution code:
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
h_max = max(h for x, y, h in points)

for Cx in range(101):
    for Cy in range(101):
        kouho = set()
        for x, y, h in points:
            if h <= 0:
                continue  # 高さ0の観測点から頂点を予測できない
            H = h + abs(x - Cx) + abs(y - Cy)
            if H < h_max:
                kouho = set()
                break
            kouho.add(H)
        if len(kouho) == 1:
            print('{} {} {}'.format(Cx, Cy, list(kouho)[0]))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
h_max = max(h for x, y, h in points)

for Cx in range(101):
    for Cy in range(101):
        kouho = set()
        for x, y, h in points:
            if h <= 0:
                continue  # 高さ0の観測点から頂点を予測できない
            H = h + abs(x - Cx) + abs(y - Cy)
            if H <= h_max:
                kouho = set()
                break
            kouho.add(H)
        if len(kouho) == 1:
            print('{} {} {}'.format(Cx, Cy, list(kouho)[0]))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
h_max = max(h for x, y, h in points)

for Cx in range(101):
    for Cy in range(101):
        kouho = set()
        for x, y, h in points:
            if h <= 0:
                continue  # 高さ0の観測点から頂点を予測できない
            H = h + abs(x - Cx) + abs(y - Cy)
            kouho.add(H)
        if len(kouho) == 1:
            print('{} {} {}'.format(Cx, Cy, list(kouho)[0]))
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
a.sort(key=lambda x:x[2],reverse=True)
for i in range(101):
    for j in range(101):
        ansh=[0]*(n+2)
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
            if h==0 and len(set(ansh))!=2 and (x<i or y<j)  :ansh[k]==0
        if len(set(ansh))==2:
            print(i,j,ansh[1])

Submission status: Wrong Answer

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


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    n, = get_ints()

    inp = [get_ints() for _ in range(n)]
    x, y, h = zip(*inp)

    def calc(cx, cy):
        know_H = None
        for x_, y_, h_ in zip(x, y, h):
            if h_ > 0:
                H = abs(cx - x_) + abs(cy - y_) + h_
                if know_H is None:
                    know_H = H
                else:
                    if know_H != H:
                        return None
        assert know_H is not None
        return know_H   

    for cx in range(101):
        for cy in range(101):
            ans = calc(cx, cy)
            if ans is not None:
                print(cx, cy, ans)
                return
    assert False

    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    n, = get_ints()

    inp = [get_ints() for _ in range(n)]
    x, y, h = zip(*inp)

    def calc(cx, cy):
        know_H = None
        for x_, y_, h_ in zip(x, y, h):
            if h_ > 0:
                H = abs(cx - x_) + abs(cy - y_) + h_
                if know_H is None:
                    know_H = H
                else:
                    if know_H != H:
                        return None
        assert know_H is not None
        return know_H   

    for cx in range(101):
        for cy in range(101):
            ans = calc(cx, cy)
            if ans is not None:
                print(cx, cy, ans)
                return

    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def get_line():
    return input()


def get_tokens():
    return get_line().split()


def get_ints():
    return [int(_) for _ in get_tokens()]


def main():
    n, = get_ints()

    inp = [get_ints() for _ in range(n)]
    x, y, h = zip(*inp)

    def calc(cx, cy):
        know_H = None
        for x_, y_, h_ in zip(x, y, h):
            if h_ > 0:
                H = abs(cx - x_) + abs(cy - y_) + h_
                if know_H is None:
                    know_H = H
                else:
                    if know_H != H:
                        return None
        return know_H

    for cx in range(101):
        for cy in range(101):
            ans = calc(cx, cy)
            if ans is not None:
                print(cx, cy, ans)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        ansh=[0]*(n+2)
        for k,(x,y,h) in enumerate(a):
            if h==0:continue
            ansh[k]=h+abs(i-x)+abs(j-y)
        if len(set(ansh))==2:
            print(i,j,ansh[1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        ansh=[0]*n
        for k,(x,y,h) in enumerate(a):
            if h==0:continue
            ansh[k]=h+abs(i-x)+abs(j-y)
        if len(set(ansh))==1:
            print(i,j,ansh[1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        ansh=[0]*n
        for k,(x,y,h) in enumerate(a):
            ansh[k]=h+abs(i-x)+abs(j-y)
        if len(set(ansh))==1:
            print(i,j,ansh[1])

Submission status: Wrong Answer

Solution code:
a = int(input())

b = []

p = 0
pp = 0
ppp = 0

for i in range(a):
    b.append(list(map(int,input().split())))
b.sort(key=lambda x:x[2])
for i in range(0,101):
    for j in range(0,101):
        for k in range(a):
            if k == 0:
                p = abs(b[k][0] - i) + abs(b[k][1]-j)+b[k][2]
            else:
                if max(0,p - abs(b[k][0]-i)- abs(b[k][1]-j)) != b[k][2]:
                    pp = 1
        if pp == 0:
            ppp = 1
            break
        else:
            pp = 0
    if ppp == 1:
        print(i,j,p)
        break

Submission status: Wrong Answer

Solution code:
a = int(input())

b = []

p = 0
pp = 0
ppp = 0

for i in range(a):
    b.append(list(map(int,input().split())))
b.sort(key=lambda x:x[2])
if a == 1:
    print(b[0][0],b[0][1],b[0][2])
else:
    for i in range(0,101):
        for j in range(0,101):
            for k in range(a):
                if k == 0:
                    p = abs(b[k][0] - i) + abs(b[k][1]-j)+b[k][2]
                else:
                    if max(0,p - abs(b[k][0]-i)- abs(b[k][1]-j)) != b[k][2]:
                        pp = 1
            if pp == 0:
                ppp = 1
                break
            else:
                pp = 0
        if ppp == 1:
            print(i,j,p)
            break

Submission status: Wrong Answer

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

for cx in range(101):
	for cy in range(101):
		H=None
		for x,y,h in A:
			if H is None:
				H=abs(x-cx)+abs(y-cy)+h
			else:
				if H==abs(x-cx)+abs(y-cy)+h:
					pass
				else:
					flag=1
					break
		else:
			print cx,cy,H
			quit()

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())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)
print(xyh)

for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            #print(cx, cy, i, hh)
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) < hres:
                ok = -1
                break
    if ok == 0:
        print(cx, cy, hres)
        break

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())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)
print(xyh)

for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            #print(cx, cy, i, hh)
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) <= hres:
                ok = -1
                break
    if ok == 0:
        break
print(cx, cy, hres)

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())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)

for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            #print(cx, cy, i, hh)
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) >= hres:
                ok = -1
                break
    if ok == 0:
        break
print(cx, cy, hres)

Submission status: Wrong Answer

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

W = 101

cs = [[0] * W for i in range(W)]

XYH.sort(key=lambda e:e[2], reverse=True)

h = XYH[0][2]
sx, sy = XYH[0][0:2]
for x in range(W):
    for y in range(W):
        cs[y][x] = h + abs(x - sx) + abs(y - sy)

for i in range(1, N):
    h = XYH[i][2]
    sx, sy = XYH[i][0:2]
    for x in range(W):
        for y in range(W):
            h1 = h + abs(x - sx) + abs(y - sy)
            if h > 0:
                if cs[y][x] != h1:
                    cs[y][x] = 0
            else:
                if cs[y][x] <= h1:
                    cs[y][x] = 0

cx, cy, ch = 0, 0, 0

for x in range(W):
    for y in range(W):
        h = cs[y][x]
        if h > 0:
            cx, cy, ch = x, y, h

print(cx, cy, ch)