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=[]
MAX=100
for i in range(n):
    x,y,h=map(int,input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
for posX in range(MAX+1):
    for posY in range(MAX+1):
        needH=-1
        for i in range(n):
            if H[i]>0:
                tmp=H[i]+abs(X[i]-posX)+abs(Y[i]-posY)
                if needH==-1:
                    needH=tmp
                else:
                    if needH!=tmp:
                        needH=-2
                        break
  
        if needH==-2:
            continue
        for i in range(n):
            if H[i]==0:    
                dis=abs(X[i]-posX)+abs(Y[i]-posY)
                if needH>dist:
                    needH=-2
                    break         
        if needH==-2:
            continue
        print(posX,posY,needH)
        exit()
~                                                                                         
~

Submission status: Runtime Error

Solution code:
a = int(input())

b = []

p = 0
pp = 0
ppp = 0

for i in range(a):
    b.append(list(map(int,input().split())))
b.sort(b,key=lambda x:-x[2])
if a == 1:
    print(b[0][0],b[0][1],b[0][2])
else:
    for i in range(0,101,-1):
        for j in range(0,101,-1):
            for k in range(a):
                if k == 0:
                 p = abs(b[k][0] - i) + abs(b[k][1]-j)+b[k][2]
            else:
                if max(0,p - abs(b[k][0]-i)- abs(b[k][1]-j)) != b[k][2]:
                    pp = 1
        if pp == 0:
            ppp = 1
            break
        else:
            pp = 0
        if ppp == 1:
            print(i,j,p)
            break

Submission status: Runtime Error

Solution code:
a = int(input())

b = []

p = 0
pp = 0
ppp = 0

for i in range(a):
    b.append(list(map(int,input().split())))
b.sort(b,key=lambda x:-x[2])
if a == 1:
    print(b[0][0],b[0][1],b[0][2])
else:
    for i in range(0,101,-1):
        for j in range(0,101,-1):
            for k in range(a):
                if k == 0:
                 p = abs(b[k][0] - i) + abs(b[k][1]-j)+b[k][2]
            else:
                if max(0,p - abs(b[k][0]-i)- abs(b[k][1]-j)) != b[k][2]:
                    pp = 1
        if pp == 0:
            ppp = 1
            break
        else:
            pp = 0
    if ppp == 1:
        print(i,j,p)
        break

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
lst = [[x, y] for x in range(101) for y in range(101)]
for i, j in lst:
    k = 0
    flag = True
    for x, y, h in xyh:
        H_ = calcH(x, i, y, j, h)
        if H_ > Hmax and h != 0:
            flag = False
            break
        if k > 0:
            if H_ != H and flag and h != 0:
                flag = False
                break
            elif H_ != H and not flag and h == 0:
                if H_ < H:
                    H = H_
            elif H_ != H and h == 0:
                if H_ <= H:
                    flag = False
                    break
            elif H_ != H:
                H = H_
                flag = True
            else:
                flag = True
        else:
            H = H_
            if h == 0 and n == 1:
                flag = False
        k += 1
    if k < n or H > Hmax:
        continue
    else:
        Cx = i
        Cy = j
        Ch = H
    break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
H_matrix = np.empty([101, 101, N])
for i in range(N):
    [x, y, h] = list(map(int, input().split()))
    if h == 0:
        H_matrix[:, :, i] = np.nan
    else:
        H_matrix[:, :, i] = h + np.abs(cx - x).reshape(1, -1) + np.abs(cy - y).reshape(-1, 1)
H_matrix[H_matrix<0] = 0
H = (H_matrix.max(axis=-1) - H_matrix.min(axis=-1)) == 0
Y = np.argmax(H, axis=0).max()
X = np.argmax(H, axis=1).max()
H = int(H_matrix[Y, X, 0])
print(X, Y, H)

Submission status: Runtime Error

Solution code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(N+1):
	for cx in range(N+1):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				H_list.append(H) 
			if h_list[i] == 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				if H > 0:
					break
		if all_same(H_list):
			print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
			break

Submission status: Runtime Error

Solution code:
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n + 1):
            if i == n:
                break
            if max(H[0] - abs(x[j] - cx) - abs(y[j] - cy), 0) != h[j]:
                break
        if n == 1:
            break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Runtime Error

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

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


def solv(Xs):
    for x in range(101):
        for y in range(101):
            Cx, Cy, h = tuple(Xs)
            H = h + abs(x - Cx) + abs(y - Cy)
            for Cx, Cy, h in Xs:
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    break
            else:
                return (x, y, H)


print("%d %d %d" % solv(Xs))

Submission status: Runtime Error

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""
Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            h= Xs[0][2]
            Cx = Xs[0][0]
            Cy = Xs[0][1]
            H = h + abs(x - Cx) + abs(y - Cy)
            for i in range(len(Xs)):
                if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                    break
                if i == len(Xs)-1:
                    if H > 0:
                        return (x, y, H)


print("%d %d %d" % solv(Xs))

Submission status: Runtime Error

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""
Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            h= Xs[0][2]
            Cx = Xs[0][0]
            Cy = Xs[0][1]
            H = h + abs(x - Cx) + abs(y - Cy)
            for i in range(len(Xs)):
                if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                    break
                if i == len(Xs)-1:
                    return (x, y, H)


print("%d %d %d" % solv(Xs))

Submission status: Runtime Error

Solution code:
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2],reverse=True)
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if j[2]==0:
            if k>l:
                n-=1
                continue
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Runtime Error

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
"""
Xs = [list(map(int, x.split(" "))) for x in input]
Xs.sort(key=lambda x:x[2], reverse=True)

for x in range(101):
    for y in range(101):
        h= Xs[0][2]
        Cx = Xs[0][0]
        Cy = Xs[0][1]
        H = h + abs(x - Cx) + abs(y - Cy)
        for i in range(len(Xs)):
            if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                break
            if i == len(Xs)-1:
                print("%d %d %d" % (x, y, H))

Submission status: Runtime Error

Solution code:
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if j[2]==0:
            if l!=0 and k>l:
                n-=1
                continue
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Runtime Error

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

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


 
def check(cx,cy):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            global H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            print("{} {} {}".format(i,j,H))

Submission status: Runtime Error

Solution code:
N=int(input())
lis=[]
res=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2])
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if k<l:
                n-=1
                continue
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Runtime Error

Solution code:
N=int(input())
lis=[]
res=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2])
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if k<l:
                break
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Runtime Error

Solution code:
N=int(input())
lis=[]
res=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    res.append([[0],i[1],l])
                    if len(res)>1:
                        m=res[1]
                    else: m=res
            else: break
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    inf = []
    a = []
    for i in range(N):
        x,y,h = map(int,input().split(" "))
        inf.append([x,y,h])
        if h >= 1:
            a.append([x,y,h])
    X = a[0][0]
    Y = a[0][1]
    H = a[0][2]
    center = []
    for i in range(101):
        for j in range(101):
            h = H + abs(X-i) + abs(Y-i)
            center.append([i,j,h])
    for i in range(len(inf)):
        x = inf[i][0]
        y = inf[i][1]
        h = inf[i][2]
        list = []
        for j in range(len(center)):
            if h == center[j][2] - abs(x-center[j][0]) - abs(y-center[j][1]):
                list.append(center[j])
        center = list
    print(center[0][0],center[0][1],center[0][2])

Submission status: Runtime Error

Solution code:
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
h=0
for x in range(0,101):
    for y in range(0,101):
        f=0
        if e[f][2]==0:
            f+=1
        else:
            k=abs(x-e[f][0])+abs(y-e[f][1])+e[f][2]
        for i in range(0,len(e)):
            if e[i][2]!=max(k-abs(x-e[i][0])-abs(y-e[i][1]),0):
                break
        else:
            print(x,y,k)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    inf = []
    x,y,h = map(int,input().split(" "))
    for i in range(101):
        for j in range(101):
            H = h + abs(x-i) + abs(y-j)
            inf.append([i,j,H])
    for i in range(N-1):
        x,y,h = map(int,input().split(" "))
        list = []
        for j in range(len(inf)):
            if h == inf[j][2] - abs(x-inf[j][0]) - abs(y-inf[j][1]):
                list.append(inf[j])
        inf = list
    print(inf[0][0],inf[0][1],inf[0][2])

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    inf = []
    x,y,h = map(int,input().split(" "))
    for i in range(101):
        for j in range(101):
            H = h + abs(x-i) + abs(y-j)
            inf.append([i,j,H])
    for i in range(N-1):
        x,y,h = map(int,input().split(" "))
        list = []
        for j in range(len(inf)):
            if h == inf[j][2] - abs(x-inf[j][0]) - abs(y-inf[j][1]):
                list.append(inf[j])
        inf = list
        print(len(inf))
    print(inf[0][0],inf[0][1],inf[0][2])

Submission status: Runtime Error

Solution code:
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
arr = np.array(arr)
x_min  = arr[:,0].min()
x_max = arr[:,0].max()
y_min = arr[:,1].min()
y_max =  arr[:,1].max()
mx = arr[:,2].max()
s = max(dx,dy)+1
for k in range(mx+100,mx-1,-1):
    for i in range(x_min,x_max+1):
        for j in range(y_min,y_max+1):
            for x,y,h in arr:
                h_ = max(k-abs(i-x)-abs(j-y),0)
                if h_ != h:
                    break
            else:
                print (i,j,k)
                exit()

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
 
n = ni()
xyh = []
for _ in range(n):
    xyh.append(tuple(list(li())))
    
 
# 中心になりうる点を全探索
def search_cent(xyh: list):
    n = len(xyh)
    for x_cent in range(101):
        for y_cent in range(101):
            
            # 各点と中心との距離
            dist = []
            is_cent = True
            for x,y,_ in xyh:
                dist.append((abs(x-x_cent), abs(y-y_cent)))
                
            # 中心との距離と高さの差に矛盾が無いかチェック
            for i in range(n):
                for j in range(n):
                    if xyh[i][2] - sum(dist[i]) < 0 or xyh[j][2] - sum(dist[j]) < 0:
                        continue
                    
                    if (xyh[i][2]-xyh[j][2]) != -(sum(dist[i]) - sum(dist[j])):
                        is_cent = False
                        break
                if not is_cent:
                    break
 
            if is_cent:
                x0, y0, h0 = 0,0,0
                for x,y,h in xyh:
                    if h == 0:
                        pass
                    else:
                        x0,y0,h0 = x,y,h
                        
                h_cent = h0 + abs(x0 - x_cent) + abs(y0 - y_cent)
                
                
                
                if h_cent > 0:
                    yield x_cent, y_cent, h_cent
 
ans_finded = False
gen = search_cent(xyh)
while not ans_finded:
    ok = True                
    x_cent, y_cent, h_cent = gen.__next__()
    for xi, yi, hi in xyh:
        if hi + abs(x_cent-xi) + abs(y_cent-yi) != h_cent:
            ok = False
            break
        
    if ok:
        ans_finded = True

 
print(x_cent, y_cent, h_cent)

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
lst = [[x, y] for x in range(101) for y in range(101)]
for i, j in lst:
    k = 0
    flag = True
    for x, y, h in xyh:
        H_ = calcH(x, i, y, j, h)
        if k > 0:
            if H_ != H and flag and h != 0:
                flag = False
                break
            elif H_ != H and h == 0:
                continue
            elif H_ != H:
                H = H_
                flag = True
            else:
                flag = True
                continue
        else:
            H = H_
        if h == 0 and k != n-1:
            flag = False
        k += 1
    if flag == False or H > Hmax:
        continue
    else:
        Cx = i
        Cy = j
        Ch = H
    break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    inf = []
    x,y,h = map(int,input().split(" "))
    for i in range(101):
        for j in range(101):
            H = h + abs(x-i) + abs(y-j)
            if H >= 1:
                inf.append([i,j,H])
    for i in range(N-1):
        x,y,h = map(int,input().split(" "))
        list = []
        for j in range(len(inf)):
            if h == inf[j][2] - abs(x-inf[j][0]) - abs(y-inf[j][1]):
                list.append(inf[j])
        inf = list
    print(inf[0][0],inf[0][1],inf[0][2])

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
lst = [[x, y] for x in range(101) for y in range(101)]
for i, j in lst:
    k = 0
    flag = True
    for x, y, h in xyh:
        H_ = calcH(x, i, y, j, h)
        if k > 0:
            if H_ != H and flag and h != 0:
                flag = False
                break
            elif H_ != H and h == 0:
                continue
            elif H_ != H:
                H = H_
                flag = True
            else:
                flag = True
                continue
        else:
            H = H_
        if h == 0 and n != 1:
            flag = False
        k += 1
    if flag == False or H > Hmax:
        continue
    else:
        Cx = i
        Cy = j
        Ch = H
    break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
lst = [[x, y] for x in range(101) for y in range(101)]
for i, j in lst:
    k = 0
    flag = True
    for x, y, h in xyh:
        H_ = calcH(x, i, y, j, h)
        if h == 0 and n != 1:
            flag = False
        if k > 0:
            if H_ != H and flag:
                flag = False
                break
            elif H_ != H:
                H = H_
                flag = True
            else:
                flag = True
                continue
        else:
            H = H_
        k += 1
    if flag == False or H > Hmax:
        continue
    else:
        Cx = i
        Cy = j
        Ch = H
    break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
lst = [[x, y] for x in range(101) for y in range(101)]
for i, j in lst:
    k = 0
    flag = True
    for x, y, h in xyh:
        H_ = calcH(x, i, y, j, h)
        if h == 0:
            flag = False if n != 1
        if k > 0:
            if H_ != H and flag:
                flag = False
                break
            elif H_ != H:
                H = H_
                flag = True
            else:
                flag = True
                continue
        else:
            H = H_
        k += 1
    if flag == False or H > Hmax:
        continue
    else:
        Cx = i
        Cy = j
        Ch = H
    break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2])
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h and abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2])
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
for i in range(101):
    for j in range(101):
        k = 0
        flag = True
        for x, y, h in xyh:
            H_ = calcH(x, i, y, j, h)
            if h == 0:
                flag = False if n != 1
            if k > 0:
                if H_ != H and flag:
                    flag = False
                    break
                elif H_ != H:
                    H = H_
                    flag = True
                else:
                    flag = True
                    continue
            else:
                H = H_
            k += 1
        if flag == False or H > Hmax:
            continue
        else:
            Cx = i
            Cy = j
            Ch = H
            break
    else:
        continue
    break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
N = int(input())
X = [0 for i in range(N)]
Y = [0 for i in range(N)]
H = [0 for i in range(N)]
tmp = []
for i in range(N):
    X[i], Y[i], H[i] = map(int, input().split())
for cx in range(0,101):
    for cy in range(0, 101):
        for i in range(N):
            if h != 0:
                ch = abs(X[i]-cx) + abs(Y[i]-cy) + H[i]
                tmp.add([cx, cy, ch])
for x, y, h in tmp:
    flag = True
    for i in range(N):
        if H[i] != max(h - abs(X[i]-x) - abs(Y[i]-y), 0)
            flag = False
            break
    if flag:
        print(x, y, h)
        break

Submission status: Runtime Error

Solution code:
N = int(input())
X = [0 for i in range(N)]
Y = [0 for i in range(N)]
H = [0 for i in range(N)]
tmp = []
for i in range(N):
    X[i], Y[i], H[i] = map(int, input().split())
for cx in range(0,101):
    for cy in range(0, 101):
        for i in range(N):
            if h != 0:
                ch = abs(X[i]-cx) + abs(Y[i]-cy) + H[i]
                tmp.add([cx, cy, ch])
for x, y, h in tmp:
    flag = True
    for i in range(N):
        if H[i] != max(h - abs(X[i]-cx) - abs(Y[i]-cy), 0)
            flag = False
            break
    if flag:
        print(x, y, h)
        break

Submission status: Runtime Error

Solution code:
n = int(input())
ss = [[int(i) for i in input().split()] for i in range(n)]


def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


ans = []
for i in range(len(ss)-1):

    temp = [] if i == 0 else get_unique_list(ans)
    ans = []

    x1, y1, h1 = ss[i]
    x2, y2, h2 = ss[i+1]

    for a in range(101):
        for b in range(101):
            left = h1 + abs(x1-a) + abs(y1 - b)
            right = h2 + abs(x2-a) + abs(y2 - b)
            if left == right and left > 0 and right > 0:
                if i == 0 or [a, b] in temp:  # 2回目移行
                    ans.append([a, b])

h = ss[0][2] + abs(ss[0][0] - ans[0][0]) + abs(ss[0][1] - ans[0][1])
print(ans[0][0], ans[0][1], h)

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
for i in range(101):
    for j in range(101):
        k = 0
        flag = True
        for x, y, h in xyh:
            H_ = calcH(x, i, y, j, h)
            if h == 0:
                flag = False
            if k > 0:
                if H_ != H and flag:
                    flag = False
                    break
                elif H_ != H:
                    H = H_
                    flag = True
                else:
                    flag = True
                    continue
            else:
                H = H_
                flag = True
            k += 1
        if flag == False or H > Hmax:
            continue
        else:
            Cx = i
            Cy = j
            Ch = H
            break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
def calcH(x, cx, y, cy, h):
    return abs(x-cx)+abs(y-cy)+h
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
Hmax = 10**9
for i in range(101):
    for j in range(101):
        k = 0
        flag = True
        for x, y, h in xyh:
            H_ = calcH(x, i, y, j, h)
            if h == 0:
                flag = False
            if k > 0:
                if H_ != H and flag:
                    flag = False
                    break
                elif H_ != H:
                    H = H_
                    flag = True
                else:
                    flag = True
                    continue
            else:
                H = H_
            k += 1
        if flag == False or H > Hmax:
            continue
        else:
            Cx = i
            Cy = j
            Ch = H
            break
print(Cx, Cy, Ch)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
yaku=set()
for i in range(1,m):
    yaku.add(m//i)
import copy
yakuc=copy.copy(yaku)
for i in yakuc:
    if i<n:
        yaku.remove(i)
yakul=list(yaku)
p=yakul[0]
print(m//p)

Submission status: Runtime Error

Solution code:
N = int(input())
ans = set()
for i in range(N):
    tmp = set()
    x, y, h = map(int, input().split())
    for cx in range(0,101):
        for cy in range(0, 101):
            ch = abs(x-cx) + abs(y-cy) + h
            if ch < 1 or (ch < 1 and h == 0):
                continue
            tmp.add((cx, cy, ch))
    if tmp == set():
        continue
    elif ans == set():
        ans = tmp
        continue
    ans = ans & tmp
ans = list(ans)[0]
print(ans[0], ans[1], ans[2])

Submission status: Runtime Error

Solution code:
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
#arr.sort(key=lambda l:-l[2])
 
for cx in range(101):
  for cy in range(101):
    ch = None
    for x, y, h in arr:
      t = h + abs(cx-x) + abs(cy-y)
      if h > 0:
        if ch is not None and t != ch:
          break
        ch = t
      else:
        if t < ch:
          break
    else:
      print(cx, cy, ch)
      exit()