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())
x=[]
y=[]
h=[]
for i in range(N):
    x_n,y_n,h_n=map(int,input().split())
    if h_n !=0:
        x.append(x_n)
        y.append(y_n)
        h.append(h_n)

def all_same(a):
    if all(a[i]==a[i+1] for i in range(0,len(a)-1)):
        return True
    else:
        return False

for C_x in range(101):
    for C_y in range(101):
        H=[]
        for i in range(N):
            H.append(h[i]+abs(x[i]-C_x)+abs(y[i]-C_y))
        H.sort()
        if all_same(H):
            print(C_x,C_y,H[0])

Submission status: Runtime Error

Solution code:
# coding: utf-8


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

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

    for coordinate in coordinates:
        if coordinate[2] > 0:
            xx = coordinate[0][0]
            yy = coordinate[0][1]
            hh = coordinate[0][2]
            break

    for px in range(101):
        for py in range(101):
            ph = hh + abs(xx - px) + abs(yy - py)

            if ph <= 0:
                continue

            suit = True
            for coordinate in coordinates:
                if coordinate[2] != ph - abs(coordinate[0] - px) - abs(coordinate[1] - py):
                    suit = False
                    break

            if suit == True:
                print(px, py, ph)
                return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
# coding: utf-8


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

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

    for co in coordinate:
        if coordinate[0][2] > 0:
            xx = coordinate[0][0]
            yy = coordinate[0][1]
            hh = coordinate[0][2]

    for px in range(101):
        for py in range(101):
            ph = hh + abs(xx - px) + abs(yy - py)

            if ph <= 0:
                continue

            suit = True
            for co in coordinate:
                if co[2] != ph - abs(co[0] - px) - abs(co[1] - py):
                    suit = False
                    break

            if suit == True:
                print(px, py, ph)
                return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[-1] * FIELD_SIZE for n in range(FIELD_SIZE)]
under_flag = True

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):
            if h[n] != 0:
                under_flag = False

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if H[cx][cy] == -1:
                H[cx][cy] = ch
            elif under_flag and ch <= H[cx][cy]:
                H[cx][cy] = ch
            elif h[n] != 0 and H[cx][cy] == ch:
                H[cx][cy] = ch
            elif h[n] == 0 and H[cx][cy] <= ch:
                pass
            else:
                H[cx][cy] = None

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] is not None:
            print(cx, cy, H[cx][cy])

Submission status: Runtime Error

Solution code:
N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[-1] * FIELD_SIZE for n in range(FIELD_SIZE)]
under_flag = True

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):
            if h[n] != 0:
                under_flag = False

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if H[cx][cy] == -1:
                H[cx][cy] = ch
            elif under_flag and ch <= H[cx][cy]:
                H[cx][cy] = ch
            elif H[cx][cy] == ch:
                H[cx][cy] = ch
            else:
                H[cx][cy] = None

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] is not None:
            print(cx, cy, H[cx][cy])

Submission status: Runtime Error

Solution code:
N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[-1] * FIELD_SIZE for n in range(FIELD_SIZE)]
under_flag = True

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):
            if h[n] != 0:
                under_flag = False

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if H[cx][cy] == -1:
                H[cx][cy] = ch
            elif under_flag and H[cx][cy] <= ch:
                H[cx][cy] = ch
            elif H[cx][cy] == ch:
                H[cx][cy] = ch
            else:
                H[cx][cy] = None

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] is not None:
            print(cx, cy, H[cx][cy])

Submission status: Runtime Error

Solution code:
import sys

def get_height(h, x, y, cx, cy):
	return h + abs(x - cx) + abs(y - cy)

n = int(input())
x = []
y = []
h = []
for _ in range(n):
	xi, yi, hi = map(int, input().split())
	if hi == 0:
		continue
	x.append(xi)
	y.append(yi)
	h.append(hi)

for cx in range(101):
	for cy in range(101):
		height = get_height(h[0], x[0], y[0], cx, cy)
        is_valid = True
		for i in range(1, len(x)):
			if height != get_height(h[i], x[i], y[i], cx, cy):
            	is_valid = False
				break
		if is_valid:
			print(cx, cy, height)
			sys.exit()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from operator import itemgetter
def solve():
    Z = sorted([tuple(map(int,input().split())) for _ in range(int(input()))], key=itemgetter(2) , reverse=True)
    x0, y0, h0 = Z[0]
    H = h0 + np.abs(np.arange(101, dtype=int).reshape(1,101)-x0) + np.abs(np.arange(101, dtype=int).reshape(101,1)-y0)
    return [' '.join(map(str, [i,j,h])) for (i,j),h in np.ndenumerate(H) if all(h == max(H[i,j]-abs(x-i)-abs(y-j),0) for x,y,h in Z)][0]

if __name__ == '__main__':
    print(solve())

Submission status: Runtime Error

Solution code:


def func():

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




    for cx in range(101):
        for cy in range(101):
            for line in data:
                if data[2] != 0:
                    x = data[i][0]
                    y = data[i][1]
                    h = data[i][2]
                    H_max = h + abs(cx - x) + abs(cy - y)
                    break
            flag = True
            for i in range(n):
                    x = data[i][0]
                    y = data[i][1]
                    h = data[i][2]
                    if h != 0:
                        if not H_max == h + abs(cx-x) + abs(cy-y):
                            flag = False
                            break
                    else:
                        if not H_max <=  abs(cx-x) + abs(cy-y):
                            flag = False
                            break
            if flag:
                print(cx,cy,H_max)
                return 0

func()

Submission status: Runtime Error

Solution code:


def func():

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




    for cx in range(101):
        for cy in range(101):
            for line in data:
                if data[2] != 0:
                    x = data[i][0]
                    y = data[i][1]
                    h = data[i][2]
                    H_max = h + abs(cx - x) + abs(cy - y)
            flag = True
            for i in range(n):
                    x = data[i][0]
                    y = data[i][1]
                    h = data[i][2]
                    if h != 0:
                        if not H_max == h + abs(cx-x) + abs(cy-y):
                            flag = False
                            break
                    else:
                        if not H_max <=  abs(cx-x) + abs(cy-y):
                            flag = False
                            break
            if flag:
                print(cx,cy,H_max)
                return 0

func()

Submission status: Runtime Error

Solution code:


def func():

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

    for cx in range(101):
        for cy in range(101):
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                if h == 0:
                    for i in range(h1):
                        if not h1 in dict:
                            dict[h1] = 0
                        else:
                            dict[h1] += 1

                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()

Submission status: Runtime Error

Solution code:


def func():

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

    for cx in range(101):
        for cy in range(101):
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                if h == 0:
                    for i in range(h1):
                        # if i == 0:
                        #     continue
                        if not h1 in dict:
                            dict[h1] = 0
                        else:
                            dict[h1] += 1

                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()

Submission status: Runtime Error

Solution code:


def func():

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

    for cx in range(101):
        for cy in range(101):
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                if h == 0:
                    for i in range(h1):
                        if i == 0:
                            continue
                        if not h1 in dict:
                            dict[h1] = 0
                        else:
                            dict[h1] += 1

                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()

Submission status: Runtime Error

Solution code:
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


def solve():
    for cx in range(101):
        for cy in range(101):
            ch = D[0][0] + abs(D[0][1] - cx) + abs(D[0][2] - cy)
            for h, x, y in D:
                if h != max(ch - (abs(x - cx) + abs(y - cy)), 0):
                    break
            else:
                return cx, cy, ch


if __name__ == '__main__':
    N = int(input())
    D = []
    for i in range(N):
        x, y, h = inpl()
        D.append([h, x, y])

    h_min = max(D)[0]
    ans = solve()
    print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


def solve():
    for cx in range(101):
        for cy in range(101):
            ch = D[0][0] + abs(D[0][1] - cx) + abs(D[0][2] - cy)
            for h, x, y in D:
                if h != ch - (abs(x - cx) + abs(y - cy)):
                    break
            else:
                return cx, cy, ch


if __name__ == '__main__':
    N = int(input())
    D = []
    for i in range(N):
        x, y, h = inpl()
        D.append([h, x, y])

    h_min = max(D)[0]
    ans = solve()
    print(' '.join(map(str, ans)))

Submission status: Runtime Error

Solution code:
import math
import sys

def ds(xk, yk, x, y):
    return (abs(xk - x) + abs(yk - y))

N = int(sys.stdin.readline())
A = sys.stdin.readlines()
A = [x.strip().split(" ") for x in A]
A = [[int(x) for x in y]for y in A]

koho = [[0] * 101 for i in range(101)]
ans = 1

# 基準となる要素
a1 = []

# 高さ>0の要素をとってくる（元のリストから抜かす）
for a in A:
    if a[2] > 0:
        a1 = a
        A.remove(a)
        break

for x in range(0,101):
    for y in range(0,101):
        koho[x][y] = ds(a1[0], a1[1], x, y) + a1[2]

# print(koho)

for x in range(0,101):
    for y in range(0,101):
        flag = 1
        h = koho[x][y]
        
        if (h > 1000000000) | (h <= 0):
            flag = 0
            continue
        for a in A:
            if a[2] != max(h - ds(a[0], a[1], x, y), 0):
                # このループから抜ける
                flag = 0
                break
        if flag == 1:
            ans = [x, y, h]
            # 解がみつかったのでyのループをbreak
            break
    # xのループ
    if flag == 1:
        break

#print(koho)
ans = " ".join(map(str, ans))
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sys

def ds(xk, yk, x, y):
    return (abs(xk - x) + abs(yk - y))

N = int(sys.stdin.readline())
A = sys.stdin.readlines()
A = [x.strip().split(" ") for x in A]
A = [[int(x) for x in y]for y in A]

koho = [[0] * 101 for i in range(101)]
ans = 1

# 基準となる要素
a1 = []

# 高さ>0の要素をとってくる（元のリストから抜かす）
for a in A:
    if a[2] > 0:
        a1 = a
        A.remove(a)
        break
print(a1)
for x in range(0,101):
    for y in range(0,101):
        koho[x][y] = ds(a1[0], a1[1], x, y) + a1[2]

# print(koho)

for x in range(0,101):
    for y in range(0,101):
        flag = 1
        h = koho[x][y]
        
        if (h > 1000000000) | (h <= 0):
            flag = 0
            continue
        for a in A:
            if a[2] != max(h - ds(a[0], a[1], x, y), 0):
                # このループから抜ける
                flag = 0
                break
        if flag == 1:
            ans = [x, y, h]
            # 解がみつかったのでyのループをbreak
            break
    # xのループ
    if flag == 1:
        break

#print(koho)
ans = " ".join(map(str, ans))
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sys

def ds(xk, yk, x, y):
    return (abs(xk - x) + abs(yk - y))

N = int(sys.stdin.readline())
A = sys.stdin.readlines()
A = [x.strip().split(" ") for x in A]
A = [[int(x) for x in y]for y in A]

koho = [[0] * 101 for i in range(101)]
ans = 1

a1 = A[0]

for x in range(0,101):
    for y in range(0,101):
        koho[x][y] = ds(a1[0], a1[1], x, y) + a1[2]

#print(koho)

for x in range(0,101):
    for y in range(0,101):
        flag = 1
        h = koho[x][y]
        
        if (h > 1000000000) | (h <= 0):
            flag = 0
            continue
        for a in A[1:]:
            if h != ds(a[0], a[1], x, y) + a[2]:
                # このループから抜ける
                flag = 0
                break
        if flag == 1:
            ans = [x, y, h]
            # 解がみつかったのでyのループをbreak
            break
    # xのループ
    if flag == 1:
        break

#print(koho)
ans = " ".join(map(str, ans))
print(ans)

Submission status: Runtime Error

Solution code:
import math
def ds(xk, yk, x, y):
    return (abs(xk - x) + abs(yk - y))

koho = [[0] * 101 for i in range(101)]
ans = 1

a1 = A[0]

for x in range(0,101):
    for y in range(0,101):
        koho[x][y] = ds(a1[0], a1[1], x, y) + a1[2]

#print(koho)

for x in range(0,101):
    for y in range(0,101):
        flag = 1
        h = koho[x][y]
        ans = [x, y, h]
        if (h > 1000000000) | (h <= 0):
            flag = 0
            continue
        for a in A[1:]:
            if h != ds(a[0], a[1], x, y) + a[2]:
                # このループから抜ける
                flag = 0
                break
        if flag == 1:
            # 解がみつかったのでyのループをbreak
            break
    else:
        # breakされてない
        continue
    break

#print(koho)
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sys

def ds(xk, yk, x, y):
    return (abs(xk - x) + abs(yk - y))

N = int(sys.stdin.readline())
A = sys.stdin.readlines()
A = [x.strip().split(" ") for x in A]
A = [[int(x) for x in y]for y in A]

koho = [[0] * 101 for i in range(101)]
ans = 1

a1 = A[0]

for x in range(0,101):
    for y in range(0,101):
        koho[x][y] = ds(a1[0], a1[1], x, y) + a1[2]

#print(koho)

for x in range(0,101):
    for y in range(0,101):
        flag = 1
        ans = [x, y, koho[x][y]]
        if koho[x][y] > 1000000000:
            flag = 0
            break
        for a in A[1:]:
            if koho[x][y] != ds(a[0], a[1], x, y) + a[2]:
                flag = 0
                break
        if flag == 1:
            break
    else:
        continue
    break

#print(koho)
print(" ".join(ans))

Submission status: Runtime Error

Solution code:
N = int(input())
pos = [list(map(int, input().split())) for _ in range(N)]
for cx in range(101):
    for cy in range(101):
        minH = 1 << 29
        se = set()
        for x,y,h in pos:
            a = -abs(x-cx)-abs(y-cy)
            if h <= a:
                break
            elif h == 0:
                minH = min(minH, -a)
            else:
                se.add(h-a)
        else:
            if len(se) == 0 and minH == 1:
                print(cx, cy, hh)
            elif len(se) == 1:
                hh = se.pop()
               if hh <= minH:
                   print(cx, cy, hh)

Submission status: Runtime Error

Solution code:
n = int(input())
lis = []
for i in range(n):
  a = list(map(int,input().split()))
  if a[2] != 0:lis.append(a)
if len(lis) == 1:
  print(lis[0][0],lis[0][1],lis[0][2])
  exit()
for x in range(101):
  for y in range(101):
    co = abs(x -lis[0][0])+abs(y -lis[0][1])+lis[0][2]
    for j in range(1,n):
      if lis[j][2] != 0 and co != abs(x -lis[j][0])+abs(y -lis[j][1])+lis[j][2]:
        break
      if j == n-1:
        print(x,y,co)
        exit()

Submission status: Runtime Error

Solution code:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
ans = []
for x in range(101):
  for y in range(101):
    co = abs(x -lis[0][0])+abs(y -lis[0][1])+lis[0][2]
    for j in range(n):
      if co != abs(x -lis[j][0])+abs(y -lis[j][1])+lis[j][2]:
        break
      if j == n-1:
        ans.append([x,y,co])
print(ans[0][0],ans[0][1],ans[0][2])

Submission status: Runtime Error

Solution code:
# Pyramid
n = int(input())
x, y, h = [], [], []
flag = True
ans_x, ans_y, ans_h = 0, 0, 0
for i in range(n):
    _x_, _y_, _h_ = map(int, input().split())
    if _h_ == 0:
        break
    x.append(_x_)
    y.append(_y_)
    h.append(_h_)
for cx in range(101):
    for cy in range(101):
        for j in range(n):
            h_ = h[j] + abs(x[j] - cx) + abs(y[j] - cy)
            if flag is True:
                flag = h_
            elif flag == h_:
                if j == n - 1:
                    ans_x, ans_y, ans_h = cx, cy, h_
                else:
                    pass
            else:
                flag = True
                break
print('{0} {1} {2}'.format(ans_x, ans_y, ans_h))

Submission status: Runtime Error

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

a,b,c = p[0]
for x in range(101):
  for y in range(101):
    h = c+abs(a-x)+abs(b-y)
	if all(k==h-abs(i-x)-abs(j-y) for i,j,k in p):
      print(x,y,h)
      exit()

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
sqrt = int(math.sqrt(M)) + 1
ans = 0
for i in range(1, sqrt):
    if M % i == 0:
        if ans < i <= M//N:
            ans = i
        if ans < M//i <= M//N:
            ans = M//i
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
data = list()
for i in range(N):
    x,y,h = (int(i) for i in input().split())
    data.append((x,y,h))
for c_x in range(0,101):
    for c_y in range(0,101):
        for x_i,y_i,h_i in data:
            if int((h_i + abs(x_i - c_x) + abs(y_i - c_y))) >= 1:
                H_set.append(int(h_i + abs(x_i - c_x) + abs(y_i - c_y)))
        H_set = set(H_set)
        if len(H_set) == 1:
            H_set = list(H_set)
            print(c_x,c_y,H_set[0])
            H_set = list()

Submission status: Runtime Error

Solution code:
import sys
N = int(input())
data = list()
for i in range(N):
    x,y,h = (int(i) for i in input().split())
    data.append((x,y,h))
H_set = list()
for c_x in range(0,101):
    for c_y in range(0,101):
        H_set = list()
        for x_i,y_i,h_i in data:
            if (h_i + abs(x_i - c_x) + abs(y_i - c_y)) >= 0:
                H_set.append(int(h_i + abs(x_i - c_x) + abs(y_i - c_y)))
            H_set = set(H_set)
        if len(H_set) == 1:
            H_set = list(H_set)
            print(c_x,c_y,H_set[0])
            sys.exit()

Submission status: Runtime Error

Solution code:
N = int(input())
data = list()
for i in range(N):
    x,y,h = (int(i) for i in input().split())
    data.append((x,y,h))
H_set = list()
for c_x in range(0,101):
    for c_y in range(0,101):
        for x_i,y_i,h_i in data:
            if (h_i + abs(x_i - c_x) + abs(y_i - c_y)) >= 0:
                H_set.append(int(h_i + abs(x_i - c_x) + abs(y_i - c_y)))
        H_set = set(H_set)
        if len(H_set) == 1:
            H_set = list(H_set)
            print(c_x,c_y,H_set[0])
    H_set = list()

Submission status: Runtime Error

Solution code:
N = int(input())
data = list()
for i in range(N):
    x,y,h = (int(i) for i in input().split())
    data.append((x,y,h))
H_set = list()
for c_x in range(0,101):
    for c_y in range(0,101):
        for x_i,y_i,h_i in data:
            if (h_i + abs(x_i - c_x) + abs(y_i - c_y)) >= 0:
                H_set.append(int(h_i + abs(x_i - c_x) + abs(y_i - c_y)))
        H_set = set(H_set)
        if len(H_set) == 1:
            H_set = list(H_set)
            print(c_x,c_y,H_set[0])
            exit()
    H_set = list()

Submission status: Runtime Error

Solution code:
N = int(input())
data = list()
for i in range(N):
    x,y,h = (int(i) for i in input().split())
    data.append((x,y,h))
H_set = list()
for c_x in range(0,101):
    for c_y in range(0,101):
        for x_i,y_i,h_i in data:
            if (h_i + abs(x_i - c_x) + abs(y_i - c_y)) >= 0:
                H_set.append(int(h_i + abs(x_i - c_x) + abs(y_i - c_y)))
        H_set = set(H_set)
        if len(H_set) == 1:
            H_set = list(H_set)
            print(c_x,c_y,H_set[0])
    else:
        H_set = list()

Submission status: Runtime Error

Solution code:
N=int(input())
A=[]
for j in range(N):
    a=[int(i) for i in input().split()]
    A.append(a)
for i in range(0,101):
    for j in range(0,101):
        HH=[]
        P=[]
        for k in range(N):
            if A[k][2]==0:
                if 1>abs(A[k][0]-i)+abs(A[k][1]-j):
                    break
                else:
                    Q=abs(A[k][0]-i)+abs(A[k][1]-j)
                    P.append(Q)
                    if k==N-1:
                        if len(P)==0:
                            print("{} {} {}".format(i,j,HH[0]))
                            break
                        elif H<=max(P):
                            print("{} {} {}".format(i,j,HH[0]))
                        else:
                            break
                    else:
                        continue
            else:
                H=A[k][2]+abs(A[k][0]-i)+abs(A[k][1]-j)
                if len(HH)==0:
                    HH.append(H)
                    continue
                if H in HH:
                    HH.append(H)
                    if k==N-1:
                        if len(P)==0:
                            print("{} {} {}".format(i,j,H))
                        elif H<=max(P):
                            print("{} {} {}".format(i,j,h))
                        else:
                            break
                    else:
                        continue
                else:
                    break

Submission status: Runtime Error

Solution code:
N = int(input())
xyh = [[int(i) for i in input().split()] for j in range(N)]
for i in range(0,101):
    for j in range(0,101):
        for k in range(N):
            if xyh[k][2] == 0:
                break
            else:
                H0 = xyh[0][2] + abs(i-xyh[0][0]) + abs(j-xyh[0][1])
                flag = True
                for k in xyh:
                    x = k[0] ; y = k[1] ; h = k[2]
                    H = h+abs(i-x)+abs(j-y)
                    if H0 != H:
                        flag = False
                        break
                if flag == True:
                    break
        if flag == True:
            break
    if flag == True:
        break
print (*[i,j,H])