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

pts = []

for i in range(n):
    x, y, h = map(int, input().split())
    if h != 0:
        pts.append((x, y, h))

for y in range(0, 101):
    for x in range(0, 101):
        needH = -1
        for i in range(n):
            tmp = pts[i][2] + abs(y - pts[i][1]) + abs(x - pts[i][0])
            if needH == -1:
                needH = tmp
            else:
                if needH != tmp:
                    needH = -2
                    break
        if needH == -2:
            continue

        for i in range(n):
            if pts[i][2] == 0:
                dist = abs(y - pts[i][1]) + abs(x - pts[i][0])
                if needH > dist:
                    needH = -2
                    break

        if needH == -2:
            continue

        print('{0} {1} {2}'.format(x, y, needH))
        exit()

Submission status: Runtime Error

Solution code:
N=int(input())
xyh=[list(map(int, input().split())) for i in range(N)]
 
for i in range(101):
  for j in range(101):
    check=True
    k=0
    while xyh[k][2]==0:
      k+=1
      
    h=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
    
    for k in range(N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if xyh[k][2]==0:
        if temph<=h:
          check=False
      else:
        if h!=temph:
          check=False
        
    if check==True and 0<h:
        print(' '.join([str(i), str(j), str(h)]))
        exit()
        
sonnnakannsuuhateigisiteinai()

Submission status: Runtime Error

Solution code:
N=int(input())
xyh=[list(map(int, input().split())) for i in range(N)]
 
for i in range(101):
  for j in range(101):
    check=True
    k=0
    while xyh[k][2]==0:
      k+=1
      
    h=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
    
    for k in range(N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if xyh[k][2]==0:
        if temph<=h:
          check=False
      else:
        if h!=temph:
          check=False
        
    if check==True and 0<h:
        print(' '.join([str(i), str(j), str(h)]))
        
sonnnakannsuuhateigisiteinai()

Submission status: Runtime Error

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

for i in range(101):
  for j in range(101):
    check=True
    h=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
    
    for k in range(1, N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if h!=temph:
        check=False
        
    if check:
      if 0<=h and h<=pow(10, 9):
      print(' '.join([str(i), str(j), str(h)]))

Submission status: Runtime Error

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

for i in range(101):
  for j in range(101):
    check=True
    h=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
    
    for k in range(1, N):
      temph=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]
      if h!=temph:
        check=False
        
    if check:
      if 0<=h<=pow(10, 9):
      print(' '.join([str(i), str(j), str(h)]))

Submission status: Runtime Error

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

for i in range(N):
    tmp = []
    for cx in range(101):
        for cy in range(101):
            H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
            tmp.append((cx, cy, H)) # setはtmp.add(要素)で追加できるが要素としてtupleを追加しようとすると和集合を書いたりしなきゃいけないので遅い
    if i == 0:
        ans = tmp
    else:
        ans = set(ans) & set(tmp) # set

ans = list(list(ans)[0])
ans = ' '.join(list(map(str, ans)))
print(ans)

Submission status: Runtime Error

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

for Cx in range(101):
    for Cy in range(101):
         ans = []
        for ix, iy, ih in I:
            ans.append(abs(ix - Cx) + abs(iy - Cy) + ih)
            ans = [a for a in ans if a > 0]
        if len(ans) > 1:
            continue
        for ix, iy, ih in I:
            if max(a - abs(ix - Cx) - abs(iy - Cy), 0) != ix:
                break
        else:
            print(Cx, Cy, a)
            exit()

Submission status: Runtime Error

Solution code:
N = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True

        for i, (x,y,h) in enumerate(xyh):
            if h == 0:
                H = h + abs(x - cx) + abs(y - cy)

        for i, (x,y,h) in enumerate(xyh):
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                continue
            else:
                flag = False
                break
        if flag:
            print(cx, cy, H)
            exit()

Submission status: Runtime Error

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    H = 0
    for i in range(N):
        if xyh[i][2] >= H:
            X = xyh[i][0]
            Y = xyh[i][1]
            H = xyh[i][2]
    
    flag = True
    for i in range(0, N):
        if xyh[i][2] != max(H - abs(xyh[i][0] - X) - abs(xyh[i][1] - Y), 0):
            flag = False
    
    if flag:
        print(1/0)
    
    
    if not flag:
        for x in range(0, 101):
            for y in range(0, 101):
                flag = True
                height = 0
                for i in range(0, N):
                    if xyh[i][2] != 0:
                        if height == 0:
                            height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                        if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                            flag = False
                            break
                    else:
                        if abs(xyh[i][0] - x) + abs(xyh[i][1] - y) < height:
                            flag = False
                            break
                if flag and height:
                    X = x
                    Y = y
        
        
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Runtime Error

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    xyh = [None]*N
    for i in range(N):
        xyh[i] = list(map(int, input().split()))
    
    H = 0
    for i in range(N):
        if xyh[i][2] >= H:
            X = xyh[i][0]
            Y = xyh[i][1]
            H = xyh[i][2]
    
    flag = True
    for i in range(0, N):
        if xyh[i][2] != 0:
            if H != xyh[i][2] + abs(xyh[i][0] - X) + abs(xyh[i][1] - Y):
                flag = False
        else:
            if abs(xyh[i][0] - X) + abs(xyh[i][1] - Y) < H:
                flag = False
    
    if flag:
        print(1/0)
    
    if not flag:
        for x in range(0, 101):
            for y in range(0, 101):
                flag = True
                height = 0
                for i in range(0, N):
                    if xyh[i][2] != 0:
                        if height == 0:
                            height = xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                        if height != xyh[i][2] + abs(xyh[i][0] - x) + abs(xyh[i][1] - y):
                            flag = False
                            break
                    else:
                        if abs(xyh[i][0] - x) + abs(xyh[i][1] - y) < height:
                            flag = False
                            break
                if flag and height:
                    X = x
                    Y = y
        
        
    H = xyh[0][2] + abs(xyh[0][0] - X) + abs(xyh[0][1] - Y)
    
    print(X, Y, H)

Submission status: Runtime Error

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = -1
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != -1 and before != height:
        if surveys[2] == 0 and before <= height:
          continue
        identified = False
        break
      if before == -1:
        before = height
    if identified:
      print(x, y, before)

Submission status: Runtime Error

Solution code:
n=int(input())
r=[list(map(int,input().split())) for _ in range(N)]
r.sort(key=lambda x:x[2])
x,y,h=r[-1]

for X in range(101):
  for Y in range(101):
    H = h + abs(X-x) + abs(Y-y)
    if all(k==max(H-abs(X-i)-abs(Y-j),0) for i,j,k in r):
      print(i,j,k)
      exit()

Submission status: Runtime Error

Solution code:
N = int(input())
coordinate = []
ans = -1
for _ in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        continue
    coordinate.append([x, y, h])

for cx in range(101):
    for cy in range(101):
        x1, y1, h1 = coordinate[0]
        H1 = h1 + abs(cx-x1) + abs(cy-y1)
        f = 1
        for n in range(1, N):
            x, y, h = coordinate[n]
            H = h + abs(cx-x) + abs(cy-y)
            if H == H1:
                f *= 1
            else:
                f *= 0
            if f and n == N-1:
                break
        if f:
            Cx = cx
            Cy = cy
            ans = H1
            break
    if f:
        break
        
print(Cx, Cy, ans)

Submission status: Runtime Error

Solution code:
N = int(input())
Inputs = [tuple(map(int, input().split())) for _ in range(N)]
H = 0
f = 0
for cx in range(101):
    for cy in range(101):
        n = 0
        while(n < N-1):
            x1, y1, h1 = Inputs[n]
            H1 = h1 + abs(x1-cx) + abs(y1-cy)
            x2, y2, h2 = Inputs[n+1]
            H2 = h2 + abs(x2-cx) + abs(y2-cy)
            n += 1
            if h1 == 0:
                continue
            if H1 != H2:
                f = 0
                break
            else:
                f = 1
        if f:
            Cx = cx
            Cy = cy
            H = H1
            
                
print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
N = int(input())
Inputs = [tuple(map(int, input().split())) for _ in range(N)]
H = 0
f = 0
for cx in range(101):
    for cy in range(101):
        n = 0
        while(n < N-1):
            x1, y1, h1 = Inputs[n]
            if h1 == 0:
                continue
            H1 = h1 + abs(x1-cx) + abs(y1-cy)
            x2, y2, h2 = Inputs[n+1]
            H2 = h2 + abs(x2-cx) + abs(y2-cy)
            if H1 != H2:
                f = 0
                break
            else:
                f = 1
                n += 1
        if f:
            print('aaaa')
            Cx = cx
            Cy = cy
            H = H1
            
                
print(Cx, Cy, H)

Submission status: Runtime Error

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

f = 0
for cx in range(101):
    for cy in range(101):
        n = 0
        while(n < N-1):
            x1, y1, h1 = Inputs[n]
            H1 = h1 + abs(x1-cx) + abs(y1-cy)
            x2, y2, h2 = Inputs[n+1]
            H2 = h2 + abs(x2-cx) + abs(y2-cy)
            if H1 != H2:
                f = 0
                break
            else:
                f = 1
                n += 1
        if f:
            Cx = cx
            Cy = cy
            H = H1
            
                
print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
def divisors(N):
    U = int(N ** 0.5)
    res = [i for i in range(1, U) if N % i == 0]
    if N % U == 0:
        res.append(U)
    res += [N // r for r in reversed(res)]
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))

Submission status: Runtime Error

Solution code:
N=int(input())
ls=[[int(s) for s in input().split()] for i in range(N)]
flag2=1
for i in range(N):
  if ls[i][2]!=0:
    a=ls[i][0]
    b=ls[i][1]
    h_base=ls[i][2]
    ls.pop(i)
    flag2=0
    break
if flag2==0:
  for x in range(101):
    for y in range(101):
      ##x,yの高さを計算
      h=h_base+abs(x-a)+abs(y-b)
      ##他の条件と合うか？
      flag=1
      for e in ls:
        if h!=e[2]+abs(x-e[0])+abs(y-e[1]):
          flag=0
          break
      if flag==1:
        ans=[x,y,h]
        break
    if flag==1:
      break
else:
  xsum=0
  ysum=0
  for e in ls:
    xsum+=e[0]
    ysum+=e[1]
  ans=[5050*101-xsum,5050*101-ysum,1]
print(*ans)

Submission status: Runtime Error

Solution code:
N=int(input())
ls=[[int(s) for s in input().split()] for i in range(N)]
flag2=1
for i in range(N):
  if ls[i][2]!=0:
    a=ls[i][0]
    b=ls[i][1]
    h_base=ls[i][2]
    ls.pop(i)
    flag2=0
    break
if flag2==0:
  for x in range(101):
    for y in range(101):
      ##x,yの高さを計算
      h=h_base+abs(x-a)+abs(y-b)
      ##他の条件と合うか？
      flag=1
      for e in ls:
        if h!=e[2]+abs(x-e[0])+abs(y-e[1]):
          flag=0
          break
      if flag==1:
        ans=[x,y,h]
        break
    if flag==1:
      break
else:
  xsum=0
  ysum=0
  for e in ls:
    xsum+=e[0]
    ysum+=e[1]
  ans=[5050-xsum,5050-ysum,1]
print(*ans)

Submission status: Runtime Error

Solution code:
N=int(input())
ls=[[int(s) for s in input().split()] for i in range(N)]
flag2=0
for i in range(N):
  if ls[i][2]!=0:
    a=ls[i][0]
    b=ls[i][1]
    h_base=ls[i][2]
    ls.pop(i)
    break
else:
  flag2=1
if flag2==0:
  for x in range(101):
    for y in range(101):
      ##x,yの高さを計算
      h=h_base+abs(x-a)+abs(y-b)
      ##他の条件と合うか？
      flag=1
      for e in ls:
        if h!=e[2]+abs(x-e[0])+abs(y-e[1]):
          flag=0
          break
      if flag==1:
        ans=[x,y,h]
        break
    if flag==1:
      break
else:
  xsum=0
  ysum=0
  for e in ls:
    xsum+=e[0]
    ysum+=e[1]
  ans=[5050-xsum,5050-ysum,1]
print(*ans)

Submission status: Runtime Error

Solution code:
import sys
N = int(input())
Data = []
for _ in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        Data.append([x,y,h])

Data.sort(key=lambda x:x[2],reverse=True)

for cx in range(101):
    for cy in range(101):
        found = True
        ans   = -1
        for i in range(0,N):
            x,y,h = Data[i]
            if i == 0:
                ans = h + abs(x-cx)+abs(y-cy)
            else:
                ph = h + abs(x-cx)+abs(y-cy)
                if ans != ph:
                    found = False
                    break
        if found == True:
            print( '{} {} {}'.format(cx,cy,ans))
            sys.exit()

Submission status: Runtime Error

Solution code:
n = int(input())
XYH = list(map(int, input().split()) for _ in range(n))
  
XYH.sort(lambda x:x[2],reverse=True)
sx = XYH[0][0]
sy = XYH[0][1]
sh = XYH[0][2]
  
for i in range(0,101):
  for j in range(0,101):
    anss = sh + abs(sx-i) + abs(sy-j)
    for k in range(n):
      if H[k] == 0:
        continue
      if anss == XYH[k][2] + abs(XYH[k][0]-i) + abs(XYH[k][1]-j):
        continue
      else:
        break
    else:
      an = [sx, sy, sh]
      print(*an)
      exit()

Submission status: Runtime Error

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0:
        if k == n-1 and ans_h != 0:
          ans_x = i
          ans_y = j
          flag=1
          break
        else:
          pass
      if ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if ans_h != 0 and k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Runtime Error

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0 and ans_h-abs(i-x[k])-abs(j-y[k]) < 0:
        if k == n-1:
          ans_x = i
          ans_y = j
          flag=1
          break
      	else:
          continue
      if ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Runtime Error

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0:
        continue
      elif ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Runtime Error

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    for k in range(n):
      if k == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Runtime Error

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    for k in range(n):
      if k == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      elif k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Runtime Error

Solution code:
import sys

def height(a, b, c, d, e):
    return abs(a-d)+abs(b-e)+c

n = int(input())
hint = []
q = 0
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append(c, a, b)
hint.sort(reverse=True)

for i in range(101):
    for j in range(101):
        frag = True
        H = height(hint[0][1], hint[0][2], hint[0][0] i, j)
        for h in hint[1:]:
            if height(h[1], h[2], h[0], i, j) != H:
                frag = False
                break
        if frag:
            print(i, j, H)
            sys.exit()

Submission status: Runtime Error

Solution code:
 n = int(input())
hint = []
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([a, b, c])
frag2 = False
for i in range(101):
    for j in range(101):
        ans_h = -1
        frag = False
        for k in range(n):
            a, b, c = hint[k][0], hint[k][1], hint[k][2]
            if c != 0:
                if ans_h == -1:
                    ans_h = abs(a-i)+abs(b-j)+c
                else:
                    if ans_h != abs(a-i)+abs(b-j)+c:
                        frag = True
                        break
                    else:
                        continue
        if not frag:
            answer = [i, j, ans_h]
            frag2 = True
            break
    if frag2:
        break

for i in range(3):
    print(answer[i], end=" ")

Submission status: Runtime Error

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

def clcdis(i, j, x, y):
    return abs(i-x) + abs(j-y)

datatmp = []
datatmp = copy.deepcopy(data[0])



ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True
        tmp = 0
        hmax = 10**10
        for k in range(len(data)):
            if data[k][2] == 0:
                hmax = min(hmax, clcdis(i, j, data[k][0]), data[k][1])
            elif tmp > 0 and tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                flg = False
                break
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])

        if flg and tmp <= hmax:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Runtime Error

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

def clcdis(i, j, x, y):
    return abs(i-x) + abs(j-y)

datatmp = []
datatmp = copy.deepcopy(data[0])



ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True
        tmp = -1
        hmax = 10**10
        for k in range(len(data)):
            if data[k][2] == 0:
                hmax = min(hmax, clcdis(i, j, data[k][0]), data[k][1])
            elif k == 0 or tmp ==-1:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                    flg = False
                    break

        if tmp > hmax:
           flg = False

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Runtime Error

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

def clcdis(i, j, x, y):
    return abs(i-x) + abs(j-y)

datatmp = []
datatmp = copy.deepcopy(data[0])



ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True
        tmp = 0
        hmax = 10**10
        for k in range(len(data)):
            if data[k][2] == 0:
                hmax = min(hmax, clcdis(i, j, data[k][0]), data[k][1])
            elif k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                    flg = False
                    break

        if tmp > hmax:
           flg = False

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Runtime Error

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

def clcdis(i, j, x, y):
    return abs(i-x) + abs(j-y)

datatmp = []
datatmp = copy.deepcopy(data[0])



ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True
        hmax = 10**10
        for k in range(len(data)):
            if data[k][2] == 0:
                hmax = min(hmax, clcdis(i, j, data[k][0]), data[k][1])
            elif k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                    flg = False
                    break

        if tmp > hmax:
           flg = False 

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Runtime Error

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True

        for k in range(n):
            if data[k][2] == 0:
                continue
            if k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]) or data[k][2] < 1:
                    flg = False
                    break

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)