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:
import numpy as np

N = int(input())
h = []
x = []
y = []
n = 100
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    h.append(tmp[0])
    x.append(tmp[1])
    y.append(tmp[2])
for i in range(len(h) - 1):
    for j in range(i + 1, len(h)):
        if abs(h[i] - h[j]) == abs(x[i] - x[j]) + abs(y[i] - y[j]):
            for X in range(n):
                for Y in range(n):
                    if ground[X][Y] != -1:
                        if h[i] > h[j]:
                            if ((X - x[i]) * (x[j] - x[i]) > 0 or (Y - y[i]) * (y[j] - y[i]) > 0 or h[i] + abs(X - x[i]) + abs(Y - y[i]) > n):
                                ground[X][Y] = -1
                            elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + abs(X - x[i]) + abs(Y + y[i])):
                                ground[X][Y] = -1
                            else:
                                ground[X][Y] = h[i] + abs(X - x[i]) + abs(Y + y[i])
                        elif h[j] > h[i]:
                            if ((X - x[j]) * (x[i] - x[j]) > 0 or (Y - y[j]) * (y[i] - y[j]) > 0 or h[j] + abs(X - x[j]) + abs(Y - y[j]) > n):
                                ground[X][Y] = 1
                            elif (ground[X][Y] > 0 and ground[X][Y] != h[j] + abs(X - x[j]) + abs(Y + y[j])):
                                ground[X][Y] = -1
                            else:
                                ground[X][Y] = h[j] + abs(X - x[j]) + abs(Y + y[j])
ans = [-1, -1]
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

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

for CX in range(0, 101):
    for CY in range(0, 101):
        H = -1
        for x, y, h in xyh:
            if h != 0:
                if H == -1:
                    H = abs(x - CX) + abs(y - CY) + h
                elif H != abs(x - CX) + abs(y - CY) + h:
                    break
            else:
                if H != -1 and H - abs(x - CX) - abs(y - CY) > 0:
                    break
        else:
            print(CX, CY, H)

Submission status: Wrong Answer

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


for CX in range(0, 101):
    for CY in range(0, 101):
        H = -1
        for x, y, h in xyh:
            if h != 0:
                if H == -1:
                    H = abs(x - CX) + abs(y - CY) + h
                elif H != abs(x - CX) + abs(y - CY) + h:
                    break
        else:
            print(CX, CY, H)

Submission status: Wrong Answer

Solution code:
import numpy as np
def solve(n, x, y, h):
    for cx in range(0, 101):
        for cy in range(0, 101):
            S = set()
            for i in range(n):
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                S.add(H)
            if (len(S) == 1) and (H > 0):
                return "%d %d %d" % (cx, cy, H)

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

Submission status: Wrong Answer

Solution code:


def func():

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

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

func()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [tuple(int(i) for i in input().split()) for i in range(N)]
 
 
def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def f(xyh):
    for cx in range(0, 101):
        for cy in range(0, 101):
            TH = set(H(cx, cy, x, y, h) for x, y, h in xyh if h > 0)
            if len(TH) == 1:
                yield (cx, cy, TH.pop())


def g(cxyh, xyh):
    for cx, cy, _th in cxyh:
        for x, y, h in xyh:
            if h == 0:
                yield H(cx, cy, x, y, h)


cxyh = [i for i in f(xyh)]

if len(cxyh) == 1:
    print("{} {} {}".format(*cxyh[0]))
else:
    max_h = max([i for i in g(cxyh, xyh)])
    print("{} {} {}".format(*[(cx, cy, th) for cx, cy, th in cxyh if 1 <= th <= max_h][0]))

Submission status: Wrong Answer

Solution code:


def func():

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

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

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

func()

Submission status: Wrong Answer

Solution code:


def func():

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

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

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

func()

Submission status: Wrong Answer

Solution code:


def func():

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

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

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

func()

Submission status: Wrong Answer

Solution code:


def func():

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

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

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

func()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [tuple(int(i) for i in input().split()) for i in range(N)]
 
 
def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)


def f(xyh):
    for cx in range(0, 101):
        for cy in range(0, 101):
            TH = set(H(cx, cy, x, y, h) for x, y, h in xyh if h > 0)
            if len(TH) == 1:
                yield (cx, cy, TH.pop())


def g(cxyh, xyh):
    for cx, cy, _th in cxyh:
        for x, y, h in xyh:
            if h == 0:
                yield H(cx, cy, x, y, h)


cxyh = [i for i in f(xyh)]

if len(cxyh) == 1:
    print("{} {} {}".format(*cxyh[0]))
else:
    l_g = [i for i in g(cxyh, xyh)]
    max_h = max(l_g)
    print("{} {} {}".format(*[(cx, cy, th)for cx, cy, th in cxyh if th <= max_h][0]))

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

x = [0 for i in range(N)]
y = [0 for i in range(N)]
h = [0 for i in range(N)]

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

# N = 4

# x = [2,2,1,3]
# y = [3,1,2,2]
# h = [5,5,5,5]

def dif(x,y,a,b):
    ans = int(abs(x-a) + abs(y-b))
    return(ans)


for i in range(N):
    if h[i] != 0:
        xt, yt, ht = x[i], y[i], h[i]
        break


for i in range(101):
    for j in range(101): # 頂点に関する全探索

        collect = True
        top = ht + dif(i, j, xt, yt)

        for k in range(N):
            h_predict = top - dif(x[k], y[k], i, j)

            if h[k] != h_predict:
                collect = False
                break

        if collect:
            print(i,j,top)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

x = [0 for i in range(N)]
y = [0 for i in range(N)]
h = [0 for i in range(N)]

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

# N = 4

# x = [2,2,1,3]
# y = [3,1,2,2]
# h = [5,5,5,5]

def dif(x,y,a,b):
    ans = int(abs(x-a) + abs(y-b))
    return(ans)


for i in range(N):
    if h[i] != 0:
        xt, yt, ht = x[i], y[i], h[i]
        break

print("xt,yt,ht = ",xt,yt,ht)

for i in range(101):
    for j in range(101): # 頂点に関する全探索
        print("i,j = ",i,j)


        collect = True
        top = ht + dif(i, j, xt, yt)
        print("top =",top)

        for k in range(N):
            print("trying",k,"-th info")
            h_predict = top - dif(x[k], y[k], i, j)
            print(h_predict)
            print(h[k])

            if h[k] != h_predict:
                collect = False
                break

        if collect:
            print(i,j,top)
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
table=[[0 for _ in range(101)] for _ in range(101)]
print(table)
for i in range(N):
    tmp=list(map(int, input().split()))
    if tmp[2]==100:
        print(tmp[0],tmp[1],tmp[2])
        exit(0)
    if table[0][1]:
        for j in range(101):
            table[tmp[0]][j]=max(0,tmp[2]-abs(j-tmp[1]))
        for j in range(101):
            table[j][tmp[1]]=max(0,tmp[2]-abs(j-tmp[0]))
    else:
            for j in range(101):
                table[tmp[0]][j]=max(0,tmp[2]-abs(j-tmp[1]))
            for j in range(101):
                table[j][tmp[1]]=max(0,tmp[2]-abs(j-tmp[0]))

Submission status: Wrong Answer

Solution code:
import sys
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)
inf=2e31-1
for i in range(101):
    for j in range(101):
        judge=True
        H1=inf
        for k in range(n): 
            if h[k-1]!=0:
                H1=h[k-1]+abs(i-1-x[k-1])+abs(j-1-y[k-1])
                break

        for k in range(n):
            if h[k-1]==0:
                if H1>abs(i-1-x[k-1])+abs(j-1-y[k-1]):
                    judge=False
                    break
            else:
                H2=h[k]+abs(i-1-x[k-1])+abs(j-1-y[k-1])
                if H1!=H2:
                    judge=False
                    break
                    
        if judge:
            sys.stdout.write(str(i-1))
            sys.stdout.write(' ')
            sys.stdout.write(str(j-1))
            sys.stdout.write(' ')
            print(H1)
            sys.exit()

Submission status: Wrong Answer

Solution code:


def func():

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

    for cx in range(101):
        for cy in range(101):
            dict = {}
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                for key in dict.keys():
                    if dict[key] == n-1:
                        if key-abs(disx)-abs(disy) >= 0:
                            print(cx,end=" ")
                            print(cy,end=" ")
                            print(key)
                            return 0

func()

Submission status: Wrong Answer

Solution code:


def func():

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

    for cx in range(101):
        for cy in range(101):
            dict = {}
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if h1 < 0:
                    break
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()

Submission status: Wrong Answer

Solution code:


def func():

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

    for cx in range(101):
        for cy in range(101):
            dict = {}
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()

Submission status: Wrong Answer

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



for cx in range(101):
    for cy in range(101):
        dict = {}
        for line in data:
            x = line[0]
            y = line[1]
            h = line[2]
            disx = x-cx
            disy = y-cy
            h1 = h + abs(disx) + abs(disy)
            if not h1 in dict:
                dict[h1] = 0
            else:
                dict[h1] += 1
            for key in dict.keys():
                if dict[key] == n-1:
                    print(cx,end=" ")
                    print(cy,end=" ")
                    print(key)

Submission status: Wrong Answer

Solution code:
import math
import sys

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

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

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

a1 = A[0]

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

#print(koho)

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

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

Submission status: Wrong Answer

Solution code:
import math
import sys

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

N = int(sys.stdin.readline())
A = sys.stdin.readlines()
A = [x.strip().split(" ") for x in A]
A = [[int(x) for x in y]for y in A]
 
koho = [[0] * 101 for i in range(101)]
ans = 1
 
a1 = A[0]
 
for x in range(0,101):
    for y in range(0,101):
        koho[x][y] = ds(a1[0], a1[1], x, y) + a1[2]

#print(koho)

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

# print(koho)
ans = " ".join(map(str, ans))
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


for hdata in heights:
    if hdata[2] != 0:
        first = hdata
        break
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(0,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:
            if cand_h <= 1000000000:
            #print("success", x,y)
                ansx, ansy, ansh = x, y, cand_h
if N == 1:
    print(fx, fy, fh)
else:
    print(ansx,ansy,ansh)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

p = []

for i in range(N):
    X1, Y1, H1 = map(int, input().split())
    if H1 != 0:
        p.append([X1, Y1, H1])


for i in range(101):
    for j in range(101):
        h = -1
        fg = True
        for t in p:
            if h == -1:
                h = t[2] + abs(i - t[0]) + abs(j - t[1])

            else:
                ht = t[2] + abs(i - t[0]) + abs(j - t[1])
                if h == ht:
                    h = ht
                else:
                    fg = False
                    break

        if fg:
            print(i, j, h)
            exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f():

  for i in range(101):
    for j in range(101):
      cx, cy = i, j
      a, b, c = l[0]
      H = c + abs(cx - a) + abs(cy - b)
      count = 0
      for data in l:
        x, y, h = data
        if h >= 1:
          if H == h + abs(cx - x) + abs(cy - y):
            count += 1
      
      if count == n:
        return ' '.join(map(str, [i, j, H]))

print(f())

Submission status: Wrong Answer

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

def f():

  for i in range(101):
    for j in range(101):
      cx, cy = i, j
      a, b, c = l[0]
      H = c + abs(cx - a) + abs(cy - b)
      count = 0
      for data in l:
        x, y, h = data
        if H == h + abs(cx - x) + abs(cy - y):
          count += 1
      
      if count == n:
        return ' '.join(map(str, [i, j, H]))

print(f())

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
sli = []
for i in range(n):
  sli.append(list(map(int,input().split())))
for j in range(101):
  for k in range(101):
    height = -1
    for item in sli:
      x,y,h = item
      if height == abs(j - x) + abs(k - y) + h or height == -1:
        height = abs(j - x) + abs(k - y) + h
      else:
        break
    else:
      print(j,k,height)
      sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for i in range(N):
    a,b,c = [int(hoge) for hoge in input().split()]
    x.append(a)
    y.append(b)
    h.append(c)

cx = 0
cy = 0
H = 0
done_flag = False

for i in range(101):
    for j in range(101):
        # (x, y) = (i, j)
        cand_h = []
        min_h = []

        for k in range(N):
            if h[k] != 0:
                cand_h.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            else:
                min_h.append(abs(x[k] - i) + abs(y[k] - j))
                
        min_h = min(min_h) if len(min_h) > 0 else 1
        cand_h = [x for x in cand_h if x >= min_h]

        if len(set(cand_h)) == 1:
            print("{} {} {}".format(i, j, cand_h[0]))
            done_flag = True
            break
    if done_flag:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for i in range(N):
    a,b,c = [int(hoge) for hoge in input().split()]
    x.append(a)
    y.append(b)
    h.append(c)
    
cand_h = []
cx = 0
cy = 0
H = 0
done_flag = False

for i in range(101):
    for j in range(101):
        # (x, y) = (i, j)
        cand_h = []

        for k in range(N):
            if h[k] != 0:
                cand_h.append(h[k] + abs(x[k] - i) + abs(y[k] - j))

        if len(set(cand_h)) == 1:
            print("{} {} {}".format(i, j, cand_h[0]))
            done_flag = True
            break
    if done_flag:
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[]
for i in range(n):
    a=list(map(int,input().split()))
    if a[2]!=0:lst.append(a)
for i in range(101):
    for j in range(101):
        h=abs(i-lst[0][0])+abs(j-lst[0][1])+lst[0][2]
        for k in lst[1:]:
            if h!=abs(i-k[0])+abs(j-k[1])+k[2]:break
        else:
            print(i,j,h)
            exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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