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: Wrong Answer

Solution code:
def cal(X,Y,H):
    for i in range(0,101):
        for j in range(0,101):
            temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
            for l in range(1,N):
                if(H[l]!=0):
                    s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                    if(temp==s):
                        temp=s
                    else:
                        break
            else:
                return print("{} {} {}".format(i,j,s))

N=int(input())
X=[]
Y=[]
H=[]
for i in range(N):
    x,y,h=list(map(int,input().split()))
    X.append(x)
    Y.append(y)
    H.append(h)
cal(X,Y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyhs = [tuple(map(int, input().split())) for _ in range(N)]
xyhs.sort(key=lambda x: x[2])

# 中心座標(Cx,Cy)を全通り試す
for Cx in range(101):
    for Cy in range(101):
        x, y, h = xyhs[-1]
        H = h + abs(Cx - x) + abs(Cy - y)
        for x, y, h in reversed(xyhs[:-1]):
            if h == 0:
                print(Cx, Cy, H)
                exit()
            H2 = h + abs(Cx - x) + abs(Cy - y)
            if H != H2:
                break
        else:
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

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):
    for i in range(n):
        x,y,h = card[i]
        if i == 0:
            H = abs(x-cx)+abs(y-cy)+h  
        
        if h == max((H-abs(x-cx)-abs(y-cy)),0):
            continue
        else:
            return False
    else:
        return True
    
for i in range(101):
    for j in range(101):
        if check(i,j):
            ax = i
            ay = j
            
            x1,y1,h1 = card[0]
            ah = abs(x1-i)+abs(y1-j)+h1

            print("{} {} {}".format(ax,ay,ah))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for i in range(N):
    x,y,h = map(int,input().split())
    lis.append((x,y,h))
flag = 1
for i in range(101):
    for j in range(101):
        flag = 1
        H = lis[0][2]+abs(lis[0][0]-i)+abs(lis[0][1]-j)
        for k in range(N):
            if lis[k][2] != max(H-abs(lis[k][0]-i)-abs(lis[k][1]-j),0):
                flag = 0
                break
        if flag == 1:
            break
    if flag == 1:
        break
print(str(i)+" "+str(j)+" "+str(H))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = []
ans_c = 0
for i in range(101):
    for j in range(101):
        H = -1
        judge = True
        for k in range(N):
            if info[k][2] == 0:
                continue
            dis = abs(i - info[k][0]) + abs(j - info[k][1])
            if H == -1:
                H = info[k][2] + dis
            else:
                if H != (info[k][2] + dis):
                    judge = False
        if judge == True:
            ans_c += 1
            add_data = [i,j,H]
            ans.append(add_data)


for i in range(ans_c):
    judge = True
    for k in range(N):
        judge = True
        if info[k][2] == 0:
            h = max(abs(ans[i][0] - info[k][0]) + abs(ans[i][1] - info[k][1]),0)
            if h != 0:
                judge = False
    if judge == True:
        ans[0][0] = ans[i][0]
        ans[0][1] = ans[i][1]
        ans[0][2] = ans[i][2]
print("{} {} {}".format(ans[0][0],ans[0][1],ans[0][2]))

Submission status: Wrong Answer

Solution code:
N = int(input())

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

H = []
xy = []
first = True
for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            tm = h0-abs(x-xy0[0])-abs(y-xy0[1])
            if h == max(0, tm):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH


print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

Submission status: Wrong Answer

Solution code:
xlst = []
ylst = []
hlst = []
n = range(int(input()))
for i in n:
    xx, yy, hh = map(int, input().split())
    xlst += [xx]
    ylst += [yy]
    hlst += [hh]
for cx in range(min(xlst), max(xlst)+1):
    for cy in range(min(ylst), max(ylst)+1):
        print('--', cx, cy)
        hhlst = [hlst[i] + abs(xlst[i]-cx) + abs(ylst[i]-cy) for i in n]
        if len(list(set(hhlst))) == 1:
            print(list(set(hhlst)))
            exit()

Submission status: Wrong Answer

Solution code:
#C
N=int(input())
X=[]
Y=[]
H=[]
finish=False
for n in range(N):
    x,y,h=map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
    
for cx in range(101):
    if finish==True:
        break
    for cy in range(101):
        if finish==True:
            break
        for n,(x,y,h) in enumerate(zip(X,Y,H)):
            if n==0:
                height_zero=abs(x-cx)+abs(y-cy)+h
            else:
                height=abs(x-cx)+abs(y-cy)+h
                if height_zero!=height:
                    break
            if n==N-1:
                finish=True
print(cx-1,cy-1,height_zero)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

field = [[-1 for i in range(101)] for j in range(101)]

for i in range(N):
	x,y,h = map(int,input().split())
	if h == 0:
		continue
	for j in range(101):
		for k in range(101):
			if field[j][k] == -1:
				field[j][k] = h + abs(x-j) + abs(y-k)
			elif field[j][k] != h + abs(x-j) + abs(y-k):
				field[j][k] = -2

for i in range(101):
	for j in range(101):
		if field[i][j] > 0:
			print(i,j,field[i][j])

Submission status: Wrong Answer

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)

print()
for Cx in range(101):
    p = False
    for Cy in range(101):
        w = True
        previous = None
        for i in range(0,N):
            H = h[i] + abs(X[i] - Cx) + abs(Y[i] - Cy)
            if H - abs(X[i] - Cx) - abs(Y[i] - Cy) > 0:
                if not previous:
                    previous = H
                elif H != previous or H < 1:
                    w = False
                    break
        
        if w:
            answer = [Cx,Cy,H]
            p = True
            break

    if p:
        break

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

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

field = [[-1 for i in range(101)] for j in range(101)]

for i in range(N):
	x,y,h = map(int,input().split())
	if h == 0:
		break
	for j in range(101):
		for k in range(101):
			if field[j][k] == -1:
				field[j][k] = h + abs(x-j) + abs(y-k)
			elif field[j][k] != h + abs(x-j) + abs(y-k):
				field[j][k] = -2

for i in range(101):
	for j in range(101):
		if field[i][j] > 0:
			print(i,j,field[i][j])

Submission status: Wrong Answer

Solution code:
from itertools import product

n = int(input())
xs, ys, hs = zip(*[[int(x) for x in input().split()] for _ in range(n)])

for i, j in product(range(0,101), repeat=2):
    k = abs(xs[0]-i) + abs(ys[0]-j) + hs[0]
    for x, y, h in zip(xs[1:], ys[1:], hs[1:]):
        if k!=abs(x-i) + abs(y-j) + h:
            break
    else:
        print(i, j, k)
        break

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        x_0, y_0, h_0 = xyh[0]
        H = h_0 + abs(y_0-i) + abs(x_0-j)
        valid = True
        for x, y, h in xyh:
            if h+abs(y-i)+abs(x-j) != H:
                valid = False
                break
        if valid:
            ans = str(j)+' '+str(i)+' '+str(H)
            print(ans)
            exit()

Submission status: Wrong Answer

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

judge = 0
ans = [0, 0, 0]
for x in range(101):
    for y in range(101):
        judge = 0
        h = data[0][2] + abs(x-data[0][0]) + abs(y-data[0][1])
        for d in range(1, N):
            h_ = h - abs(x-data[d][0]) - abs(y-data[d][1])
            if data[d][2] == h_:
                continue
            else:
                judge = 1
                break
        if judge == 0:
            break
    if judge == 0:
        ans = [x, y, h]
        break
    else:
        judge = 0
        continue

for i in ans:
    print(i, end=" ")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N = int(input())

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


for xi in range(101):
    for yi in range(101):
        ans_list = []
        for x,y,h in xyhn:
            temp = h + abs(x - xi) + abs(y - yi)
            ans_list.append([xi,yi,temp])

        cx0,cy0,H0 = ans_list[0]
        odd_fg = False
        for cx,cy,H in ans_list:
            if cx == cx0 and cy == cy0 and H == H0:
                pass
            else:
                odd_fg = True

        if odd_fg:
            continue
        else:
            print("%d %d %d"%(cx0,cy0,H0))
            exit()

Submission status: Wrong Answer

Solution code:
def H(h,cx,cy,x,y):
    return h+abs(cx-x)+abs(cy-y)

n = int(input())
arr=[]
for i in range(n):
    arr.append(list(map(int, input().split())))
isSame = True
for cx in range(0,101):
    for cy in range(0,101):
        isSame = True
        h_prev=-1
        for a in arr:
            h= H(a[2],cx,cy,a[0],a[1])
            if h_prev==-1:
                h_prev=h
            if h!=h_prev:
                isSame=False
                break
            else:
                h_prev=h
        if isSame==True:
            print("{} {} {}".format(cx,cy,h))
            exit

Submission status: Wrong Answer

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

flag = False
flag2 = True
count = 0
for i in range(N):
    if INFO[i][2] == 0:
        count += 1
if N-count <= 3:
    flag = True

for x in range(0,101):
    for y in range(0,101):
        flag2 = True
        for i in range(N):
            if INFO[i][2]!=0:
                elseH = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
                break
        for i in range(N):
            H = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            if flag:
                if H != elseH:
                    flag2 = False
                    break
            else:
                if H != elseH and INFO[i][2]!=0:
                    flag2 = False
                    break

        if flag2:
            break
    if flag2:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
import sys
Input = sys.stdin.readline

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = None

if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h):
                if i == 0:
                    H = abs(c_x - x) + abs(c_y - y) + h
                elif H != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                Cx = c_x
                Cy = c_y
                print("{0} {1} {2}".format(Cx, Cy, H))
                sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]
H_pre = 0
for cx in range(101):
    for cy in range(101):
        for x, y, h in xyh:
            if h:
                if H_pre:
                    if H_pre != h + abs(x-cx) + abs(y-cy):
                        H_pre = 0
                        break
                else:
                    H_pre = h + abs(x-cx) + abs(y-cy)
        else:
            if N == 1:
                print(xyh[0][0],xyh[0][1],xyh[0][2])
            else:
                print(cx, cy, H_pre)
            exit()

Submission status: Wrong Answer

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

judge = 0
ans = [0, 0, 0]
for x in range(101):
    for y in range(101):
        judge = 0
        h = data[0][2] + abs(x-data[0][0]) + abs(y-data[0][1])
        for d in range(1, N):
            h_ = h - abs(x-data[d][0]) - abs(y-data[d][1])
            if data[d][2] == h_:
                continue
            else:
                judge = 1
                break
        if judge == 0:
            break
    if judge == 0:
        ans = [x, y, h]
        break
    else:
        judge = 0
        continue

            
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []; y = []; h = []

xmin = 0; ymin = 0; xmax = 101; ymax = 101

for i in range(n):
    xx, yy, hh = list(map(int, input().split(' ')))
    x.append(xx)
    y.append(yy)
    h.append(hh)

field = []

for i in range(n):
    if i == 0:
        for xx in range(xmin, xmax):
            f = []
            for yy in range(ymin, ymax):
                f.append(max(abs(xx - x[i]) + abs(yy - y[i]) + h[i], 0))
            field.append(f)
    
    else:
        for xx in range(xmin, xmax):
            for yy in range(ymin, ymax):
                f = max(abs(xx - x[i]) + abs(yy - y[i]) + h[i], 0)
                if field[xx][yy] != f:
                    field[xx][yy] = -1

maxx = 0; maxy = 0; maxV = 0
for xx in range(xmin, xmax):
    for yy in range(ymin, ymax):
        if maxV < field[xx][yy]:
            maxx = xx; maxy = yy; maxV = field[xx][yy]

print(str(maxx) + " " + str(maxy) + " " + str(maxV))

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = [list(map(lambda x:int(x),input().split())) for i in range(n)]
if n == 1:
    print(lists[0][0],lists[0][1],lists[0][2])
for i in range(101):
    for j in range(101):
        if lists[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i)>=1:
            H = lists[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i)
            for k in range(1,n):
                if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) >0:
                    if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) != H:
                        break
                    else :
                        if k == n-1:
                            print(i,j,lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i))

Submission status: Wrong Answer

Solution code:
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
def k(t,x,y):
  return abs(e[t+1][0]-x)+abs(e[t+1][1]-y)-abs(e[t][0]-x)-abs(e[t][1]-y)
for x in range(0,101):
    for y in range(0,101):
        for i in range(0,len(e)-1):
            if e[i][2]!=0 or e[i+1][2]!=0:
                if k(i,x,y)!=e[i][2]-e[i+1][2]:
                    break
        else:
            print(str(x)+" "+str(y)+" "+str(e[0][2]+abs(e[0][0]-x)+abs(e[0][1]-y)))

Submission status: Wrong Answer

Solution code:
N = int(input())
lis = []
for i in range(N):
    x,y,h = map(int,input().split())
    lis.append((x,y,h))
flag = 1
for i in range(101):
    for j in range(101):
        flag = 1
        H = lis[0][2]+abs(lis[0][0]-i)+abs(lis[0][1]-j)
        for k in range(N):
            if H != lis[k][2]+abs(lis[k][0]-i)+abs(lis[k][1]-j):
                flag = 0
                break
        if flag == 1:
            break
    if flag == 1:
        break
print(str(i)+" "+str(j)+" "+str(H))

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = [0]*n
        ans = 0
        for i in range(n):
            if xyh[i][2]!=0:
                h[i] = abs(xyh[i][0] - x) + abs(xyh[i][1] - y) + xyh[i][2]
                if ans == h[i] or ans ==0:
                    if i ==n-1:
                        print(x, y, h[i])
                    ans =h[i]
                else:
                    break

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        tl = []
        for l in xyh:
            if l[0] == l[1] == 0 or l[0] == l[1] == 100:
                print("{} {} {}".format(l[0], l[1], l[2]))
                exit(0)
            h = abs(l[0] - i) + abs(l[1] - j) + l[2]
            tl.append(h)
        
        sl = set(tl)
        if len(sl) == 1:
            print("{} {} {}".format(i, j, tl[0]))
            exit(0)

Submission status: Wrong Answer

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

judge = 0
ans = [0, 0, 0]
for x in range(11):
    for y in range(11):
        judge = 0
        h = data[0][2] + abs(x-data[0][0]) + abs(y-data[0][1])
        for d in range(1, N):
            h_ = h - abs(x-data[d][0]) - abs(y-data[d][1])
            if data[d][2] == h_:
                continue
            else:
                judge = 1
                break
        if judge == 0:
            break
    if judge == 0:
        ans = [x, y, h]
        break
    else:
        judge = 0
        continue

            
print(ans)

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


heights = []
N = getN()
xmax, ymax, xmin, ymin = (-1,0,0), (0,-1,0), (200,0,0), (0,200,0)

for i in range(N):
    data = getlist()
    x,y,h = data[0],data[1],data[2]
    heights.append(data)
    if x > xmax[0]:
        xmax = (x,y,h)
    if x < xmin[0]:
        xmin = (x,y,h)
    if y > ymax[1]:
        ymax = (x,y,h)
    if y < ymin[1]:
        ymin = (x,y,h)
ansx, ansy, ansh = 0,0,0
first = heights[0]
fx,fy,fh = first[0], first[1], first[2]
for x in range(0,101):
    for y in range(0,101):
        flag = 1
        cand_h = fh + abs(fx-x) + abs(fy-y)
        #print(cand_h, x,y)
        for i in range(1,N):
            comp = heights[i]
            if (cand_h - abs(comp[0]-x) - abs(comp[1]-y)) >= 0:
                if (comp[2] + abs(comp[0]-x) + abs(comp[1]-y)) != cand_h:
                    #print("break",x,y)
                    flag = 0

        if flag == 1:

            #print("success", x,y)
            ansx, ansy, ansh = x, y, cand_h

print(ansx,ansy,ansh)

Submission status: Wrong Answer

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

for cx in range(101):
  for cy in range(101):
    ch={h[i]+abs(x[i]-cx)+abs(y[i]-cy) for i in range(n)}
    if len(ch)==1:
      print(cx,cy,ch.pop())
      exit()

Submission status: Wrong Answer

Solution code:
a = int(input())

b = []

p = 0
pp = 0
ppp = 0
for i in range(a):
    b.append(list(map(int,input().split())))

for i in range(100,-1,-1):
    for j in range(100,-1,-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: Wrong Answer

Solution code:
import math

N = int(input())

field = [[-1 for i in range(101)] for j in range(101)]

for i in range(N):
	x,y,h = map(int,input().split())
	for j in range(101):
		for k in range(101):
			if field[j][k] == -1:
				field[j][k] = h + abs(x-j) + abs(y-k)
			elif field[j][k] != h + abs(x-j) + abs(y-k):
				field[j][k] = -2

for i in range(101):
	for j in range(101):
		if field[i][j] > 0:
			print(i,j,field[i][j])

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)
    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

cx_cand = range(101)
cy_cand = range(101)
end_flag = False
for cx in cx_cand:
    for cy in cy_cand:

        temp = h + np.abs(x - cx) + np.abs(y - cy)                 
        temp2 = h - np.abs(x - cx) - np.abs(y - cy)                 
        unuse = (temp2 < 0) * (h == 0)
#         if cx == 2:
#             if cy == 2:
#                 aaa
        temp = temp[unuse == False]

        if np.max(temp)== np.min(temp):
            end_flag = True
            break
    if end_flag:
        break

a = unuse == False
print(cx,cy,h[a][0] + np.abs(x[a][0] - cx) + np.abs(y[a][0] - cy))

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
for cx in range(cm+1):
    for cy in range(cm+1):
        contra = False
        Hmax = 1000000000
        Hmin = 0
        for i in range(N):
            HH = h[i] + abs(cx-x[i]) + abs(cy-y[i])
            if h[i] != 0:
                if Hmax < HH or Hmin > HH:
                    contra = True
                    break
                else:
                    Hmax = Hmin = HH
            else:
                if Hmax < HH:
                    contra = True
                    break
                else:
                    Hmax = HH
        if not contra:
            print(cx,cy,Hmax)
            exit()

Submission status: Wrong Answer

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

for i in range(0, 100):
    for j in range(0, 100):
        tl = []
        for l in xyh:
            if l[0] == l[1] == 0 or l[0] == l[1] == 100:
                print("{} {} {}".format(l[0], l[1], l[2]))
                exit(0)
            h = abs(l[0] - i) + abs(l[1] - j) + l[2]
            tl.append(h)
        
        sl = set(tl)
        if len(sl) == 1:
            print("{} {} {}".format(i, j, tl[0]))

Submission status: Wrong Answer

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)

print()
for Cx in range(101):
    p = False
    for Cy in range(101):
        w = True
        previous = None
        for i in range(0,N):
            H = h[i] + abs(X[i] - Cx) + abs(Y[i] - Cy)
            if H - abs(X[i] - Cx) - abs(Y[i] - Cy) > 0:
                if not previous:
                    previous = H
                elif H != previous:
                    w = False
                    break
        
        if w:
            answer = [Cx,Cy,H]
            p = True
            break

    if p:
        break

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

Submission status: Wrong Answer

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

for i in range(N):
    xi, yi, hi = map(int, input().split())
    if hi == 0:
        continue
    else:
        x.append(xi)
        y.append(yi)
        h.append(hi)


def fn(H, X, Y, Cx, Cy):
    return H + abs(Cx - X) + abs(Cy - Y)

for Cx in range(101):
    for Cy in range(101):
        height = fn(h[0], x[0], y[0], Cx, Cy)
        flag = True
        for i in range(1, len(h)):
            if height != fn(h[i], x[i], y[i], Cx, Cy):
                flag = False
                break
        if flag:
            print(Cx, Cy, height)
            exit()
print(1)

Submission status: Wrong Answer

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

H = 1
C_x = 0
C_y = 0

def height(C_x,C_y,x,y,h):
  H = h + abs(x-C_x) + abs(y-C_y)
  return H

def koud(C_x,C_y,H,x,y):
  h = H - abs(x-C_x) - abs(y-C_y)
  return h
  
flag = False

for i in range(0,101):
  C_x = i
  for j in range(0,101):
    C_y = j
    for k in range(N):
      if k == 0 :
        H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
      else:
        if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
          break
        else:
          continue
    else:
      flag = True
      break
    if flag:
      break
  if flag:
    break

print(C_x,C_y,H)

Submission status: Wrong Answer

Solution code:
a = int(input())

b = []

p = 0
pp = 0
ppp = 0
for i in range(a):
    b.append(list(map(int,input().split())))

for i in range(100,0,-1):
    for j in range(100,0,-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: Wrong Answer

Solution code:
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
def k(t,x,y):
  return abs(e[t+1][0]-x)+abs(e[t+1][1]-y)-abs(e[t][0]-x)-abs(e[t][1]-y)
for x in range(0,101):
    for y in range(0,101):
        for i in range(0,len(e)-1):
            if e[i][1]!=0 or e[i+1][2]!=0:
                if k(i,x,y)!=e[i][2]-e[i+1][2]:
                    break
        else:
            print(str(x)+" "+str(y)+" "+str(e[0][2]+abs(e[0][0]-x)+abs(e[0][1]-y)))

Submission status: Wrong Answer

Solution code:
N = int(input())

points = []
for i in range(0, N):
    xi, yi, hi = map(int, input().split())
    points.append((xi, yi, hi))

cand = {}
for CX in range(101):
    for CY in range(101):
        Hs = set()
        for x, y, h in points:
            H = h + abs(x - CX) + abs(y - CY)
            Hs.add(H)
        if len(Hs) == 1:
            cand[H] = (CX, CY, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        H = []
        check = []
        for k in range(n):
            x = a[k][0]
            y = a[k][1]
            h = a[k][2]
            if h ==  0:
                check.append((x, y))
            else:
                H.append(h + abs(x-i) + abs(y-j))
                if len(set(H)) > 1:
                    break
            if k == n-1:
                for s,t in check:
                    if H[0] - abs(s-i) - abs(t-j) > 0:
                        break
                print(i, j, H[0])
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
cx,cy = 0,0
list_xyh = []
for i in range(n):
    list_xyh.append(list(map(int, input().split())))
for cx in range(0,101):
    for cy in range(0,101):
        H = abs(cx - list_xyh[0][0]) + abs(cy - list_xyh[0][1]) + list_xyh[0][2]
        for i in range(n):
            if list_xyh[i][2] != 0:
                if H - list_xyh[i][2] == abs(cx - list_xyh[i][0]) + abs(cy - list_xyh[i][1]):
                    continue
                else:
                    break
        else:
            flag = "YES"
            for i in range(n):
                if list_xyh[i][2] == 0:
                    if H - abs(cx - list_xyh[i][0]) - abs(cy - list_xyh[i][1]) > 0:
                        flag = "NO"
            if flag != "NO":
                print(cx,cy,H)
                break
            else:
                continue

    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
x = np.array([xyh[i][0] for i in range(N)])
y = np.array([xyh[i][1] for i in range(N)])
h = np.array([xyh[i][2] for i in range(N)])
x_ = x[h != 0]
y_ = y[h != 0]
h_ = h[h != 0]
for Cx in range(101):
    for Cy in range(101):
        H = h_ + list(map(abs, [xi - Cx for xi in x_])) + list(map(abs, [yi - Cy for yi in y_]))
        if len(set(H)) == 1:
            break
    else:
        continue
    break
H = list(set(H))
print("{} {} {}".format(Cx, Cy, H[0]))

Submission status: Wrong Answer

Solution code:
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
xyh = []
xyh.sort(key=lambda x: x[2])
for _ in range(n):
    xyh.append(ai())

for cx in range(101):
    for cy in range(101):
        H = []
        d = []
        for x,y,h in xyh:
            H.append(h+abs(cx-x)+abs(cy-y))
            d.append(abs(cx-x)+abs(cy-y))
        hh = min(H)
        f = 0
        for i in range(n):
            if (d[i]>=hh and H[i] > hh) or (d[i] < hh and H[i] == hh):
                continue
            else:
                f = 1
                break
        if f == 0:
            print(cx,cy,hh)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
x = 0
y = 0
while y <= 100:
  x = 0
  while x <= 100:
    lis = []
    for arrays in grid:
      if arrays[2]>=1:
        lis.append(arrays[2]+abs(x-arrays[0])+abs(y-arrays[1]))
    if min(lis)==max(lis):
      print(x,y,max(0,arrays[2]+abs(x-arrays[0])+abs(y-arrays[1])))
      sys.exit()
    x += 1
  y += 1