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

def solve():
    for cx in range(101):
        for cy in range(101):
            H = -1
            Hmax = 114514
            flg = True
            for i in range(N):
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if h[i] > 0:
                    HH = h[i] + dist
                    if H < 0:
                        H = HH
                    if H != HH or H > Hmax:
                        flg = False
                        break
                else:
                    Hmax = min(Hmax, dist)
                    if H > Hmax:
                        flg = False
                        break
            if flg:
                if Hmax == 1:
                    H = 1
                print(cx, cy, H)
                return

solve()

Submission status: Wrong Answer

Solution code:
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)

def solve():
    for cx in range(101):
        for cy in range(101):
            H = -1
            Hmax = 114514
            flg = True
            for i in range(N):
                dist = abs(x[i] - cx) + abs(y[i] - cy)
                if h[i] > 0:
                    HH = h[i] + dist
                    if H < 0:
                        H = HH
                    if H != HH or H > Hmax:
                        flg = False
                        break
                else:
                    Hmax = min(Hmax, dist)
                    if H > Hmax:
                        flg = False
                        break
            if flg:
                print(cx, cy, H)
                return

solve()

Submission status: Wrong Answer

Solution code:
#112C
n = int(input())
p = [[int(i) for i in input().split()] for i in range(n)]
p.sort(key=lambda x: x[2])
a,b,c = p[0]
f = 0
for cx in range(101):
    for cy in range(101):
        h = c+abs(a-cx)+abs(b-cy)
        if all(k==max(h-abs(i-cx)-abs(j-cy),0) for i,j,k in p): f = 1
        if f: break
    if f: break
print(cx,cy,h)

Submission status: Wrong Answer

Solution code:
N=input()
 
N=int(N)
 
x=list()
y=list()
h=list()
for i in range(N):
    temp=input().split(" ")
    x.append(int(temp[0]))
    y.append(int(temp[1]))
    h.append(int(temp[2]))
    
def pass_all_condition(x,y,h,x_i,y_i,h_i):
    result=True
    for  k in range(len(x)):
        if h[k]!=max(h_i-abs(x_i-x[k])-abs(y_i-y[k]),0):
            result=False
    return(result)
    
def print_answer(x,y,h):
    for x_i in range(101):
        for y_i in range(101):
            for h_i in range(1,101):
                if pass_all_condition(x,y,h,x_i,y_i,h_i):
                    print(x_i, y_i, h_i)
                    return
 
print_answer(x,y,h)

Submission status: Wrong Answer

Solution code:
N=input()

N=int(N)

x=list()
y=list()
h=list()
for i in range(N):
    temp=input().split(" ")
    x.append(int(temp[0]))
    y.append(int(temp[1]))
    h.append(int(temp[2]))
    
def pass_all_condition(x,y,h,x_i,y_i,h_i):
    result=True
    for  k in range(len(x)):
        if h[k]!=max(h_i-abs(x_i-x[k])-abs(y_i-y[k]),0):
            result=False
    return(result)
    
def print_answer(x,y,h):
    for x_i in range(100):
        for y_i in range(100):
            for h_i in range(1,100):
                if pass_all_condition(x,y,h,x_i,y_i,h_i):
                    print(x_i, y_i, h_i)
                    return

print_answer(x,y,h)

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        needH = -1

        for x, y, h in xyh:
            if h > 0:
                # この頂点から見て、頂上がcx, cyのときどのくらいの高さがあってほしいか
                tmp = h + abs(cx - x) + abs(cy - y)
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break

        if needH == -2:
            continue

        for x, y, h, in xyh:
            if h == 0:
                dist = abs(cx - x) + abs(cy - y)
                if needH > dist:
                    needH == -2
                    break
        if needH == -2:
            continue

        print(cx, cy, needH)
        exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        needH = -1

        for x, y, h in xyh:
            if h > 0:
                # この頂点から見て、頂上がcx, cyのときどのくらいの高さがあってほしいか
                tmp = h + abs(cx - x) + abs(cy - y)
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break

        if needH == -2:
            continue

        for x, y, h, in xyh:
            if h == 0:
                dist = h + abs(cx - x) + abs(cy - y)
                if needH > dist:
                    needH == -2
                    break
        if needH == -2:
            continue

        print(cx, cy, needH)
        exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        needH = -1
        ans = True

        for x, y, h in xyh:
            if h > 0:
                # この頂点から見て、頂上がcx, cyのときどのくらいの高さがあってほしいか
                tmp = h + abs(cx - x) + abs(cy - y)
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2

            if needH == -2:
                continue

        for x, y, h, in xyh:
            if h == 0:
                dist = h + abs(cx - x) + abs(cy - y)
                if needH > dist:
                    needH == -2
                    break
        if needH == -2:
            continue

        print('{} {} {}'.format(cx, cy, needH))

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        needH = -1
        ans = True

        for x, y, h in xyh:
            if h > 0:
                # この頂点から見て、頂上がcx, cyのときどのくらいの高さがあってほしいか
                tmp = h + abs(cx - x) + abs(cy - y)
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2

        if needH == -2:
            continue

        for x, y, h, in xyh:
            if h == 0:
                dist = h + abs(cx - x) + abs(cy - y)
                if needH > dist:
                    needH == -2
                    break
        if needH == -2:
            continue

        print('{} {} {}'.format(cx, cy, needH))

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split())) for i in range(N)]
MAX=100
for PosY in range(MAX+1):
    for PosX in range(MAX+1):
        needH=-1
        for i in range(N):
            tmp=xyh[i][2]+abs(PosX-xyh[i][0])+abs(PosY-xyh[i][1])
            if needH==-1:
                needH=tmp
            else:
                if needH!=tmp:
                    needH=-2
                    break
        if needH==-2:
            continue
        for i in range(N):
            if xyh[i][2]==0:
                dist=abs(PosX-xyh[i][0])+abs(PosY-xyh[i][1])
                if needH>dist:
                    needH=-2
                    break
        if needH==-2:
            continue
        print(PosX,PosY,needH)

Submission status: Wrong Answer

Solution code:
n = int(input())
x, y, h = [], [], []
for _ in range(n):
    xi, yi, hi = map(int, input().split())
    x.append(xi)
    y.append(yi)
    h.append(hi)

for cx in range(101):
    for cy in range(101):
        H = []
        for i in range(len(x)):
            H.append(max(abs(x[i] - cx) + abs(y[i] - cy) + h[i], 0))
        if len(set(H)) == 1:
            print('{} {} {}'.format(cx, cy, H[0]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
sm = [list(map(int, input().split())) for _ in range(N)]
for cx in range(101):
    for cy in range(101):
        se = set()
        for x,y,h in sm:
            con = -abs(x-cx)-abs(y-cy)
            if h <= con:
                break
            se.add(h - con)
        else:
            if len(se) == 1:
                print(cx, cy, se.pop())

Submission status: Wrong Answer

Solution code:
N = int(input())
sm = [list(map(int, input().split())) for _ in range(N)]
for cx in range(100):
    for cy in range(100):
        se = set()
        for x,y,h in sm:
            con = -abs(x-cx)-abs(y-cy)
            if h <= con:
                break
            se.add(h - con)
        if len(se) == 1:
            print(cx, cy, se.pop())

Submission status: Wrong Answer

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

ans = None
for cx in range(101):
    for cy in range(101):
        H_tmp = -1
        # print("#", cx, cy)
        for xi, yi, hi in sorted(xyh, key=lambda x: -x[2]):
            if hi == 0: continue
            # print("##", (xi, yi, hi), H_tmp)
            dx = (xi - cx) if xi >= cx else (cx - xi)
            dy = (yi - cy) if yi >= cy else (cy - yi)
            if H_tmp == -1: H_tmp = hi + dx + dy
            elif H_tmp == hi + dx + dy: H_tmp = hi + dx + dy
            else: break
        else:
            ans = (cx, cy, H_tmp)
        if ans != None: break
    if ans != None: break

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

Submission status: Wrong Answer

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

# h >  0 => h == H - |x - CX| - |y - CY| (<= H)
# h == 0 => 0 >= H - |x - CX| - |y - CY|

MAX_X = 100
MAX_Y = 100

H = {(x, y): None for x in range(MAX_X + 1) for y in range(MAX_Y + 1)}

for x, y, h in xyh:
    for cx, cy in list(H.keys()):
        hh = h + abs(x - cx) + abs(y - cy)
        if   H[(cx, cy)] == None:
             H[(cx, cy)] =  hh
        elif H[(cx, cy)] != hh:
             del H[(cx, cy)]

for cx, cy in H:
    print(cx, cy, H[(cx, cy)])

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
pos = list()
for i in range(n):
    xyh = list(map(int,input().split()))
    pos.append(xyh)
h_list = list()
for i in range(101):
    for j in range(101):
        h_list=list()
        for k in range(n):
            h = max(pos[k][2]+abs(pos[k][0]-i)+abs(pos[k][1]-j),0)
            h_list.append(h)
        if max(h_list)==min(h_list):
            print(i,j,h_list[0])
            sys.exit()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(101):
        for j in range(101):
            rh = -1
            for x,y,h in a:
                th = h + abs(i-x) + abs(j-y)
                if rh < th:
                    rh = th
            f = True
            for x,y,h in a[1:]:
                if max(rh - abs(i-x) - abs(j-y),0) != h:
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(101):
        for j in range(101):
            rh = -1
            for x,y,h in a:
                rh = h + abs(i-x) + abs(j-y)
                if h == 0:
                    continue
                break
            f = True
            for x,y,h in a[1:]:
                if max(rh - abs(i-x) - abs(j-y),0) != h:
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(101):
        for j in range(101):
            rh = -1
            for x,y,h in a:
                if h == 0:
                    continue
                rh = h + abs(i-x) + abs(j-y)
                break
            f = True
            for x,y,h in a[1:]:
                if max(rh - abs(i-x) - abs(j-y),0) != h:
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(101):
        for j in range(101):
            rh = a[0][2] + abs(i-a[0][0]) + abs(j-a[0][1])
            f = True
            for x,y,h in a[1:]:
                if max(rh - abs(i-x) - abs(j-y),0) != h:
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(-100,201):
        for j in range(-100,201):
            rh = a[0][2] + abs(i-a[0][0]) + abs(j-a[0][1])
            f = True
            for x,y,h in a[1:]:
                if max(rh - abs(i-x) - abs(j-y),0) != h:
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(-100,201):
        for j in range(-100,201):
            rh = a[0][2] + abs(i-a[0][0]) + abs(j-a[0][1])
            f = True
            for x,y,h in a[1:]:
                if rh != h + abs(i-x) + abs(j-y):
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    for i in range(101):
        for j in range(101):
            rh = a[0][2] + abs(i-a[0][0]) + abs(j-a[0][1])
            f = True
            for x,y,h in a[1:]:
                if rh != h + abs(i-x) + abs(j-y):
                    f = False
                    break
            if f:
                return '{} {} {}'.format(i,j,rh)

    return -1


print(main())

Submission status: Wrong Answer

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

for cx in range(101):
	for cy in range(101):
		flag=0
		for H in range(1,201):
			for x,y,h in A:
				if h==max( H-abs(x-cx)-abs(y-cy), 0):
					pass
				else:
					break
			else:
				print cx,cy,H
				quit()

Submission status: Wrong Answer

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

for cx in range(101):
	for cy in range(101):
		flag=0
		for H in range(201):
			for x,y,h in A:
				if h==max( H-abs(x-cx)-abs(y-cy), 0):
					pass
				else:
					break
			else:
				print cx,cy,H
				quit()

Submission status: Wrong Answer

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

for cx in range(101):
	for cy in range(101):
		for H in range(201):
			for x,y,h in A:
				if H==abs(x-cx)+abs(y-cy)+h:
					pass
				else:
					break
			else:
				print cx,cy,H
				quit()

Submission status: Wrong Answer

Solution code:
import sys
N=int(input())
table=[]
def f(cx,cy,h,x,y):
    return max(h-abs(x-cx)-abs(y-cy),0)
for i in range(N):
    x,y,h=map(int,input().split())
    table.append((x,y,h))
for cx in range(101):
    for cy in range(101):
        n=0
        h=0
        while n<N:
            x,y,z=table[n]
            if z>0:
                h=z+abs(cx-x)+abs(cy-y)
                break
            n+=1
        flag=True
        while n<N:
            x,y,z=table[n]
            if f(cx,cy,h,x,y)!=z:
                flag=False
                break
            n+=1
        if flag:
            print(cx,cy,h)
            sys.exit()

Submission status: Wrong Answer

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

for cx in range(101):
	for cy in range(101):
		for H in range(201):
			for x,y,h in A:
				if H is None:
					H=abs(x-cx)+abs(y-cy)+h
				else:
					if H==abs(x-cx)+abs(y-cy)+h:
						pass
					else:
						break
			else:
				print cx,cy,H
				quit()

Submission status: Wrong Answer

Solution code:
N = int(input())

xy_h = { }
for n in range(N):
  x,y,h = map(int, input().split())
  key = (x,y)
  xy_h[key] = h

for sx in range(100+1):
  for sy in range(100+1):
    
    rhs = []
    for xy, h in xy_h.items():
      x,y = xy
      rh = h + abs(x - sx) + abs(y - sy)
      rhs.append(rh)
    check = all( [ x == rh for x in rhs ] )
    #print(sx, sy, rh, check) 
   
    if check is True:
      print(sx, sy, rh) 
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

in_list = []
x0, y0, h0 = 0, 0, 0
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)
        x0, y0, h0 = xyh[0], xyh[1], xyh[2]


for Cx in range(0, 101):
    for Cy in range(0, 101):
        for xyh in in_list:
            x, y, h = xyh[0], xyh[1], xyh[2]
            H = h0 + abs(x0-Cx) + abs(y0-Cy)
            if h != max(H-abs(x-Cx)-abs(y-Cy), 0):
                break
        else:
            print(Cx, Cy, H)

Submission status: Wrong Answer

Solution code:
N = int(input())

in_list = []
x0, y0, h0 = 0, 0, 0
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)
        x0, y0, h0 = xyh[0], xyh[1], xyh[2]


for x1 in range(0, 101):
    for y1 in range(0, 101):
        for xyh in in_list:
            x, y, h = xyh[0], xyh[1], xyh[2]
            H = h + abs(x0-x1) + abs(y0-y1)
            if h != max(H-abs(x-x1)-abs(y-y1), 0):
                break
        else:
            print(x1, y1, H)

Submission status: Wrong Answer

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

def main():
    for i in range(N):
        x, y, h = map(int, input().split())
        X.append(x)
        Y.append(y)
        H.append(h)

    for posY in range(101):
        for posX in range(101):

            # 頂点の高さを求める
            # -1はよく分かってないない時、だけど0より上は決まってる
            # -2はだめだとわかった時
            needH = -1
            
            for i in range(N):

                # H[i]==0 は、平地の可能性もあるので、高さの確認から省く
                if H[i] > 0:
                    
                    # 各座標の情報から、現在のposX、posYが頂点だとした時、
                    # 頂点の高さはどのくらい必要かを求める
                    tmp = H[i] + abs(posY - Y[i]) + abs(posX - X[i])

                    #最初、-1だったらtmpを保存する
                    if needH == -1:
                        needH = tmp
                    #2回め以降、与えられた座標から得たtmpがneedHと違っていたら間違ってる
                    elif needH != tmp:
                        needH = -2
                        break
                
            #だめだったら別の場所を探す
            if needH == -2:
                continue

            # 省いた H[i]==0　に矛盾がないか調べる
            for i in range(N):
                if H[i] == 0:

                    # 頂上との距離が高さより大きければH[i]==0の情報は正しい
                    dist = abs(posY - Y[i]) + abs(posX - X[i])
                    if needH > dist:
                        needH = -2
                        break

            #見つけたら[そのまま出力する
            print(posX, posY, needH)
            return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    for i in range(N):
        x, y, h = map(int, input().split())
        X.append(x)
        Y.append(y)
        H.append(h)

    for posY in range(101):
        for posX in range(101):

            # 頂点の高さを求める
            # -1はよく分かってないない時、だけど0より上は決まってる
            # -2はだめだとわかった時
            needH = -1
            
            for i in range(N):

                if H[i] > 0:
                    
                    # 各座標の情報から、現在のposX、posYが頂点だとした時、
                    # 頂点の高さはどのくらい必要かを求める
                    tmp = H[i] + abs(posY - Y[i]) + abs(posX - X[i])

                    #最初、-1だったらtmpを保存する
                    if needH == -1:
                        needH = tmp
                    #2回め以降、与えられた座標から得たtmpがneedHと違っていたら間違ってる
                    elif needH != tmp:
                        needH = -2
                        break

            #だめだったら別の場所を探す
            if needH == -2:
                continue

            #見つけたらそのまま出力する
            print(posX, posY, needH)
            return 0

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

x_list=[]
y_list=[]
h_list=[]
h_now_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(101):
	for cx in range(101):
		n = -1	
		for h in h_list:
			n += 1
			if h >= 1:
				H = abs(cx - x_list[n])+abs(cy - y_list[n])+h
				break
		for i in range(N):
			h_now = max(H-abs(cx - x_list[i])-abs(cy - y_list[i]), 0)
			h_now_list.append(h_now)
			if h_now != h_list[i]:
				break	
		if len(h_now_list) == N:
			print(str(cx)+' '+str(cy)+' '+str(H))
			break		
	else:
		continue
	break

Submission status: Wrong Answer

Solution code:
N = int(input())

XYH = set()
flag = True
for i in range(N):
    x, y, h = map(int, input().split())
    if (flag is True) and h > 0:
        flag = False
        ex_x = x
        ex_y = y
        ex_h = h
        continue
    XYH.add((x, y, h))

flag = False
for x in range(0, 101):
    for y in range(0, 101):
        # print(x, y)
        hight = ex_h + abs(x - ex_x) + abs(y - ex_y)
        for tx, ty, th in XYH:
            div = abs(x - tx) + abs(y - ty)
            if div > hight:
                if hight == 0:
                    continue
                else:
                    break

            if hight != th + abs(x - tx) + abs(y - ty):
                break
        else:
            print(x, y, hight)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

XYH = set()
flag = True
for i in range(N):
    x, y, h = map(int, input().split())
    if (flag is True) and h > 0:
        flag = False
        ex_x = x
        ex_y = y
        ex_h = h
        continue
    XYH.add((x, y, h))

flag = False
for x in range(0, 101):
    for y in range(0, 101):
        # print(x, y)
        hight = ex_h + abs(x - ex_x) + abs(y - ex_y)
        for tx, ty, th in XYH:
            div = abs(x - tx) + abs(y - ty)
            if div > hight and hight == 0:
                continue
            
            if hight != th + abs(x - tx) + abs(y - ty):
                break
        else:
            print(x, y, hight)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

XYH = set()
flag = True
for i in range(N):
    x, y, h = map(int, input().split())
    if (flag is True) and h > 0:
        flag = False
        ex_x = x
        ex_y = y
        ex_h = h
        continue
    XYH.add((x, y, h))

flag = False
for x in range(0, 101):
    for y in range(0, 101):
        # print(x, y)
        hight = ex_h + abs(x - ex_x) + abs(y - ex_y)
        for tx, ty, th in XYH:
            div = abs(x - tx) + abs(y - ty)
            if div > hight and hight > 0:
                break
            elif hight != th + abs(x - tx) + abs(y - ty):
                break
        else:
            print(x, y, hight)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
list = sorted([list(map(int,input().split())) for x in range(N)],reverse=True)

H = 0
Cx = 0
Cy= 0
h = 0

for Cx in range(101):
    for Cy in range(101):
        H = list[0][2] + abs(list[0][0] - Cx) + abs(list[0][1] - Cy)
        for i in range(len(list)):
            if list[i][2] != max(H-abs(list[i][0]-Cx)-abs(list[i][1]-Cy),0):
                break
        else:
            print(Cx,Cy,H)

Submission status: Wrong Answer

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

H = 0
Cx = 0
Cy= 0
h = 0

for Cx in range(0,101):
    for Cy in range(0,101):
        H = list[0][2] + abs(list[0][0] - Cx) + abs(list[0][1] - Cy)
        for i in range(len(list)):
            if list[i][2] != max(H-abs(list[i][0]-Cx)-abs(list[i][1]-Cy),0):
                break
        else:
            print(Cx,Cy,H)