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, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        A.append((cx, cy, C.pop()))
print(*A.pop())

Submission status: Runtime Error

Solution code:
n = int(input())
u = []
for i in range(n):
    u.append(list(map(int,input().split())))
 
for i in range(0,n,-1):
    if u[i][2] == 0:
        u.pop(i)
z=[]
c =0
for cx in range(101):
    for cy in range(101):
        c = u[0][2]+abs(u[0][0]-cx)+abs(u[0][1]-cy)
        for j in u:
            if c != j[2]+abs(j[0]-cx)+abs(j[1]-cy):
                break
        else:
            z.append((cx,cy))
 
print(z[0][0],z[0][1],u[0][2]+abs(u[0][0]-z[0][0])+abs(u[0][1]-z[0][1]))

Submission status: Runtime Error

Solution code:
n = int(input())
u = []
for i in range(n):
    u.append(list(map(int,input().split())))
 
for i in range(n):
    if u[i][2] == 0:
        u.pop(i)
z=[]
c =0
for cx in range(101):
    for cy in range(101):
        c = u[0][2]+abs(u[0][0]-cx)+abs(u[0][1]-cy)
        for j in u:
            if c != j[2]+abs(j[0]-cx)+abs(j[1]-cy):
                break
        else:
            z.append((cx,cy))
 
print(z[0][0],z[0][1],u[0][2]+abs(u[0][0]-z[0][0])+abs(u[0][1]-z[0][1]))

Submission status: Runtime Error

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

for i in range(n):
    if u[i][2] == 0:
        u[i].pop(2)
z=[]
c =0
for cx in range(101):
    for cy in range(101):
        c = u[0][2]+abs(u[0][0]-cx)+abs(u[0][1]-cy)
        for j in u:
            if c != j[2]+abs(j[0]-cx)+abs(j[1]-cy):
                break
        else:
            z.append((cx,cy))

print(z[0][0],z[0][1],u[0][2]+abs(u[0][0]-z[0][0])+abs(u[0][1]-z[0][1]))

Submission status: Runtime Error

Solution code:
N = int(input())
data = [tuple(map(int, input().split())) for _ in range(N)]
data.sort(key=lambda x: x[2])
for cx in range(101):
    for cy in range(101):
        h0 = None
        for x, y, h in data:
            if h:
                h_tmp = h + abs(cx - x) + abs(cy - y)
                if h_tmp != h0 and h0 is not None:
                    break
                h0 = h_tmp
            else:
                if abs(cx - x) + abs(cy - y) < h0:
                    break
        else:
            print(cx, cy, h0)
            exit()

Submission status: Runtime Error

Solution code:
N = int(input())
data = [tuple(map(int, input().split())) for _ in range(N)]
data.sort(key=lambda x: x[2])
for cx in range(101):
    for cy in range(101):
        h0 = None
        for x, y, h in data:
            if h:
                if (h_tmp := h + abs(cx - x) + abs(cy - y)) != h0 and h0 is not None:
                    break
                h0 = h_tmp
            else:
                if abs(cx - x) + abs(cy - y) < h0:
                    break
        else:
            print(cx, cy, h0)
            exit()

Submission status: Runtime Error

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))
    
assert False

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

p,q,r = c[0]
if n == 1:
  print(p,q,r)
  exit()

end = c[-1]
c = c[1:]
for i in range(101):
  for j in range(101):
    chk = abs(p-i)+abs(q-j)+r
    for num,k in enumerate(c):
      x,y,h = k
      if abs(x-i)+abs(y-j)+h != chk and h != 0:
        break
      if k == end:
        ans = (i,j,chk)

print(*ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
c = []
for i in range(n):
  a = [int(i) for i in input().split()]
  c.append(a)

p,q,r = c[0]
c = c[1:]
for i in range(101):
  for j in range(101):
    chk = abs(p-i)+abs(q-j)+r
    for num,k in enumerate(c):
      x,y,h = k
      if abs(x-i)+abs(y-j)+h != chk:
        break
      if num == n-2:
        ans = (i,j,chk)

print(*ans)

Submission status: Runtime Error

Solution code:
n = int(input())
t = [list(map(int,input().split())) for i in range(n)]
for x,y,h in t:
    if h > 0:
        a = [x,y,h]            # hが0でない1つの組(地面以外の部分)

for cx in range(101):
    for cy in range(101):
        flag = True
        ch = abs(a[0]-cx) + abs(a[1] - cy) + a[2]     # 高さ
        for x,y,h in t:
            if h != max(ch - abs(x - cx) - abs(y - cy),0):　　　# 高さが条件に合うか 
                flag = False
                break
        if flag:
            print(cx,cy,ch)
            exit()

Submission status: Runtime Error

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

def solve():
  for cx in range(101):
    for cy in range(101):
      H = h+abs(x-cx)+abs(y-cy)
      if all(h == max(H-abs(x-cx)-abs(y-cy), 0) for x,y,h in pos):
        return(cx,cy,H)

cx,cy,H=solve()
print(cx,cy,H)

Submission status: Runtime Error

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

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      edge=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        H = h+abs(x-cx)+abs(y-cy)
        if h == 0:
          if x == cx+H or x == cx-H or y == cy+H or y == cy-H:
            res.append(H)
        else:
          res.append(H)
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

Submission status: Runtime Error

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

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      edge=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        H = h+abs(x-cx)+abs(y-cy)
        if h == 0:
          if (x == cx+H or x == cx-H) or (y == cy+H or x == cy-H):
            res.append(H)
        else:
          res.append(H)
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

Submission status: Runtime Error

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

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if xyhn[k][2] > 0 and tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
            if xyhn[k][2] == 0 and calc_h(cx, cy, xyhn[k]) > 0:
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))

Submission status: Runtime Error

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

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if xyhn[k][2] > 0 and tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
            if xyhn[k][2] <= 0 and tmp_h > 0:
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))

Submission status: Runtime Error

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

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))

Submission status: Runtime Error

Solution code:

n = int(input())
xyhn = [None] * n
for i in range(n):
    xyhn[i] = list(map(int, input().split(' ')))

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(1, n):
            if tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))

Submission status: Runtime Error

Solution code:
n = int(input())
hint_ls = [0] * n
for i in range(n):
    x,y,h = map(int,input().split())
    hint_ls[i] = [x,y,h]
target_ls = [[i,j] for i in range(101) for j in range(101)]
for x_target, y_target in target_ls:
    res = True
    for i in range(n):
        x_hint, y_hint, h_hint = hint_ls[i]
        if h_hint != 0:
            h_target_new = h_hint + abs(x_hint - x_target) + abs(y_hint - y_target)
            if i>= 1:
                if not h_target_new == h_target_old:
                    res = False
            h_target_old = h_target_new
        else:
            if h_target_old > abs(x_hint - x_target) + abs(y_hint - y_target):
                res = False
    if res:
        x_ans,y_ans,h_ans = x_target, y_target, h_target_new

print(x_ans, y_ans, h_ans)

Submission status: Runtime Error

Solution code:
n = int(input())
hint_ls = [0] * n
for i in range(n):
    x,y,h = map(int,input().split())
    hint_ls[i] = [x,y,h]
target_ls = [[i,j] for i in range(101) for j in range(101)]
for x_target, y_target in target_ls:
    res = True
    for i in range(n):
        x_hint, y_hint, h_hint = hint_ls[i]
        h_target_new = h_hint + abs(x_hint - x_target) + abs(y_hint - y_target)
        if i>= 1:
            if not h_target_new == h_target_old:
                res = False
        h_target_old = h_target_new
    if res:
        x_ans,y_ans,h_ans = x_target, y_target, h_target_new

print(x_ans, y_ans, h_ans)

Submission status: Runtime Error

Solution code:
from itertools import combinations
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = []
grids = [(i, j) for i in range(101) for j in range(101)]
grids_set = set(grids)
for i in range(n):
    coords.append(tuple(map(int, input().split())))
xr, yr, hr = coords[0]
for i, j in combinations(coords, 2):
    xi, yi, hi = i
    xj, yj, hj = j
    for grid in grids:
        x, y = grid
        if dis(xi, x, yi, y) + hi != dis(xj, x, yj, y) + hj:
            grids_set.remove(grid)
    grids = list(grids_set)
x, y = grids[0]
print(x, y, dis(x, xr, y, yr)+hr)

Submission status: Runtime Error

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

candidate = lambda xyh, cx, cy: abs(xyh[0] - cx) + abs(xyh[1] - cy) + xyh[2]

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        found = True
        candidates = [candidate(xyhi, cx, cy) for xyhi in xyh]

        found = True
        height = None
        for candidate in candidates:
            if candidate < 0: continue
            if height is None:
                height = candidate
                continue
            if candidate != height:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

Submission status: Runtime Error

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

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        height = abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy) + xyh[0][2]
        foo = [(abs(x - cx) + abs(y - cy) + h == height or (abs(x - cx) + abs(y - cy) + h == 0) for x, y, h in xyh]
        found = all(foo)
        if found: break
    if found: break
print(cx, cy, height)

Submission status: Runtime Error

Solution code:
size = 101
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
ans = None
for i in range(size):
  for j in range(size):
    # 高いほうに持ち上げるよう試みて、整合性とれなければ却下
    max_h = None
    succ = True
    for x, y, h in points:
      tmp = abs(i-x) + abs(j-y) + h
      if max_h == None:
        max_h = tmp
        continue
      else:
        if max_h != tmp:
          succ = False
          break
    if succ:
      ans = (i, j, max_h)
      break
  if succ: break
print('{} {} {}'.format(ans[0], ans[1], ans[2]))

Submission status: Runtime Error

Solution code:
n = int(input())
points = [tuple(map(int, input().split())) for _ in range(n)]
size = 101
ans = None
for i in range(size):
  for j in range(size):
    # 高いほうに持ち上げるよう試みて、整合性とれなければ却下
    max_h = 0
    succ = True
    for x, y, h in points:
      tmp = abs(i-x) + abs(j-y) + h
      if max_h == 0:
        max_h = tmp
        continue
      else:
        if max_h != tmp:
          succ = False
          break
    if succ:
      ans = (i, j, max_h)
      break
  if succ: break
print('{} {} {}'.format(ans[0], ans[1], ans[2]))

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors


cnd = make_divisors(m)

for i in range(len(cnd)):
    if m // cnd[i] >= n:
        print(cnd[i])
        exit()

Submission status: Runtime Error

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        l = 0
        while h[l] == 0:
            l += 1
        #print(l)
        val = h[l] + abs(i-x[l]) + abs(j-y[l])
        flg = True
        for k in range(n):
            if val != h[k] + abs(i-x[k]) + abs(j-y[k]) and h[k] != 0:
                flg = False
            if h[k] == 0 and val != abs(i-x[k]) + abs(j-y[i]) and val - abs(i-x[k]) - abs(j-y[k]) == 0:
                flg = False
        if flg == True:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        l = 0
        while h[l] == 0:
            l += 1
        #print(l)
        val = h[l] + abs(i-x[l]) + abs(j-y[l])
        flg = True
        for k in range(n):
            if val != h[k] + abs(i-x[k]) + abs(j-y[k]) and h[k] != 0:
                flg = False
            if h[k] == 0 and val != abs(i-x[k]) + abs(j-y[i]) and val - abs(i-x[k]) - abs(j-y[k]) == 0:
                flg == False
        if flg == True:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        l = 0
        while h[l] == 0:
            l += 1
        #print(l)
        val = h[l] + abs(i-x[l]) + abs(j-y[l])
        flg = True
        for k in range(n):
            if val != h[k] + abs(i-x[k]) + abs(j-y[k]) and h[k] != 0:
                flg = False
            if h[k] == 0 and val != abs(i-x[k]) + abs(j-y[i]) and val - (i-x[k]) - (j-y[k]) == 0:
                flg == False
        if flg == True:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        l = 0
        while h[l] == 0:
            l += 1
        #print(l)
        val = h[l] + abs(i-x[l]) + abs(j-y[l])
        flg = True
        for k in range(n):
            if val != h[k] + abs(i-x[k]) + abs(j-y[k]) and h[k] != 0:
                flg = False
            if h[0] == 0 and val != abs(i-x[k]) + abs(j-y[i]) and val - (i-x[k]) - (j-y[k]) == 0:
                flg == False
        if flg == True:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
N = int(input())

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

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(1, N):
            if A[i][2] > 0:
                    if H != A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y):
                        Flag = False
                        break
            else:
                if H > abs(A[i][0]-x)+abs(A[i][1]-y):
                    Flag = False
                    break
        if Flag == True:
            print(x, y, h)

Submission status: Runtime Error

Solution code:
N = int(input())
x = [None]*N
y = [None]*N
h = [None]*N

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

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        else:
            if H-abs(X-x[n])-abs(Y-y[n])>0:
            return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            H = height(X,Y,x[n],y[n],h[n])
            if check(x,y,h,X,Y,H) is True:
                print(X,Y,H)
                exit()

Submission status: Runtime Error

Solution code:
n = int(input())
data = []
for i in range(n):
    xi,yi,hi = map(int,input().split())
    data.append((xi,yi,hi))
lst = [[] for _ in range(n)]
data.sort(key = lambda x:x[2],reverse = True)
x,y,h = data[0]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(1,n):
    xi,yi,hi = data[i]
    if hi > 0:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi)+hi == h:
                lst[i].append((x,y,h))
    else:
        for x,y,h in lst[i-1]:
            if abs(x-xi)+abs(y-yi) >= h:
                lst[i+1].append((x,y,h))
print(*lst[n-1][0])

Submission status: Runtime Error

Solution code:
n = int(input())
x,y,h = map(int,input().split())
if n == 1:
    print(x,y,h)
    exit()
lst = [[] for _ in range(n)]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(n-1):
    xi,yi,hi = map(int,input().split())
    for x,y,h in lst[i]:
        if abs(x-xi)+abs(y-yi)+hi == h:
            lst[i+1].append((x,y,h))
print(*lst[n-1][0])

Submission status: Runtime Error

Solution code:
n = int(input())
x,y,h = map(int,input().split())
lst = [[] for _ in range(n)]
for i in range(101):
    for j in range(101):
        lst[0].append((i,j,h+abs(i-x)+abs(j-y)))
for i in range(n-1):
    xi,yi,hi = map(int,input().split())
    for x,y,h in lst[i]:
        if abs(x-xi)+abs(y-yi)+hi == h:
            lst[i+1].append((x,y,h))
print(*lst[n-1][0])

Submission status: Runtime Error

Solution code:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,z))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for i in range(len(late)):
      x,y,h=late[i]
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)

Submission status: Runtime Error

Solution code:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    late=[]
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        late.append((x,y,z))
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    for x,y,h in late:
      if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
    if isans:
      print(cx, cy, H)

Submission status: Runtime Error

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

ans = []
for X in range(101):
    for Y in range(101):
        flag = True
        height = []
        for i in range(n):
            height.append(h[i]+abs(x[i]-X)+abs(y[i]-Y))
        for i in range(n):
            if height[i] != height[0]:
                flag = False

        if flag:
            ans.append(X)
            ans.append(Y)
            ans.append(height[0])
            break

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

Submission status: Runtime Error

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

ans = []
for X in range(101):
    for Y in range(101):
        flag = True
        height = []
        for i in range(n):
            height.append(max(h[i]+abs(x[i]-X)+abs(y[i]-Y),0))
        for i in range(n):
            if height[i] != height[0]:
                flag = False

        if flag:
            ans.append(X)
            ans.append(Y)
            ans.append(height[0])
            break

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

Submission status: Runtime Error

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

ans = []
for X in range(101):
    for Y in range(101):
        flag = True
        height = []
        for i in range(n):
            height.append(h[i]+abs(x[i]-X)+abs(y[i]-Y))
        for i in range(len(height)):
            if height[i] != height[0]:
                flag = False

        if flag:
            ans.append(X)
            ans.append(Y)
            ans.append(height[0])
            break

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

Submission status: Runtime Error

Solution code:
def main():
    from itertools import product

    n, *xyh = map(int, open(0).read().split())
    a = range(101)

    if n - xyh[2::3].count(0) == 1:
        i = xyz[2::3].index(1)
        print(xyh[i])
        return
    a = range(101)
    for x, y in product(a, a):
        l = None
        for i, j, h in zip(*[iter(xyh)] * 3):
            ll = h + abs(x - i) + abs(y - j)
            if l:
                if ll != l:
                    break
            else:
                l = ll
        else:
            print(x, y, l)
            return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    from itertools import product

    n, *xyh = map(int, open(0).read().split())
    a = range(101)

    if n - xyh[2::3].count(0) == 1:
        i = xyz[2::3].index(1)
        print(xyh[i])
        return
    a = range(101)
    for x, y in product(a, a):
        l = None
        for i, j, h in zip(*[iter(xyh)] * 3):
            ll = h + abs(x - i) + abs(y - j)
            if l:
                if ll != l:
                    break
            else:
                l = ll
    else:
        print(x, y, l)
        return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    from itertools import product

    n, *xyh = map(int, open(0).read().split())
    a = range(101)

    if n - xyh[2::3].count(0) == 1:
        i = xyz[2:;
        3].index(1)
        print(xyh[i])
        return
    a = range(101)
    for x, y in product(a, a):
        l = None
        for i, j, h in zip(*[iter(xyh)] * 3):
            ll = h + abs(x - i) + abs(y - j)
            if l:
                if ll != l:
                    break
            else:
                l = ll
    else:
        print(x, y, l)
        return


if __ name__ == '__main__':
    main()

Submission status: Runtime Error

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

def func():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh if el[2]!=0]
            if H>=1 and len(set(H))==1:
                temp=[H[0]-abs(el[0]-Cx)-abs(el[0]-Cy) for el in xyh if el[2]==0]
                for el in temp:
                    if el>0:
                        break
                else:
                    print(Cx, Cy, H[0])
                    return None
func()

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<int> x(N), y(N), h(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x[i] >> y[i] >> h[i];
  }

  int MAX = 100;

  for (int posY = 0; posY <= MAX; posY++)
  {
    for (int posX = 0; posX <= MAX; posX++)
    {
      // 頂上がどれくらいの高さであって欲しいか
      // -1はまだよくわからない時。0以上は確定してる時
      // -2はダメだってわかった時
      int needH = -1;

      for (int i = 0; i < N; i++)
      {
        if (h[i] > 0)
        {
          //この頂点から見て、頂上がposY, posXの時に、
          // どれくらいの高さがあって欲しいかとを求める
          int tmp = h[i] + abs(posY - y[i]) + abs(posX = x[i]);
          if (needH == -1)
          {
            needH = tmp;
          }
          else
          {
            if (needH != tmp)
            {
              needH = -2;
              break;
            }
          }
        }
      }
      // ダメだったら他の場所を探す
      if (needH == -2)
        continue;

      for (int i = 0; i < N; i++)
      {
        if (h[i] == 0)
        {
          int dist = abs(posY - y[i]) + abs(posX - x[i]) if (needH > dist)
          {
            needH = -2;
            break;
          }
        }
      }

      if (needH == -2)
        continue;

      cout << posX << " " << posY << " " << needH << endl;
      return 0;
    }
  }
}

Submission status: Runtime Error

Solution code:
raise TypeError

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
{ % if prediction_success % }
{ % endif % }
{ % if mod or yes_str or no_str % }

{ % endif % }
{ % if mod % }
MOD = None  # type: int
{ % endif % }
{ % if yes_str % }
YES = "None"  # type: str
{ % endif % }
{ % if no_str % }
NO = "None"  # type: str
{ % endif % }
{ % if prediction_success % }


def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        points.append((x, y, h))
        if h >= 1:
            hint = (x, y, h)

    for px in range(1, 101):
        for py in range(1, 101):
            H = hint[2] + abs(px-hint[0]) + abs(py-hint[1])
            clearflag = True
            for point in points:
                x, y, h = point
                val = max([H - abs(px-x) - abs(py-y), 0])
                if val != h:
                    clearflag = False

            if clearflag:
                print(px, py, H)
                return
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())

xyh_list = list()

for i in range(N):
    x,y,h = map(int, input().split())
    xyh_list.append((x,y,h))
    
for i in range(N):
    h = xyh_list[i][2]
    if h != 0:
        no_zero_h = i
        break
else:


break_flag = 0

for i in range(0,101):
    for j in range(0,101):
        
        x = xyh_list[no_zero_h][0]
        y = xyh_list[no_zero_h][1]
        h = xyh_list[no_zero_h][2]
        H = h + abs(x-i) + abs(y-j)
        
        if 1 <= H:
            for k in range(0,N):
                x = xyh_list[k][0]
                y = xyh_list[k][1]
                h = xyh_list[k][2]
                
                if h + abs(x-i) + abs(y-j) != H:
                    break
            else:
                print(i,j,H)
                break_flag = 1
                
        if break_flag == 1:
            break
            
    if break_flag == 1:
        break

Submission status: Runtime Error

Solution code:
n = int(input())

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

G = []
for x, y, h in XYH:
	if h >= 1:
		G.append((x, y, h))

for cx in range(0, 101):
	for cy in range(0, 101):

		x, y, h = G
		H = abs(x-cx) + abs(y-cy) + h

		if all([h == H - abs(x-cx) - abs(y-cy) for x, y, h in XYH]):
			print(cx, cy, H)
			exit()