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

def find_top(x,y,N,xyh):
    find=True
    prev=-1
    for n in range(N):
        if xyh[n][2]!=0:
            top=xyh[n][2]+abs(xyh[n][0]-x)+abs(xyh[n][1]-y)
            if prev==-1 or prev==top:
                prev=top
            else:
                find=False
                break
    return find,top

fin=False
for x in range(101):
    if fin==True:
        break
    for y in range(101):
        find=find_top(x,y,N,xyh)[0]
        height=find_top(x,y,N,xyh)[1]
        if find and height>=1:
            print("{} {} {}".format(x,y,height))
            fin=True

Submission status: Wrong Answer

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

def find_top(x,y,N,xyh):
    find=True
    prev=xyh[0][2]+abs(xyh[0][0]-x)+abs(xyh[0][1]-y)
    for n in range(N):
        if xyh[n][2]!=0:
            top=xyh[n][2]+abs(xyh[n][0]-x)+abs(xyh[n][1]-y)
            if prev==top:
                prev=top
            else:
                find=False
                break
    return find,top

fin=False
for x in range(101):
    if fin==True:
        break
    for y in range(101):
        find=find_top(x,y,N,xyh)[0]
        height=find_top(x,y,N,xyh)[1]
        if find and height>=1:
            print("{} {} {}".format(x,y,height))
            fin=True

Submission status: Wrong Answer

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

def find_top(x,y,N,xyh):
    find=True
    prev=xyh[0][2]+abs(xyh[0][0]-x)+abs(xyh[0][1]-y)
    for n in range(N):
        if xyh[n][2]!=0:
            top=xyh[n][2]+abs(xyh[n][0]-x)+abs(xyh[n][1]-y)
            if prev==top:
                prev=top
            else:
                find=False
                break
    return find,top

fin=False
for x in range(101):
    if fin==True:
        break
    for y in range(101):
        find=find_top(x,y,N,xyh)[0]
        height=find_top(x,y,N,xyh)[1]
        if find:
            print("{} {} {}".format(x,y,height))
            fin=True

Submission status: Wrong Answer

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

for cx in range(0,101):
  for cy in range(0,101):
    H=[]
    for i in range(n):
      if h[i]>0:
        H.append(h[i]+abs(cx-x[i])+abs(cy-y[i]))
    if len(set(H))==1:
      print(cx,cy,H[0])
      exit()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        l = []
        for k in range(n):
            x = xyh[k][0]
            y = xyh[k][1]
            h = xyh[k][2]
            if xyh[k][2] != 0:
                l.append(abs(xyh[k][0] - i) + abs(xyh[k][1] - j) + xyh[k][2])
        if len(set(l)) == 1:
            print(i, j, l[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        h = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        flag = True
        for k in range(1, n):
            temp = xyh[k][2] + abs(xyh[k][0] - i) + abs(xyh[k][1] - j)
            if h != temp:
                flag = False
                break
        if flag == True and h >= 1:
            print(i, j, h)
            break
    if flag == True:
        break

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def main():
	n = int(input())
	lh =[]
	for i in range(0 ,n):
		x, y , h = map(int , input().split())
		lh.append([x, y, h])
	for X in range(0, 101):
		for Y in range(0, 101):
			height =defaultdict(int)
			for x, y , h in lh:
				H = max(h,abs(x-X)+abs(y-Y)+h)
				height[H]=height[H]+1
				if height[H]==n and H>=1:
					print(X, Y , H)
					exit()
if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def main():
	n = int(input())
	lh =[]
	for i in range(0 ,n):
		x, y , h = map(int , input().split())
		lh.append([x, y, h])
	for X in range(0, 101):
		for Y in range(0, 101):
			height =defaultdict(int)
			for x, y , h in lh:
				H = abs(x-X)+abs(y-Y)+h
				height[H]=height[H]+1
				if height[H]==n and H>=1:
					print(X, Y , H)
					exit()
if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
def main():
	n = int(input())
	lh =[]
	for i in range(0 ,n):
		x, y , h = map(int , input().split())
		lh.append([x, y, h])
	for X in range(0, 101):
		for Y in range(0, 101):
			height =defaultdict(int)
			for x, y , h in lh:
				H = abs(x-X)+abs(y-Y)+h
				height[H]=height[H]+1
				if height[H]==n:
					print(X, Y , H)
					exit()
if __name__=="__main__":
	main()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
for cy in range(0, 101):
    for cx in range(0, 101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0)
            if h2 != xyh[i][2]:
                flag = False
                break
        if flag:
            answer = [cx, cy, H]
            break
    if flag:
        break

answerString = str(answer[0]) + " " + str(answer[1]) + " " + str(answer[2])
print(answerString)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
for cy in range(101):
    for cx in range(101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0)
            if h2 != xyh[i][2]:
                flag = False
                break
        if flag:
            answer = [cx, cy, H]
            break
    if flag:
        break

answerString = str(answer[0]) + " " + str(answer[1]) + " " + str(answer[2])
print(answerString)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
flag = True
for cy in range(101):
    for cx in range(101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0)
            if h2 != xyh[i][2]:
                flag = False
        if flag:
            answer = [cx, cy, H]
            break

answerString = str(answer[0]) + " " + str(answer[1]) + " " + str(answer[2])
print(answerString)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
flag = True
for cy in range(101):
    for cx in range(101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0)
            if h2 != xyh[i][2]:
                flag = False
        if flag:
            answer = [cx, cy, H]
            break

print(answer)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  if xyh[i][2] != 0:
    cnt += 1
if cnt == 1:
  for i in range(n):
    if xyh[i][2] != 0:
      print(" ".join(list(map(str, xyh[i]))))
      sys.exit()
for i in range(101):
  for j in range(101):
    x = []
    for k in range(n):
      if xyh[k][2] != 0:
        x.append(abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2])
    print(x)
    if len(set(x)) == 1:
      print(i, j, x[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for i in range(101):
  for j in range(101):
    x = []
    for k in range(n):
      if xyh[k][2] != 0:
        x.append(abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2])
    if len(set(x)) == 1:
      print(i, j, x[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for n in range(N)]
xyh.sort(key=lambda x:x[2],reverse=True)#高度１でない情報から高さ定めるため
for X in range(1,101):
    for Y in range(1,101):
        H = xyh[0][2] + abs(xyh[0][0]-X) + abs(xyh[0][1]-Y)
        for i in range(1,N):
            x,y,h = xyh[i]
            if h != max(H - abs(x-X) -abs(y-Y),0):
                break
        else:
            print(X,Y,H)
            break

Submission status: Wrong Answer

Solution code:
N = int(input())

XYs = []
for _ in range(N):
  XYs.append(list(map(int, input().split())))
  
for i in range(101):
  for j in range(101):
    f = 1
    for k in range(N):
      if XYs[k][2] > 0:
        h = XYs[k][2] + abs(XYs[k][0]-i) + abs(XYs[k][1]-j)
        break
    for k in range(1,N):
      if max(h - abs(XYs[k][0]-i) - abs(XYs[k][1]-j), 0) != XYs[k][2]:
        f = 0
        break
    if f == 1:
      print(i,j,h)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

XYs = []
for _ in range(N):
  XYs.append(list(map(int, input().split())))
  
for i in range(101):
  for j in range(101):
    f = 1
    h = XYs[0][2] + abs(XYs[0][0]-i) + abs(XYs[0][1]-j)
    for k in range(1,N):
      if max(h - abs(XYs[k][0]-i) - abs(XYs[k][1]-j), 0) != XYs[k][2]:
        f = 0
        break
    if f == 1:
      print(i,j,h)
      exit()

Submission status: Wrong Answer

Solution code:
import sys

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

idx = 0
for i in range(N):
    if xyz[i][2] != 0:
        idx = i
        break

for cx in range(101):
    for cy in range(101):
        switch = 1
        H = xyz[idx][2] + abs(xyz[idx][0] - cx) + abs(xyz[idx][1] - cy)
        for x,y,h in xyz:
            if h == 0:
                continue
            kari = h + abs(x - cx) + abs(y - cy)
            if H != kari:
                switch = 0
                break
        if switch == 1:
            print(cx, cy, H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

idx = 0
for i in range(N):
    if xyz[i][2] != 0:
        idx = i
        break

for cx in range(101):
    for cy in range(101):
        switch = 1
        H = xyz[idx][2] + abs(xyz[idx][0] - cx) + abs(xyz[idx][1] - cy)
        for x,y,h in xyz:
            kari = h + abs(x - cx) + abs(y - cy)
            if H != kari:
                switch = 0
                break
        if switch == 1:
            print(cx, cy, H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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


for cx in range(101):
    for cy in range(101):
        switch = 1
        H = xyz[0][2] + abs(xyz[0][0] - cx) + abs(xyz[0][1] - cy)
        for x,y,h in xyz[1:]:
            kari = h + abs(x - cx) + abs(y - cy)
            if H != kari:
                switch = 0
                break
        if switch == 1:
            print(cx, cy, H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
coor = [tuple(map(int,input().split())) for _ in range(N)]
coor = sorted(coor, key=lambda x:x[2])

def dist(coor1,coor2):
  return abs(coor2[0]-coor1[0])+abs(coor2[1]-coor1[1])

for x in range(101):
  for y in range(101):
    h = [max(coor[i][2]+dist((x,y),coor[i]),0) for i in range(N)]
    if len(set(h))==1 and h[0] != 0:
      print(*(x,y,h[0]))
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
coor = [tuple(map(int,input().split())) for _ in range(N)]
coor = sorted(coor, key=lambda x:x[2])

def dist(coor1,coor2):
  return abs(coor2[0]-coor1[0])+abs(coor2[1]-coor1[1])

for x in range(101):
  for y in range(101):
    h = [coor[i][2]+dist((x,y),coor[i]) for i in range(N)]
    if len(set(h))==1:
      print(*(x,y,h[0]))
      exit()

Submission status: Wrong Answer

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

answer_string = ""
for cx in range(101):
    for cy in range(101):
        flag = True
        tmpH = 0
        for i in range(N):
            X = xyh[i][0]
            Y = xyh[i][1]
            h = xyh[i][2]
            if h != 0:
                if tmpH == 0:
                    tmpH = abs(X-cx) + abs(Y-cy) + h
                else:
                    if tmpH != abs(X-cx) + abs(Y-cy) + h:
                        flag = False
        if flag:
            answer_string = str(cx) + " " + str(cy) + " " + str(tmpH)
print(answer_string)

Submission status: Wrong Answer

Solution code:
n = int(input())

x = [0] * n
y = [0] * n
h = [0] * n

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

for cx in range(101):
    for cy in range(101):
        arr = []
        for i in range(n):
            if h[i] == 0:
                pass
            else:
                H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
                arr.append(H)
        if len(list(set(arr))) == 1:
            print(cx,cy,arr[0])
            exit()

Submission status: Wrong Answer

Solution code:
def f(l):
    s=l[0]
    for i in l[1:]:
        if s!=i:
            return False
    return True
n=int(input())
l=[]
for i in range(n):
    l.append([*map(int,input().split())])
for cx in range(101):
    for cy in range(101):
        d=[abs(cx-x)+abs(cy-y)+h for x,y,h in l if h!=0]
        if f(d):
            print(cx,cy,d[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
for i in range(n):
    a,b,c=map(int,input().split())
    x[i]=a
    y[i]=b
    h[i]=c

ans={}
cnt=[0]*1000010
for t in range(n):
    for i in range(101):
        for j in range(101):
            H = h[t] + abs(i-x[t]) + abs(j-y[t])
            if (H,i,j) in ans:
                ans[(H,i,j)]+=1
            else:
                ans[(H,i,j)]=1

for i in ans:
    if ans[i]==n:
        print(i[1],i[2],i[0])
        break

Submission status: Wrong Answer

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

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

H = 0
flag = 0

for i in range(101):
    for j in range(101):
        flag = 0
        H = s_list[0][2] + abs(i-s_list[0][0]) + abs(j-s_list[0][1])
        for k in range(1,n):
            if s_list[k][2] != max(H - abs(s_list[k][0]-i) - abs(s_list[k][1]-j),0):
                flag = 1
                break
        if flag == 0:
            print(i,j,H)
            break

Submission status: Wrong Answer

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

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

H = 0
flag = 0

for i in range(101):
    for j in range(101):
        flag = 0
        H = s_list[0][2] + abs(s_list[0][0]-i) + abs(s_list[0][1]-j)
        for k in range(1,n):
            if s_list[k][2] != max(H - abs(s_list[k][0]-i) - abs(s_list[k][1]-j),0):
                flag = 1
                break
        if flag == 0:
            print(i,j,H)
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
#print(XYH)

for x1, y1, h1 in XYH:
    if h1 > 0:
        for Cx in range(101):
            for Cy in range(101):
                H = h1 + abs(x1 - Cx) + abs(y1 - Cy)
                # print(Cx, Cy, H)
                if H >= 1:
                  if all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x, y, h in XYH[1:]):
                    print(Cx, Cy, H)
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
#print(XYH)

for x1, y1, h1 in XYH:
    if h1 > 0:
        for Cx in range(101):
            for Cy in range(101):
                H = h1 + abs(x1 - Cx) + abs(y1 - Cy)
                # print(Cx, Cy, H)
                if all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x, y, h in XYH[1:]):
                  print(Cx, Cy, H)
                  exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = sorted([list(map(int, input().split())) for _ in range(n)], reverse=True)
#print(XYH)
x1, y1, h1 = XYH[0]
# print(x1, y1, h1)

for Cx in range(101):
    for Cy in range(101):
        H = h1 + abs(x1 - Cx) + abs(y1 - Cy)

        # print(Cx, Cy, H)
        if all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x, y, h in XYH[1:]):
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
x1, y1, h1 = XYH[0]
#print(x1, y1, h1)

for Cx in range(101):
    for Cy in range(101):
        H = h1 + abs(x1-Cx) + abs(y1-Cy)
        #print(Cx, Cy, H)
        if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in XYH[1:]):
            print(Cx, Cy, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
x1, y1, h1 = XYH[0]
# print(x1, y1, h1)

for Cx in range(101):
    for Cy in range(101):
        H = h1 + abs(x1-Cx) + abs(y1-Cy)
        # print(Cx, Cy, H)
        if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in XYH):
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
x1, y1, h1 = XYH[0]
# print(x1, y1, h1)

for Cx in range(101):
    for Cy in range(101):
        H = h1 + abs(x1-Cx) + abs(y1-Cy)
        # print(Cx, Cy, H)
        if all(h == max(H-abs(x-Cx)-abs(y-Cy), 0) for x, y, h in XYH[1:]):
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]
x1, y1, h1 = XYH[0]
#print(x1, y1, h1)

for Cx in range(101):
  for Cy in range(101):
    H = h1 + abs(x1-Cx)+ abs(y1-Cy)
    for x, y, h in XYH[1:]:
      #print(Cx, Cy, H)
      if h == max(H - abs(x-Cx) - abs(y-Cy), 0):
        print(Cx, Cy, H)
        exit()

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
x = [0]*n
y = [0]*n
h = [0]*n

for i in range(n):
    x[i], y[i], h[i] = MAP()

for i in range(101):
    for j in range(101):
        H = 0
        for k in range(n):
            if h[k] != 0:
                if H == 0 or H == h[k] + abs(x[k]-i) + abs(y[k]-j):
                    H = h[k] + abs(x[k]-i) + abs(y[k]-j)
                else:
                    break
        else:
            print(i,j,H)

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    xyh = [LI() for _ in range(N)]

    for cx, cy in itertools.product(range(101), range(101)):
        H = []
        for i in range(N):
            x, y, h = xyh[i]
            if h > 0:
                H.append(h + abs(x - cx) + abs(y - cy))
        if len(set(H)) == 1:
            print(cx, cy, H[0])
            break

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    xyh = [LI() for _ in range(N)]

    for cx, cy in itertools.product(range(101), range(101)):
        H = []
        for i in range(N):
            x, y, h = xyh[i]
            H.append(h + abs(x - cx) + abs(y - cy))
        if len(set(H)) == 1:
            print(cx, cy, H[0])
            break

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    xyh = [LI() for _ in range(N)]

    for cx, cy in itertools.product(range(101), range(101)):
        H = []
        for i in range(N):
            x, y, h = xyh[i]
            if h != 0:
                H.append(h + abs(x - cx) + abs(y - cy))
        if len(set(H)) == 1:
            print(cx, cy, H[0])
            break

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())

xy = [[-1 for i in range(101)] for j in range(101)]

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


for i in range(101):
  for j in range(101):
    top = -1
    for k in range(n):
      if h[k] > 0:
        tmp = h[k] + abs(x[k]-i) + abs(y[k]-j)
        if top == -1:
          top = tmp
        else:
          if top != tmp:
            top = -2
            break
    if top > 0:
      print (i,j,top)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

xy = [[-1 for i in range(101)] for j in range(101)]

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


for i in range(101):
  for j in range(101):
    top = -1
    for k in range(n):
      if h[k] > 0:
        tmp = h[k] + abs(x[k]-i) + abs(y[k]-j)
        if top == -1:
          top = tmp
        else:
          if top != tmp:
            top = -2
            break
    if top != -2:
      print (i,j,top)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import product

input = sys.stdin.readline


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    for i in range(N):
        X[i], Y[i], H[i] = map(int, input().split())

    for Cx, Cy in product(range(101), repeat=2):
        Ch = set()
        Ch_upper = float("inf")
        for x, y, h in zip(X, Y, H):
            a = abs(x - Cx) + abs(y - Cy)
            if h == 0:
                Ch_upper = a
            else:
                Ch.add(h + a)
        if len(Ch) != 1:
            continue
        else:
            Ch = Ch.pop()
            if Ch <= Ch_upper:
                ans = f"{Cx} {Cy} {Ch}"
                break

    print(ans)


if __name__ == "__main__":
    main()

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)

for x in range(101):
    for y in range(101):
        h = set()
        for i in range(n-1):
            if H[i]==0: continue
            h.add(H[i]+abs(x-X[i])+abs(y-Y[i]))
        if len(h)==1:
            print(x, y, list(h)[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
coords = [tuple(map(int, input().split())) for i in range(n)]
for xt, yt, ht in coords:
    if ht != 0:
        break
x, y, h = -1, -1, -1
for px in range(101):
    for py in range(101):
        flag = True
        htmp = ht + abs(px-xt) + abs(py-yt)
        for x1, y1, h1 in coords:
            if h1 == 0:
                continue
            if abs(htmp-h1) != abs(px-x1) + abs(py-y1):
                flag = False
                break
        if flag:
            if htmp > h:
                h = htmp
                x = px
                y = py
print (x, y, h)

Submission status: Wrong Answer

Solution code:
n = int(input())
coords = [tuple(map(int, input().split())) for i in range(n)]
left, right, top, down = 0, 100, 0, 100
iplusj = -1
H = -1
for i in range(n):
    x1, y1, h1 = coords[i]
    for j in range(i+1, n):
        x2, y2, h2 = coords[j]
        if h2-h1< 0:
            h2, x2, y2, h1, x1, y1 = h1, x1, y1, h2, x2, y2
        if h1 == 0 or h2 == 0:
            continue
        dx = x2 - x1
        dy = y2 - y1
        dh = h2 - h1
        #print (left, right, x1, x2)
        if abs(dh) < abs(dx) + abs(dy):
            d = (abs(dx) + abs(dy) - abs(dh))//2 
            if H < max(h1, h2) + d:
                #print (x1, y1, h1, x2, y2, h2, d)
                H = max(h1, h2) + d
                if dx > 0 or dy > 0:
                    iplusj = x2-d+y2
                elif dx < 0 or dy < 0:
                    iplusj = x2+d+y2
            """
            if dx > 0:
                left = max(x1, left)
                right = min(x2, right)
            elif dx < 0:
                left = max(x2, left)
                right = min(x1, right)
            if dy > 0:
                top = max(y1, top)
                down = min(y2, down)
            elif dy < 0:
                top = max(y2, top)
                down = min(y1, down)
            """
        else:
            #print (h1, x1, y1, h2, x2, y2)
            if dx > 0:
                left = max(x1, left)
                right = min(x2, right)
            elif dx < 0:
                left = max(x2, left)
                right = min(x1, right)
            if dy > 0:
                top = max(y1, top)
                down = min(y2, down)
            elif dy < 0:
                top = max(y2, top)
                down = min(y1, down)
#print ("iplusj", left, right, top, down, iplusj, H)
if iplusj == -1:
    no1 = max(coords, key=lambda x: x[2])
    x, y, H = no1
    print (x, y, H)
else:
    for y in range(101):
        x = iplusj - y
        if x < 0:
            continue
        success = True
        for i in range(n):
            x1, y1, h1 = coords[i]
            if h1 == 0:
                continue
            dx, dy = x-x1, y-y1
            #print (x, y, h1, abs(dx), abs(dy), H)
            if (h1 + abs(dx)+abs(dy) != H):
                success = False
                break
        if success:
            print (x, y, H)
            break