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())
xyh=[]
for i in range(n):
    xyh.append(list(map(int,input().split(" "))))
for i in range(n):
    if xyh[i][2]==0:
        xyh.remove(xyh[i])
    else:
        pass

cx=0
while cx<=100:
    cy=0
    while cy<=100:
        i=0
        while  i<=len(xyh)-2:
            if abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2]-abs(cx-xyh[i+1][0])-abs(cy-xyh[i+1][1])-xyh[i+1][2]==0:
                i+=1
            else:
                break
            
            if i==len(xyh)-1:
                print("{} {} {}".format(cx,cy,abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]))
        cy+=1
    cx+=1

Submission status: Runtime Error

Solution code:
n=int(input())
xyh=[]
for i in range(n):
    xyh.append(list(map(int,input().split(" "))))
for i in range(n):
    if xyh[i][2]==0:
        xyh.remove(xyh[i])
    else:
        pass

cx=0
while cx<=100:
    cy=0
    while cy<=100:
        i=0
        while  i<=len(xyh)-2:
            if abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2]-abs(cx-xyh[i+1][0])-abs(cy-xyh[i+1][1])-xyh[i+1][2]==0:
                i+=1
            else:
                break
            
            if i==len(xyh)-1:
                print("{} {} {}".format(cx,cy,abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]))
        cy+=1
    cx+=1n=int(input())
xyh=[]
for i in range(n):
    xyh.append(list(map(int,input().split(" "))))
for i in range(n):
    if xyh[i][2]==0:
        xyh.remove(xyh[i])
    else:
        pass

cx=0
while cx<=100:
    cy=0
    while cy<=100:
        i=0
        while  i<=len(xyh)-2:
            if abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2]-abs(cx-xyh[i+1][0])-abs(cy-xyh[i+1][1])-xyh[i+1][2]==0:
                i+=1
            else:
                break
            
            if i==len(xyh)-1:
                print("{} {} {}".format(cx,cy,abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]))
        cy+=1
    cx+=1

Submission status: Runtime Error

Solution code:
n = int(input())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        H = l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
        for k in range(1,n):
            if not h==max(H-abs(i-l[k][0])-abs(j-l[k][1]), 0):
                break
            if k==n-1 and h>0:
                print(i,j,h)
                import sys
                sys.exit()

Submission status: Runtime Error

Solution code:
N = int(input())
arr = list()
for i in range(N):
  arr.append(tuple(map(int,input().split())))
rtn=None
for i in range(101):
  for j in range(101):
    H=None
    for tk in arr:
      xk,yk,hk = tk
      if hk == 0:
        continue
      if H is None:
        H = abs(i-xk)+abs(j-yk)+hk
        continue
      rtn=(i,j,H)
      Hk = abs(i-xk)+abs(j-yk)+hk
      if H != Hk:
        rtn=None
        break
    if rtn is not None:
      break
  if rtn is not None:
    break
x,y,h=rtn
print(x,y,h)

Submission status: Runtime Error

Solution code:
import sys

def is_center(x, y, P):
  H = [abs(x-p[0]) + abs(y-p[1]) + p[2] for p in P]
  return len(set(H)) == 1

def main():
  input = sys.stdin.readline
  N = int(input())
  P = [[0, 0, 0] for _ in range(N)]
  for i in range(N):
    x, y, h = map(int, input().split())
    P[i][0], P[i][1], P[i][2] = x, y, h
  for i in range(101):
    for j in range(101):
      if is_center(i, j, P):
        h = abs(i - P[0][0]) + abs(j - P[0][1]) + P[0][2]
        ans = '{} {} {}'.format(i, j, h)
        break
 
  print(ans)


if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
def calc_height(xs, ys, hs, cx, cy):
    ret = -1
    zeros = []
    for i in range(len(xs)):
        x = xs[i]
        y = ys[i]
        h = hs[i]
        if h == 0:
            zeors.append((x,y,h))
            continue
        a = abs(x - cx)
        b = abs(y - cy)
        ch = h + a + b
        if ret == -1:
            ret = ch
        else:
            if ret != ch:
                return -1
    for x, y, h in zeros:
        a = abs(x - cx)
        b = abs(y - cy)
        if ret - a - b > 0:
            return -1
    return ret


def solve(xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = calc_height(xs, ys, hs, cx, cy)
            if h > 0:
                return cx, cy, h


n = int(input())
xs = []
ys = []
hs = []
for i in range(n):
    x, y, h = list(map(int, input().split(' ')))
    xs.append(x)
    ys.append(y)
    hs.append(h)


print(' '.join([str(q) for q in solve(xs, ys, hs)]))

Submission status: Runtime Error

Solution code:
def calc_height(xs, ys, hs, cx, cy):
    ret = -1
    for i in range(len(xs)):
        x = xs[i]
        y = ys[i]
        h = hs[i]
        a = abs(x - cx)
        b = abs(y - cy)
        ch = h + a + b
        if ret == -1:
            ret = ch
        else:
            if ret != ch:
                return -1
    return ret


def solve(xs, ys, hs):
    for cx in range(101):
        for cy in range(101):
            h = calc_height(xs, ys, hs, cx, cy)
            if h > 0:
                return cx, cy, h


n = int(input())
xs = []
ys = []
hs = []
for i in range(n):
    x, y, h = list(map(int, input().split(' ')))
    xs.append(x)
    ys.append(y)
    hs.append(h)


print(' '.join([str(q) for q in solve(xs, ys, hs)]))

Submission status: Runtime Error

Solution code:
n = int(input())
data = [tuple(map(int, input().split())) for _ in range(n)]
ax, ay, ah = list(filter(lambda x:x[2], data))[0]

for cx in range(101):
    for cy in range(101):
        H = h + abs(ax-cx) + abs(ay-cy)
        if all(max(H-abs(d[0]-cx)-abs(d[1]-cy),0)==d[2]) for d in data):
            print(cx, cy, H)
            exit()

Submission status: Runtime Error

Solution code:
n = int(input())
X = []
Y = []
H = []

for _ in range(n):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for cx in range(101):
    for cy in range(101):
        flg = False
        # print(cx, cy)
        tmp = None
        for k in range(n):
            # print(tmp)
            if H[k] == 0 and tmp<abs(cx-X[k])+abs(cy-Y[k]):
                flg = True
                break
            elif H[k] == 0:
                continue
            elif not tmp:
                tmp = H[k]+abs(cx-X[k])+abs(cy-Y[k])
                continue
            elif tmp == H[k]+abs(cx-X[k])+abs(cy-Y[k]):
                continue
            else:
                flg = True 
                break
        if flg:
            continue
        else:
            print(cx, cy, tmp)
            exit()

Submission status: Runtime Error

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

x,y,k=-1,-1,-1
n=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        n=o
for i in range(101):
    for j in range(101):
        h=a[n][2]+abs(a[n][0]-i)+abs(a[n][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Submission status: Runtime Error

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

x,y,k=-1,-1,-1
n=-1
for o in range(n):
    a.append(list(map(int,input().split())))
    if a[o][2] != 0:
        n=o
for i in range(101):
    for j in range(101):
        h=a[o][2]+abs(a[o][0]-i)+abs(a[o][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Submission status: Runtime Error

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

x,y,k=-1,-1,-1
n=-1
for _ in range(n):
    a.append(list(map(int,input().split())))
    if a[_][2] != 0:
        n=i
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Submission status: Runtime Error

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

x,y,k=-1,-1,-1

for _ in range(n):
    s=list(map(int,input().split()))
    if s[2] != 0:
        a.append(s)
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Submission status: Runtime Error

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

x,y,k=-1,-1,-1

for _ in range(n):
    s=list(map(int,input().split()))
    if s[2] != 0:
        a.append(s)
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            elif a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for _ in range(n):
    s=list(map(int,input().split()))
    if s[2] != 0:
        a.append(s)
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            elif a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,h = i,j,h
            print(x,y,h)

Submission status: Runtime Error

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

for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            if plist[2] == 0:
                continue
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2] or diff + i[2] == 0:
                    break
        else:
            print("{} {} {}".format(x, y, h))

Submission status: Runtime Error

Solution code:
for x in range(0,101):
    for y in range(0,101):
        h = -1
        for i in plist:
            diff = abs(i[0]-x) + abs(i[1]-y)
            if h == -1:
                h = diff + i[2]
            else:
                if h != diff + i[2]:
                    break
        else:
            print(x, y, h)

Submission status: Runtime Error

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

ansx,ansy,ansh = -1,-1,-1
nonzero=-1

for i in range(n):
    l = list(map(int,input().split()))
    if l[2] != 0:
        xyh.append(l)
        nonzero=i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2] + abs(xyh[nonzero][0]-px) + abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if (xyh[nn][2] > 0 and nh != xyh[nn][2] + abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py)): 
                ok=False
            if (xyh[nn][2] == 0 and nh >  abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py)):
                ok=False
        if ok:
            ansx,ansy,ansh = px,py,nh
        
       

print(ansx,ansy,ansh)

Submission status: Runtime Error

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
kk = h.index(max(h))
for i in range(101):
    for j in range(101):
        H = h[kk] + abs(x[k] - i) + abs(y[k] - j)
        for k in range(n):
            if h[k] > 0:
                if H != abs(x[k]-i)+abs(y[k]-j)+h[k]:
                    H = -1
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    H = -1
        if H != -1:
            print(i, j, H)

Submission status: Runtime Error

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
      else:
        List.append(0)
    print(List)
    if len(list(set(List))) == 1:
      answer = List[0]
      center.append(i)
      center.append(j)

print(center[0], center[1], answer)

Submission status: Runtime Error

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
      else:
        List.append(0)
    if len(list(set(List))) == 1:
      answer = List[0]
      center.append(i)
      center.append(j)

print(center[0], center[1], answer)

Submission status: Runtime Error

Solution code:
def manhattan(i, j, x, y):
    # (i, j)中央点の座標，(x, y)既知の座標
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    for i in range(101):
        for j in range(101):
            # 既知座標１点を得て，中心座標の高さを決定する
            x, y, h = X[0], Y[0], H[0]
            hmax = h + manhattan(i, j, x, y)
            # 残り既知座標N-1点について，矛盾がないか確かめる
            for k in range(1, N):
                x, y, h = X[k], Y[k], H[k]
                if hmax - h != manhattan(i, j, x, y):
                    break
            else:
                return i, j, hmax

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

Submission status: Runtime Error

Solution code:
def manhattan(i, j, x, y):
    # (i, j)中央点の座標，(x, y)既知の座標
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    for i in range(101):
        for j in range(101):
            # 既知座標１点を得て，中心座標の高さを決定する
            x, y, h = X[0], Y[0], H[0]
            hmax = h + manhattan(i, j, x, y)
            # 残り既知座標N-1点について，矛盾がないか確かめる
            for k in range(1, N-1):
                x, y, h = X[k], Y[k], H[k]
                if hmax - h != manhattan(i, j, x, y):
                    break
            else:
                return i, j, hmax

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

Submission status: Runtime Error

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
          for x in H:
            h = x
          for k in range(len(l)):
            x = l[k]
            f = 1
            f *= x[3] == max(0,h - abs(i - x[0]) - abs(j - x[1]))
        if f == 1:
          print(i,j,h)

Submission status: Runtime Error

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
          for x in H:
            h = x
          for k in range(len(l)):
            x = l[k]
            f = True
            f *= x[3] == max(0,h - abs(i - x[0]) - abs(j - x[1]))
        if f == True:
          print(i,j,h)

Submission status: Runtime Error

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
          for x in H:
            h = x
          for k in range(len(l)):
            x = l[k]
            f = True
            f *= x[3] == max(0,h - abs(i - x[0]) - abs(i - x[1]))
        if f == True:
          print(i,j,h)

Submission status: Runtime Error

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
          for x in H:
            h = x
          for k in range(len(l)):
            x = l[k]
            f = True
            f *= x[3] == max(0,h - abs(i - x[0], abs(i - x[1]) )
        if f == True:
          print(i,j,h)

Submission status: Runtime Error

Solution code:
n = int(input())
 
#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 
flag = 0
for cx in range(101):
  for cy in range(101):
    if flag == 0:
      for i in range(0,n):
        if zahyo[0][2]>0:
          H0 = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]
          break
      for i in range(1,n):
        H = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]  
        if H != H0:
          break
      if H == H0 and H != 0:
        print(cx,cy,H0)
        flag = 1
    else:
      break

Submission status: Runtime Error

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

def solve(N,x,y,h):
    for cx in range(101):
        for cy in range(101):
            H = [h[i]+abs(x[i]-cx)+abs(y[i]-cy) for i in range(N)]
            if all([i==H[0] for i in H]):
                return [cx,cy,H[0]]
ans = solve(N,x,y,h)
print(ans[0],ans[1],ans[2])

Submission status: Runtime Error

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


def m():
    for cx in range(0, 101):
        for cy in range(0, 101):
            hs = []
            h = 0
            for x, y, r in xyr:
                h = max(0, r + abs(x - cx) + abs(y - cy))
                hs.append(h)
            if len(set(hs)) == 1:
                return "{} {} {}".format(cx, cy, set(hs)[0])


print(m())

Submission status: Runtime Error

Solution code:
N = int(input().strip())
x = []
y = []
h = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                Hi = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)
                if H == -1:
                    H = Hi

                if h[i] == 0:
                    if H < Hi:
                        break
                elif H != Hi:
                    break

                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

Submission status: Runtime Error

Solution code:
N = int(input().strip())
x = []
y = []
h = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                Hi = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)
                if H == -1:
                    H = Hi

                if h[i] == 0:
                    if H > Hi:
                        break
                elif H != Hi:
                    break

                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

Submission status: Runtime Error

Solution code:
N = int(input().strip())
x = []
y = []
h = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                if h[i] == 0:
                    continue
                Hi = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)
                if H == -1:
                    H = Hi
                if H != Hi:
                    break
                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

Submission status: Runtime Error

Solution code:
N = int(input())
X = []
Y = []
H = []

N_MAX = 100
X_MAX = 101
H_MAX = 1000000000

for i in range(N):
    t = list(map(int,input().split()))
    X.append(t[0])
    Y.append(t[1])
    H.append(t[2])

coord = []
[[coord.append([i,j]) for j in range(X_MAX)] for i in range(X_MAX)]
check = [1 for i in range(len(coord))]

for i in range(N):
    if H[i] != 0:
        table = [[H[0]+abs(i-X[0])+abs(j-Y[0]) for j in range(X_MAX)] for i in range(X_MAX)]
        table_num = i
        break

for k in range(0,N):
    if k != table_num:
        if H[k] != 0:
            tmp = [[H[k]+abs(i-X[k])+abs(j-Y[k]) for j in range(X_MAX)] for i in range(X_MAX)]
            for i,c in enumerate(coord):
                if tmp[c[0]][c[1]] != table[c[0]][c[1]]:
                    check[i] = 0

if sum(check) == 0:
    #top_coord = coord[table_num]
    print(X[table_num], Y[table_num], H[table_num])
else:
    top_coord = coord[check.index(1)]
    print(top_coord[0], top_coord[1], H[table_num]+abs(top_coord[table_num]-X[table_num])+abs(top_coord[1]-Y[table_num]))

Submission status: Runtime Error

Solution code:
N = int(input())
X = []
Y = []
H = []

N_MAX = 100
X_MAX = 101
H_MAX = 1000000000

for i in range(N):
    t = list(map(int,input().split()))
    X.append(t[0])
    Y.append(t[1])
    H.append(t[2])

coord = []
[[coord.append([i,j]) for j in range(X_MAX)] for i in range(X_MAX)]
check = [1 for i in range(len(coord))]

for i in range(N):
    if H[i] != 0:
        table = [[H[0]+abs(i-X[0])+abs(j-Y[0]) for j in range(X_MAX)] for i in range(X_MAX)]
        table_num = i
        break

for k in range(0,N):
    if k != table_num:
        if H[k] != 0:
            tmp = [[H[k]+abs(i-X[k])+abs(j-Y[k]) for j in range(X_MAX)] for i in range(X_MAX)]
            for i,c in enumerate(coord):
                if tmp[c[0]][c[1]] != table[c[0]][c[1]]:
                    check[i] = 0

if sum(check) == 0:
    top_coord = coord[table_num]
else:
    top_coord = coord[check.index(1)]

print(top_coord[0], top_coord[1], H[table_num]+abs(top_coord[table_num]-X[table_num])+abs(top_coord[1]-Y[table_num]))

Submission status: Runtime Error

Solution code:
N = int(input())
X = []
Y = []
H = []

N_MAX = 100
X_MAX = 101
H_MAX = 1000000000

for i in range(N):
    t = list(map(int,input().split()))
    X.append(t[0])
    Y.append(t[1])
    H.append(t[2])

coord = []
[[coord.append([i,j]) for j in range(X_MAX)] for i in range(X_MAX)]
check = [1 for i in range(len(coord))]

for i in range(N):
    if H[i] != 0:
        table = [[H[0]+abs(i-X[0])+abs(j-Y[0]) for j in range(X_MAX)] for i in range(X_MAX)]
        table_num = i
        break

for k in range(0,N):
    if k != table_num:
        if H[k] != 0:
            tmp = [[H[k]+abs(i-X[k])+abs(j-Y[k]) for j in range(X_MAX)] for i in range(X_MAX)]
            for i,c in enumerate(coord):
                if tmp[c[0]][c[1]] != table[c[0]][c[1]]:
                    check[i] = 0

top_coord = coord[check.index(1)]

print(top_coord[0], top_coord[1], H[0]+abs(top_coord[0]-X[0])+abs(top_coord[1]-Y[0]))

Submission status: Runtime Error

Solution code:
N = int(input())
X = []
Y = []
H = []

N_MAX = 100
X_MAX = 101
H_MAX = 1000000000

for i in range(N):
    t = list(map(int,input().split()))
    X.append(t[0])
    Y.append(t[1])
    H.append(t[2])

coord = []
[[coord.append([i,j]) for j in range(X_MAX)] for i in range(X_MAX)]
check = [1 for i in range(len(coord))]

table = [[H[0]+abs(i-X[0])+abs(j-Y[0]) for j in range(X_MAX)] for i in range(X_MAX)]

for k in range(1,N):
    if H[k] != 0:
        tmp = [[H[k]+abs(i-X[k])+abs(j-Y[k]) for j in range(X_MAX)] for i in range(X_MAX)]
        for i,c in enumerate(coord):
            if tmp[c[0]][c[1]] != table[c[0]][c[1]]:
                check[i] = 0

top_coord = coord[check.index(1)]

print(top_coord[0], top_coord[1], H[0]+abs(top_coord[0]-X[0])+abs(top_coord[1]-Y[0]))

Submission status: Runtime Error

Solution code:
def abc(n:int,lst:list):
    h=0
    l=list(map(lambda x:x[2],lst))
    if min(l)==0 and max(l)<201:
        for x in range(101):
            for y in range(101):
                for h in range(n):
                    h+=1
                    for i in range(n):
                        if max(0,h-abs(lst[i][0]-x)-abs(lst[i][1]-y)) ==lst[i][2]:
                            if i ==n-1:
                                return [x,y,h]
                        else:
                            h=0
                            break
    else:
        x0 =lst[0][0]
        y0=lst[0][1]
        h0 =lst[0][2]
        for x in range(101):
            for y in range(101):
                for i in range(1,n):
                    if abs(x0-x)+abs(y0-y)-abs(lst[i][0]-x)-abs(lst[i][1]-y) ==lst[i][2]-h0:
                        if i ==n-1:
                            return x,y,h0+abs(x0-x)+abs(y0-y)
                    else:
                        break
n = int(input())
lst = [list(map(int,input().split())) for i in range(n)]
x,y,h =abc(n,lst)
print(x,y,h)

Submission status: Runtime Error

Solution code:
N = int(input())
X = []
Y = []
H = []

N_MAX = 100
X_MAX = 101
H_MAX = 1000000000

for i in range(N):
    t = list(map(int,input().split()))
    X.append(t[0])
    Y.append(t[1])
    H.append(t[2])

coord = []
[[coord.append([i,j]) for j in range(X_MAX)] for i in range(X_MAX)]
check = [1 for i in range(len(coord))]

table = [[H[0]+abs(i-X[0])+abs(j-Y[0]) for j in range(X_MAX)] for i in range(X_MAX)]

for k in range(1,N):
    tmp = [[H[k]+abs(i-X[k])+abs(j-Y[k]) for j in range(X_MAX)] for i in range(X_MAX)]
    for i,c in enumerate(coord):
        if tmp[c[0]][c[1]] != table[c[0]][c[1]]:
            check[i] = 0

top_coord = coord[check.index(1)]

print(top_coord[0], top_coord[1], H[0]+abs(top_coord[0]-X[0])+abs(top_coord[1]-Y[0]))

Submission status: Runtime Error

Solution code:
N = int(input())
data = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    data[i][0],data[i][1],data[i][2] = [int(s) for s in input().split()]

fl = 0
for Cx in range(0,101):
    for Cy in range(0,101):
        s1 = abs(data[0][0]-Cx)+abs(data[0][1]-Cy)+data[0][2]
        for i in range(1,N):
            s2 = abs(data[i][0]-Cx)+abs(data[i][1]-Cy)+data[i][2]
            if s1 != s2:
                break
        else:
            H = s1
            cx = Cx
            cy = Cy
            fl = 1
        if fl:
            break
    if fl:
        break

print(cx,cy,H)

Submission status: Runtime Error

Solution code:
N = int(input())
S = [[int(i) for i in input().split()] for j in range(N)]
SS = sorted(S,key=lambda x: x[2], reverse=True)

#(x, y)を(0,0)から(100,100)まで試す
def firstlook(si, kohod): 
    for x in range(0, 100+1):
        for y in range(0, 100+1):
            h = si[2]+abs(si[0]-x)+abs(si[1]-y)
            kohod[(x,y)] = h
    return kohod

def lastlook(si, kohod):
    for (x, y) in list(kohod.keys()):
        h = max((si[2]+abs(si[0]-x)+abs(si[1]-y)),0)
        if kohod[(x,y)] != h:
            del kohod[(x,y)]
    return kohod

anspre = firstlook(SS[0], dict())
for Si in SS:
    ans = lastlook(Si, anspre)

[xy] = list(ans.keys())
print(str(xy[0]) + " " + str(xy[1]) + " "+ str(ans[xy]))

Submission status: Runtime Error

Solution code:
N = int(input())
S = [[int(i) for i in input().split()] for j in range(N)]
SS = sorted(S,key=lambda x: x[2], reverse=True)

#(x, y)を(0,0)から(100,100)まで試す
def firstlook(si, kohod): 
    for x in range(0, 100+1):
        for y in range(0, 100+1):
            h = max((si[2]+abs(si[0]-x)+abs(si[1]-y)),0)
            kohod[(x,y)] = h
    return kohod

def lastlook(si, kohod):
    for (x, y) in list(kohod.keys()):
        h = max((si[2]+abs(si[0]-x)+abs(si[1]-y)),0)
        if kohod[(x,y)] != h:
            del kohod[(x,y)]
    return kohod

anspre = firstlook(SS[0], dict())
for Si in SS:
    ans = lastlook(Si, anspre)

[xy] = list(ans.keys())
print(str(xy[0]) + " " + str(xy[1]) + " "+ str(ans[xy]))

Submission status: Runtime Error

Solution code:
W = 101

def solve(N, xyh):
    H = [[1e9] * W for i in range(W)]
    for x, y, h in xyh:
        for yy in range(W):
            for xx in range(W):
                if h == 0:
                    d = abs(xx - x) + abs(yy - y)
                    H[yy][xx] = min(H[yy][xx], d)
    V = [[-1] * W for i in range(W)]
    for x, y, h in xyh:
        for yy in range(W):
            for xx in range(W):
                d = abs(xx - x) + abs(yy - y)
                if h + d > H[yy][xx]:
                    V[yy][xx] = -2
                else:
                    if V[yy][xx] == -1:
                        V[yy][xx] = d + h
                    elif V[yy][xx] != d + h:
                        V[yy][xx] = -2
    for yy in range(W):
        for xx in range(W):
            if 1 <= V[yy][xx]:
                return (xx, yy, V[yy][xx])

if __name__ == '__main__':
    N = int(input())
    xyh = [tuple(map(int, input().split())) for i in range(N)]
    print(*solve(N, xyh))