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: Runtime Error

Solution code:
n = int(input())
a = []
b = []
flag = 0
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for i in range(0, 101):
	for j in range(0,101):
		h = a[0][0] + abs(i - a[0][2]) + abs(j - a[0][1])
		for k in range(n):
			d = h - abs(i - a[k][2]) - abs(j - a[k][1])
			if (d >= 0 and d != a[k][0]) or (d < 0 and a[k][0] != 0):
				break
			if k == n - 1:
				b.append(i)
				b.append(j)
				b.append(h)
print(b[0], b[1], b[2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
b = []
flag = 0
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for i in range(0, 101):
	if flag == 1:
		break
	for j in range(0,101):
		if flag == 1:
			break
		h = a[0][0] + abs(i - a[0][2]) + abs(j - a[0][1])
		for k in range(n):
			d = h - abs(i - a[k][2]) - abs(j - a[k][1])
			if (d >= 0 and d != a[k][0]) or (d < 0 and a[k][0] != 0):
				break
			if k == n - 1:
				b.append(i)
				b.append(j)
				b.append(h)
				flag = 1
print(b[0], b[1], b[2])

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
b = []
flag = 0
for i in range(n):
	a.append([int(n) for n in input().split()])
	a[i][0], a[i][2] = a[i][2], a[i][0]
a = sorted(a)
for i in range(0, 101):
	if flag == 1:
		break
	for j in range(0,101):
		if flag == 1:
			break
		h = a[0][0] + abs(i - a[0][2]) + abs(j - a[0][1])
		for k in range(n):
			d = h - abs(i - a[k][2]) - abs(j - a[k][1])
			if (d >= 0 and d != a[k][0]) or (d < 0 and a[k][0] == 0):
				break
			if k == n - 1:
				b.append(i)
				b.append(j)
				b.append(h)
				flag = 1
print(b[0], b[1], b[2])

Submission status: Runtime Error

Solution code:
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y', 'h'))

def main():
    n = int(input())
    points = [read_point() for _ in range(n)]
    print(*solve(points))

def solve(points):
    for x in range(0, 101 + 1):
        for y in range(0, 100 + 1):
            h = points[0].h + abs(points[0].x - x) + abs(points[0].y - y)
            for p in points[1:]:
                h2 = p.h + abs(p.x - x) + abs(p.y - y)
                if (p.h > 0 and h2 != h) or h2 > h:
                    break
            else:
                return Point(x, y, h)

def read_point():
    x, y, h = map(int, input().split())
    return Point(x, y, h)

main()

Submission status: Runtime Error

Solution code:
from collections import namedtuple

Point = namedtuple('Point', ('x', 'y', 'h'))

def main():
    n = int(input())
    points = [read_point() for _ in range(n)]
    print(*solve(points))

def solve(points):
    for x in range(0, 101 + 1):
        for y in range(0, 100 + 1):
            h = points[0].h + abs(points[0].x - x) + abs(points[0].y - y)
            for p in points[1:]:
                h2 = p.h + abs(p.x - x) + abs(p.y - y)
                if h != h2:
                    break
            else:
                return Point(x, y, h)

def read_point():
    x, y, h = map(int, input().split())
    return Point(x, y, h)

main()

Submission status: Runtime Error

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

from collections import deque
dq = deque() #stackとして使用、深さ優先探索
dq.append([0, None, None, None, None])

while dq:
  print(dq)
  i, xmin, xmax, ymin, ymax = dq.pop()
  
  if i==N:
    print(xmin,xmax,ymin,ymax)
    Cx = (xmin+xmax)//2
    Cy = (ymin+ymax)//2
    H = (xmax-xmin)//2
    print(Cx,Cy,H)
    exit()
    
  x, y, h = XYH[i]
  print(x,y,h)
  
  # one of the four
  print(x<=100 and 0<=y and y<=100)
  if x<=100 and 0<=y and y<=100:
    new_xmin = x-h
    if xmin==new_xmin or xmin is None and (not all([ymax, ymin, xmax]) or ymax - ymin == xmax - new_xmin):
      dq.append([i+1, new_xmin, xmax, ymin, ymax])
      
  print(x>=0 and 0<=y and y<=100)
  if x>=0 and 0<=y and y<=100:
    new_xmax = x+h
    if xmax==new_xmax or xmax is None and (not all([ymax, ymin,xmin]) or ymax-ymin == new_xmax - xmin):
      dq.append([i+1, xmin, new_xmax, ymin, ymax])
      
  print(0<=x and x<=100 and y<=100)
  if 0<=x and x<=100 and y<=100:
    new_ymin = y-h
    if ymin==new_ymin or ymin is None and (not all([ymax, xmax, xmin]) or ymax - new_ymin ==xmax-xmin):
      dq.append([i+1, xmin, xmax, new_ymin, ymax])
      
  print(0<=x and x<=100 and 0<=y)
  if 0<=x and x<=100 and 0<=y:
    new_ymax = y+h
    if ymax==new_ymax or ymax is None and (not all([ymin, xmax, xmin]) or new_ymax - ymin ==xmax-xmin):
      dq.append([i+1, xmin, xmax, ymin, new_ymax])

Submission status: Runtime Error

Solution code:
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[1][2]==0:
    print(ans[0][0],ans[0][1],ans[0][2])

for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if p==q:
            for k in range(2,N):
                if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
                elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<=p : break
                if k==N-1:
                    print(i,j,p)
                    sys.exit()

        if p==100: print(i,j,100)

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]
for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if N>2: r=a[2][2]+abs(i-a[2][0])+abs(j-a[2][1])

        if N==2 and p==q: ans.append([i,j,p])
        elif p==q and p==r: ans.append([i,j,p])


for i in range(2,N) :
    if len(ans)==1: break
    for x in ans:
        if x[2]!=a[i][2]+abs(x[0]-a[i][0])+abs(x[1]-a[i][1]):
            ans.remove(x)

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

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[1],reverse=True)

ans=[]
for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if N>2: r=a[2][2]+abs(i-a[2][0])+abs(j-a[2][1])

        if N==2 and p==q: ans.append([i,j,p])
        elif p==q and p==r: ans.append([i,j,p])

for i in range(3,N) :
    if len(ans)==1: break
    for x in ans:
        if x[2]!=a[i][2]+abs(x[0]-a[i][0])+abs(x[1]-a[i][1]):
            ans.remove(x)

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

Submission status: Runtime Error

Solution code:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[1])

ans=[]
for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if N>2: r=a[2][2]+abs(i-a[2][0])+abs(j-a[2][1])

        if N==2 and p==q: ans.append([i,j,p])
        elif p==q and p==r: ans.append([i,j,p])

for i in range(3,N) :
    if len(ans)==1: break
    for x in ans:
        if x[2]!=a[i][2]+abs(x[0]-a[i][0])+abs(x[1]-a[i][1]):
            ans.remove(x)

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

Submission status: Runtime Error

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

def height(cx, cy):
    res = set()
    for p in points:
        if p[2] == 0:
            continue
        res.add(p[2] + abs(p[0] - cx) + abs(p[1] - cy))
    return list(res)

def find():
    result = []
    for x in range(101):
        for y in range(101):
            hs = height(x, y)
            if len(hs) == 1:
                result.append([str(x), str(y), str(hs[0])])
    return result

res = find()
if len(res) > 1:
    raise Exception()

print(' '.join(res[0]))

Submission status: Runtime Error

Solution code:
pyramid=[]
if n==1:
  x,y,h=map(int,input().split())
  print(x,y,h)
  return
else:
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
ans=[[0 for i in range(101)] for i in range(101)]
flag=1
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Submission status: Runtime Error

Solution code:

pyramid=[]
if n==1:
  x,y,h=map(int,input().split())
  print(x,y,h)
else:
  x,y,h=map(int,input().split())
  pyramid.append([x,y,h])
ans=[[0 for i in range(101)] for i in range(101)]
flag=1
for i in range(n):
  if pyramid[i][2]!=0:
    for cx in range(101):
      for cy in range(101):
        H=pyramid[i][2]+abs(pyramid[i][0]-cx)+abs(pyramid[i][1]-cy)
        if flag==1:
          ans[cx][cy]=H
        else:
          if ans[cx][cy]!=H:
            ans[cx][cy]=0
  flag=0
for i in range(101):
  for j in range(101):
    if ans[i][j]!=0:
      print(i,j,ans[i][j])

Submission status: Runtime Error

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi==0:
      if (h-abs(xi-cx)-abs(yi-cy))<=0:
        continue
      else:
        break
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    print(cx, cy, h)
    break

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])
for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = max([point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY),0])
            else:
                if(checker == max([point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)],0)):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Runtime Error

Solution code:
n=int(input())
l=[]
for i in range(n):
  l.append(reversed(list(map(int,input().split()))))
l=sorted(l)
for i in range(101):
  for j in range(101):
    b=True
    h=abs(i-l[-1][2])+abs(j-l[-1][1])+l[-1][0]
    for i in range(n-1):
      if max(h-abs(i-l[-2-i][2])-abs(j-l[-2-i][1]),0)!=l[-2-i][0]:
        b=False
    if b:
      print(i,j,h)
      break

Submission status: Runtime Error

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


ls = [[0]*101 for i in [0]*101]

cor = [[i,j] for i in range(101) for j in range(101)]

x,y,h = xyh[0]
for cx,cy in cor[:]:
	hx = abs(cx-x)
	hy = abs(cy-y)
	H = h+hx+hy
	ls[cx][cy] = H

for x,y,h in xyh[1:]:
	for cx,cy in cor[:]:
		hx = abs(cx-x)
		hy = abs(cy-y)
		H = h + hx + hy
		if not ls[cx][cy] == H:
			cor.remove([cx,cy])

cx,cy = cor[0]
print(cx,cy,ls[cx][cy])

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
xyh = [list(map(int,input().split(' '))) for i in [0]*N]


ls = [[0]*101 for i in [0]*101]

cor = [[i,j] for i in range(101) for j in range(101)]

x,y,h = xyh[0]
for cx,cy in cor[:]:
	hx = abs(cx-x)
	hy = abs(cy-y)
	H = h+hx+hy
	if H <= 0:
		cor.remove([cx,cy])
	else:
		ls[cx][cy] = H

for x,y,h in xyh[1:]:
	for cx,cy in cor[:]:
		hx = abs(cx-x)
		hy = abs(cy-y)
		H = h + hx + hy
		if not ls[cx][cy] == H:
			cor.remove([cx,cy])

cx,cy = cor[0]
print(cx,cy,ls[cx][cy])

Submission status: Runtime Error

Solution code:
N = int(input())

list_inp = [list(map(int,input().split())) for _ in range(N)]
list_inp.sort(key=lambda x: x[2], reverse=True)
max_list_inp = list_inp[-1]


for x in range(101):
  for y in range(101):
    flg = True
    max_h = max_list_inp[2] + abs(max_list_inp[0] - x) + abs(max_list_inp[1] - y)
    
    # 全サンプルで、結果が一致することを確認する。
    for i in list_inp:
      h = max(max_h - abs(i[0] - x) - abs(i[1] - y), 0)
      if h != i[2]:
        flg = False
        break
    
    if flg:
      ans_x, ans_y,ans_h = x,y,max_h
      break
    
  if flg:
    break
    
    
print(ans_x, ans_y,ans_h)

Submission status: Runtime Error

Solution code:
N = int(input())

list_inp = [list(map(int,input().split())) for _ in range(N)]
list_inp.sort(key=lambda x: x[2], reverse=True)
max_list_inp = list_inp[-1]


for x in range(101):
  for y in range(101):
    flg = True
    max_h = max_list_inp[2] + abs(max_list_inp[0] - x) + abs(max_list_inp[1] - y)
    
    # 全サンプルで、結果が一致することを確認する。
    for i in list_inp:
      h = max(max_h - abs(i[0] - x) - abs(i[1] - y), 0)
      if h != i[2]:
        flg = False
        break
    
    if flg:
      ans_x, ans_y,ans_h = x,y,max_h
    
    
print(ans_x, ans_y,ans_h)

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    Z=10**18
    flag=True
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        if flag:
          H=abs(x-cx)+abs(y-cy)+h
        else:
          if H!=abs(x-cx)+abs(y-cy)+h:
            H=10**18+1
            break
      else:
        Z=min(Z,abs(x-cx)+abs(y-cy))
    if H<=Z:
      print(cx,cy,H[0])
      exit()

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    stack2==10**18
    for i in range(n):
      if flag==False:
        break
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      if h==0:
        stack2=min(stack2,H)
      if h!=0 and flag2==False:
        if stack!=H:
          flag=False
          break
    if flag and stack<=stack2:
      print(cx,cy,H)
      exit()

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        H.append(abs(x-cx)+abs(y-cy)+h)
      else:
        Z.append(abs(x-cx)+abs(y-cy))
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H[0])
      exit()

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h==0:
        H.append(abs(x-cx)+(y-cy)+h)
      else:
        Z.append(abs(x-cx)+(y-cy))
    if len(Z)==0:
      Z.append(10**18)
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H)
      exit()

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h==0:
        H.append(abs(x-cx)+(y-cy)+h)
      else:
        Z.append(abs(x-cx)+(y-cy))
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H)
      exit()

Submission status: Runtime Error

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if i==0:
        if h==0:
          flag2=False
        stack=H
        continue
      if h==0:
        if flag2==False:
          if H<stack:
            stack=H
          continue
        elif stack>H:
          flag=False
          break
      if flag2=False:
        if H>stack:
          flag=False
          break
        else:
          stack=H
          flag2=True
      if stack!=H:
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for _ in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = ['0']*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                    flag = False
        if(flag):
            ans=[str(i),str(j),str(h)]
            break
print(ans[0]+' '+ans[1]+' '+ans[2])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                    flag = False
        if(flag):
            ans=[str(i),str(j),str(h)]
            break
print(ans[0]+' '+ans[1]+' '+ans[2])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**8)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                    flag = False
        if(flag):
            ans=[str(i),str(j),str(h)]
            break
print(ans[0]+' '+ans[1]+' '+ans[2])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**10)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                    flag = False
        if(flag):
            ans=[str(i),str(j),str(h)]
            break
print(ans[0]+' '+ans[1]+' '+ans[2])

Submission status: Runtime Error

Solution code:
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                    flag = False
        if(flag):
            ans=[str(i),str(j),str(h)]
            break
print(ans[0]+' '+ans[1]+' '+ans[2])

Submission status: Runtime Error

Solution code:
#coding: utf-8
import sys
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    l.append(a)
    if N == 1:
      print(a[0], a[1], a[2])
      sys.exit()

for i in range(N-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break

print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))

Submission status: Runtime Error

Solution code:
#coding: utf-8
import sys
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)
    if N == 1:
      print(a[0], a[1], a[2])
      sys.exit()

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break

print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break

if len(ans) == 1:
  print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))
else:
  print(l[0][0], l[0][1], l[0][2])

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]) if len(ans) == 1 else l[0][0], l[0][1], l[0][2])

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]) if len(ans) == 1)

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]) if len(ans) == 1 else 0)

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))
print(ans[0][19])

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[2] > 0:
      l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy) and l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) >= l[i][2] and l[i][2] + abs(l[i][0] - cx) + abs(l[i+1][1] - cy) >= l[i+1][2]:
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    l.append(a)

for i in range(len(l)-1):
    ans = []
    for cx in range(101):
        for cy in range(101):
          if l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy) == l[i+1][2] + abs(l[i+1][0] - cx) + abs(l[i+1][1] - cy):
            if i == 0:
              ans.append([cx, cy])
            else:
              if [cx, cy] in ansn:
                ans.append([cx, cy])
    ansn = ans[:]
    if len(ans) == 1:
        break
print(ans[0][0], ans[0][1], l[0][2] + abs(l[0][0] - ans[0][0]) + abs(l[0][1] - ans[0][1]))

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    l.append(a)

for i in range(len(l)):
    ansn = []
    for cx in range(101):
        for cy in range(101):
            ans_tmp = [cx, cy, l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy)]
            if i == 0 and ans_tmp[-1] >= 1:
                ansn.append(ans_tmp)
            else:
                if ans_tmp in ans:
                    ansn.append(ans_tmp)
    ans = ansn[:]
print(ans[0][0], ans[0][1], ans[0][2])

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    l.append(a)
H = []
for i in range(N):
    Hn = []
    for cx in range(101):
        for cy in range(101):
            H_tmp = l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy)
            Hn.append([cx, cy, H_tmp])
    if i == 0:
        ans = []
        H = Hn[:]
    else:
        ans = []
        for j in range(len(H)):
            if H[j] in Hn:
                ans.append(H[j])
        H = ans[:]
print(H[0][0], H[0][1], H[0][2])

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
xyh = []
for _ in range (N):
    xyh.append([int(x) for x in input().split()])

count = 0
while True:
    if xyh[count][2] >= 0:
        hstd = xyh[count][2]
        break
    else:
        count += 1

for x in range (101):
    for y in range (101):
        Cx = x
        Cy = y
        H = hstd + abs(x-Cx) + abs (y - Cy)
        xyhcand = []
        for k in range (N) :
            xi = xyh[k][0]
            yi = xyh[k][1]
            h = max(H-abs(x-Cx)-abs(y-Cy),0)
            xyhls = [xi,yi,h]
            xyhcand.append(xyhls)
            xyhls = []
        if sorted(xyh) == sorted(xyhcand):
            ans = '.'.join([x,y,H])
            break
        
print(ans)

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
xyh = []
for _ in range (N):
    xyh.append([int(x) for x in input().split()])

count = 0
while True:
    if xyh[count][2] >= 0:
        hstd = xyh[count][2]
        break
    else:
        count += 1

for x in range (101):
    for y in range (101):
        Cx = x
        Cy = y
        H = hstd + abs(x-Cx) + abs (y - Cy)
        xyhcand = []
        for k in range (N) :
            xi = xyh[k][0]
            yi = xyh[k][1]
            h = max(H-abs(x-Cx)-abs(y-Cy),0)
            xyhls = [xi,yi,h]
            xyhcand.append(xyhls)
            xyhls = []
        if set(xyh) == set(xyhcand):
            ans = '.'.join([x,y,H])
            break
        
print(ans)