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())
XYH = []
Cx, Cy, H = 0, 0, 1
for _ in range(N):
    XYH.extend([list(map(int, input().split()))])
tmpH = 0
for x in range(100+1):
    for y in range(100+1):
        for i in range(len(XYH)):
            if i == 0:
                tmpH = XYH[i][2] + abs(XYH[i][0] - x) + abs(XYH[i][1] - y)
            if XYH[i][2] == 0:
                continue
            H = XYH[i][2] + abs(XYH[i][0] - x) + abs(XYH[i][1] - y)
            if tmpH == H and i == len(XYH) - 1:
                print(x, y, H)
            elif tmpH == H:
                tmpH = H
            else:
                break

Submission status: Wrong Answer

Solution code:
N=int(input())
XYH = [[int(a) for a in input().split(" ")] for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        Hp = [abs(x-cx)+abs(y-cy)+h for x, y, h in XYH if h>0]
        Hz = [Hp[0]-abs(x-cx)-abs(y-cy) for x,y,h in XYH if h==0] 
        if all([h==Hp[0] for h in Hp]) and all([h>=0 for h in Hz]):
            print(" ".join([str(cx),str(cy),str(Hp[0])]))

Submission status: Wrong Answer

Solution code:
N=int(input())
XYH = [[int(a) for a in input().split(" ")] for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        H = [abs(x-cx)+abs(y-cy)+h for x, y, h in XYH if h>0]
        if all([h==H[0] for h in H]):
            print(" ".join([str(cx),str(cy),str(H[0])]))

Submission status: Wrong Answer

Solution code:
import math
N = int( input())
di = [[-1] * 101 for i in range(101)]
temp = list(map(int,input().split(" ")))
h = temp[2]
x = temp[0]
y = temp[1]

for i in range(0,101):
    for j in range(0,101):
        di[i][j] = [h + abs(x-i)  + abs(y-j)]



for k in range(N-1):
    temp = list(map(int,input().split(" ")))
    h = temp[2]
    x = temp[0]
    y = temp[1]

    for i in range(0,101):
        for j in range(0,101):
            di[i][j].append(h + abs(x-i)  + abs(y-j))

for i in range(0,101):
        for j in range(0,101):
            if len(list(set(di[i][j]))) == 1:
                print(i,j,di[i][j][0])

Submission status: Wrong Answer

Solution code:
from itertools import product

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

for cx, cy in product(range(101), repeat=2):
    H = h[0] + abs(x[0] - cx) + abs(y[0] - cy)
    ok = True
    for i in range(1, N):
        if h[i] != max(H - abs(x[i] - cx) - abs(y[i] - cy), 0):
            ok = False
            break
    if ok:
        print(cx, cy, H)
        break

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())

xyh=[[int(l) for l in k] for k in [j.split() for j in [i.strip() for i in sys.stdin.readlines()]]]

#print(xyh)
ef=0

def hgh(c,p):
    return abs(c[0]-p[0])+abs(c[1]-p[1])+p[2]

for x in range(101):
    if ef:
        break
    for y in range(101):
        th = 0
        for plc in xyh:
            c=1
            if not plc[2]:
                continue
            h = hgh([x,y],plc)
            if not th:
                th = h
                continue
            if h!=th:
                c=0
                break
        if c:
            ef=1
            ans=[str(s) for s in [x,y,th]]
            break

print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())

xyh=[[int(l) for l in k] for k in [j.split() for j in [i.strip() for i in sys.stdin.readlines()]]]

#print(xyh)
ef=0

def hgh(c,p):
    return abs(c[0]-p[0])+abs(c[1]-p[1])+p[2]

ans=[]

for x in range(101):
    if ef:
        break
    for y in range(101):
        th = 0
        for plc in xyh:
            c=1
            if not plc[2]:
                continue
            h = hgh([x,y],plc)
            if not th:
                th = h
                continue
            if h!=th:
                c=0
                break
        if c:
            ef=1
            ans=[str(s) for s in [x,y,th]]
            break

print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())

xyh=[[int(l) for l in k] for k in [j.split() for j in [i.strip() for i in sys.stdin.readlines()]]]

#print(xyh)
ef=0

def hgh(c,p):
    return abs(c[0]-p[0])+abs(c[1]-p[1])+p[2]

ans=[]

for x in range(101):
    if ef:
        break
    for y in range(101):
        th = 0
        for plc in xyh:
            c=1
            h = hgh([x,y],plc)
            if not th:
                th = h
                continue
            if h!=th:
                c=0
                break
        if c:
            ef=1
            ans=[ str(s) for s in [x,y,th]]
            break

print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
import sys
place=[]
place_0=[]
place_all=[]
for i in range(n):
    x,y,h=map(int,input().split())
    place_all.append((x,y,h))
    if h==0:
        place_0.append((x,y,h))
    else:
        place.append((x,y,h))
for x in range(0,101):
    for y in range(0,101):
        if not place==[]:
            H=abs(place[0][0]-x)+abs(place[0][1]-y)+place[0][2]
        else:
            H=1
        for i in range(1,n):
            d=abs(place_all[i][0]-x)+abs(place_all[i][1]-y)
            if place_all[i][2]>0:
                if H==place_all[i][2]+d:
                    count=1
                else:
                    count=0
                    break
            else:
                if d>=H:
                    count=1
                else:
                    count=0
                    break
        if count==1:
            print(x,y,H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
import sys
place=[]
for i in range(n):
    x,y,h=map(int,input().split())
    place.append((x,y,h))
for x in range(0,101):
    for y in range(0,101):
        for i in range(n-1):
            a=abs(place[i][0]-x)+abs(place[i][1]-y)
            b=abs(place[i+1][0]-x)+abs(place[i+1][1]-y)
            if b-a==place[i][2]-place[i+1][2]:
                count=1
            else:
                count=0
                break
        if count==1:
            H=abs(place[0][0]-x)+abs(place[0][1]-y)+place[0][2]
            print(x,y,H)
            sys.exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        flag = True
        flag_init = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if flag_init:
                    H0 = H
                    flag_init = False
                else:
                    if H != H0:
                        flag = False
        if flag == True and H >= 1:
            print(cx, cy, H)
            break

    else:
        continue
    break

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        flag = True
        flag_init = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if flag_init:
                    H0 = H
                    flag_init = False
                else:
                    if H != H0:
                        flag = False
        if flag == True:
            print(cx, cy, H)
            break
        
    else:
        continue
    break

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        flag = True
        flag_init = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if flag_init:
                    H0 = H
                    flag_init = False
                else:
                    if H != H0:
                        flag = False
        if flag == True:
            print(cx, cy, H)

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        flag = True
        flag_init = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if flag_init:
                    H0 = H
                    flag_init = False
                else:
                    if H != H0:
                        flag = False
            if _n == n-1 and flag == True:
                print(cx, cy, H)

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        flag = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if _n == 0:
                    H0 = H

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        flag = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    for i, j in product(range(0, 101), range(0, 101)):
        H = set()
        for xx, yy, hh in zip(x, y, h):
            if 0 < hh:
                ch = hh + abs(xx - i) + abs(yy - j)
                H.add(ch)
        if len(H) == 1:
            return "{} {} {}".format(i, j, list(H)[0])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    result = solve(N, x, y, h)
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
I = [list(map(int, input().split())) for _ in range(n)]
cands = [[x, y] for x in range(101) for y in range(101)]
for cand in cands:
    h = 0
    flag = 0
    for i in I:
        if i[2] == 0:
            continue
        ch = i[2] + abs(i[0] - cand[0]) + abs(i[1] - cand[1])
        if h == 0:
            flag = 1
            h = ch
            continue
        if h != 0:
            if h != ch:
                flag = 0
                break
    if flag == 1:
        print(cand[0], cand[1], h)
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
I = [list(map(int, input().split())) for _ in range(n)]
cands = [[x, y] for x in range(101) for y in range(101)]
for cand in cands:
    h = 0
    flag = 0
    for i in I:
        if i[2] == 0:
            continue
        ch = i[2] + abs(i[0] - cand[0]) + abs(i[1] - cand[1])
        if h == 0:
            flag = 1
            h = ch
        if h != 0:
            if h != ch:
                flag = 0
                break
    if flag == 1:
        print(cand[0], cand[1], h)
        break

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
data = []
for _ in range(N):
    data.append(list(map(int,input().split())))

CX = -1
CY = -1
H = -1
for cx in range(101):
    for cy in range(101):
        estimated_h = -1
        for d in data:
            x,y,h = d
            if h <= 0:
                print("continue",h)
                continue

            if estimated_h < 0 :
                estimated_h = abs(x-cx) + abs(y-cy) + h
            if estimated_h != abs(x-cx) + abs(y-cy) + h:
                break
        else:
            CX = cx
            CY = cy
            H = estimated_h
            for d in data:
                x, y, h = d
                if max(H - abs(x-cx) - abs(y-cy), 0) != h:
                    H = -1
                    CX = -1
                    CY = -1
                    break
            else:
                print(cx,cy,estimated_h)
                sys.exit(0)

Submission status: Wrong Answer

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

n = int(input())
l = [None] * n

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

fx = l[0][0]
fy = l[0][1]
fh = l[0][2]
ansl = [None] * 101
for i in range(101):
    ansl[i] = [None] * 101
    for j in range(101):
        ansl[i][j] = abs(i - fx) + abs(j - fy) + fh

for i in range(101):
    for j in range(101):
        for t in range(n - 1):
            xx = l[t + 1][0]
            yy = l[t + 1][1]
            hh = l[t + 1][2]
            
            maxh = max(ansl[i][j] - abs(i - xx) - abs(j - yy), 0)
            
            if hh != maxh:
                ansl[i][j] = 1000000001
                
f = False
for i in range(101):
    for j in range(101):
        t = ansl[i][j]
        if t != 1000000001 and t >= 1:
            print(i, j, t)
            f = True
            break
    if f:
        break

Submission status: Wrong Answer

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

n = int(input())
l = [None] * n

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

fx = l[0][0]
fy = l[0][1]
fh = l[0][2]
ansl = [None] * 101
for i in range(101):
    ansl[i] = [None] * 101
    for j in range(101):
        ansl[i][j] = abs(i - fx) + abs(j - fy) + fh

for i in range(101):
    for j in range(101):
        for t in range(n - 1):
            xx = l[t + 1][0]
            yy = l[t + 1][1]
            hh = l[t + 1][2]
            
            maxh = max(ansl[i][j] - abs(i - xx) - abs(j - yy), 0)
            
            if hh != maxh:
                ansl[i][j] = 1000000001
                
f = False
for i in range(101):
    for j in range(101):
        t = ansl[i][j]
        if t != 1000000001:
            print(i, j, t)
            f = True
            break
    if f:
        break

Submission status: Wrong Answer

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

n = int(input())
l = [None] * n

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

fx = l[0][0]
fy = l[0][1]
fh = l[0][2]
ansl = [None] * 101
for i in range(101):
    ansl[i] = [None] * 101
    for j in range(101):
        ansl[i][j] = abs(i - fx) + abs(j - fy) + fh

for i in range(101):
    for j in range(101):
        for t in range(n - 1):
            xx = l[t + 1][0]
            yy = l[t + 1][1]
            hh = l[t + 1][2]
            
            maxh = max(ansl[i][j] - abs(i - xx) - abs(j - yy), 0)
            
            if hh != maxh or maxh < 1:
                ansl[i][j] = 1000000001
                
f = False
for i in range(101):
    for j in range(101):
        t = ansl[i][j]
        if t != 1000000001:
            print(i, j, t)
            f = True
            break
    if f:
        break

Submission status: Wrong Answer

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

n = int(input())
l = [None] * n

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

fx = l[0][0]
fy = l[0][1]
fh = l[0][2]
ansl = [None] * 101
for i in range(101):
    ansl[i] = [None] * 101
    for j in range(101):
        ansl[i][j] = abs(i - fx) + abs(j - fy) + fh

for i in range(101):
    for j in range(101):
        for t in range(n - 1):
            xx = l[t + 1][0]
            yy = l[t + 1][1]
            hh = l[t + 1][2]
            
            maxh = max(ansl[i][j] - abs(i - xx) - abs(j - yy), 0)
            
            if hh != maxh or maxh <= 1:
                ansl[i][j] = 1000000001
                
f = False
for i in range(101):
    for j in range(101):
        t = ansl[i][j]
        if t != 1000000001:
            print(i, j, t)
            f = True
            break
    if f:
        break

Submission status: Wrong Answer

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

n = int(input())
l = [None] * n
minh = 0

for i in range(n):
    l[i] = list(map(int, input().split()))
    minh = max(l[i][2], minh)

fx = l[0][0]
fy = l[0][1]
fh = l[0][2]
ansl = [None] * 101
for i in range(101):
    ansl[i] = [None] * 101
    for j in range(101):
        ansl[i][j] = abs(i - fx) + abs(j - fy) + fh

for i in range(101):
    for j in range(101):
        for t in range(n - 1):
            xx = l[t + 1][0]
            yy = l[t + 1][1]
            hh = l[t + 1][2]
            
            if hh != max(ansl[i][j] - abs(i - xx) - abs(j - yy), 0):
                ansl[i][j] = 1000000001
                
f = False
for i in range(101):
    for j in range(101):
        t = ansl[i][j]
        if t != 1000000001:
            print(i, j, t)
            f = True
            break
    if f:
        break

Submission status: Wrong Answer

Solution code:
from itertools import product

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

for cx, cy in product(range(101), range(101)):

    def height(x, y, h):
        return h + abs(x -cx) + abs(y - cy)

    s = set()

    for x, y, h in xyh:
        if h > 0:
            s.add(height(x, y, h))

    if len(s) == 1:
        print(cx, cy, list(s)[0])
        exit()

Submission status: Wrong Answer

Solution code:
from itertools import product

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

for cx, cy in product(range(101), range(101)):

    def height(x, y, h):
        if h > 0:
            return h + abs(x -cx) + abs(y - cy) 

    s = set()

    for x, y, h in xyh:
        s.add(height(x, y, h))

    if len(s) == 1:
        print(cx, cy, list(s)[0])
        exit()

Submission status: Wrong Answer

Solution code:
from itertools import product

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

for cx, cy in product(range(101), range(101)):

    def height(x, y, h):
        return max(h + abs(x -cx) + abs(y - cy), 0)

    s = set()

    for x, y, h in xyh:
        s.add(height(x, y, h))
        
    if len(s) == 1:
        print(cx, cy, list(s)[0])
        exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

class Position():
    def __init__(self, x, y, h):
        self.x = x
        self.y = y
        self.h = h

    def hamming_distance(self, x, y):
        return abs(self.x - x) + abs(self.y - y)

    def original_height(self, x, y):
        height = self.h + self.hamming_distance(x, y)
        if self.h == 0:
            return False, height
        else:
            return True, height

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

unsafe_positions = []
for x in range(101):
    for y in range(101):
        H = 0
        for position in position_list:
            is_safe, h = position.original_height(x, y)
            if is_safe:
                H = h
                break
            else:
                unsafe_positions.append(Position(x, y, h))
        if H < 1:
            continue
        is_correct = True
        for position in position_list:
            hamming = position.hamming_distance(x, y)
            if hamming > H:
                if position.h == 0:
                    continue
                else:
                    is_correct = False
                    break
            if H != position.original_height(x, y):
                is_correct = False
                break
        if is_correct:
            print("{0} {1} {2}".format(x, y, H))
            sys.exit()
for unsafe_position in unsafe_positions:
    is_correct = True
    for position in position_list:
        is_safe, h = position.original_height(unsafe_position.x, unsafe_position.y)
        if is_safe and unsafe_position.h != h:
            is_correct = False
            break
    if is_correct:
        print("{0} {1} {2}".format(unsafe_position.x, unsafe_position.y, unsafe_position.h))
        break

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

class Position():
    def __init__(self, x, y, h):
        self.x = x
        self.y = y
        self.h = h

    def hamming_distance(self, x, y):
        return abs(self.x - x) + abs(self.y - y)

    def original_height(self, x, y):
        height = self.h + self.hamming_distance(x, y)
        if self.h == 0:
            return False, height
        else:
            return True, height

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

unsafe_positions = []
for x in range(101):
    for y in range(101):
        H = 0
        for position in position_list:
            is_safe, h = position.original_height(x, y)
            if not is_safe:
                H = h
                unsafe_positions.append(Position(x, y, h))
                break
        if H < 1:
            continue
        is_correct = True
        for position in position_list:
            hamming = position.hamming_distance(x, y)
            if hamming > H:
                if position.h == 0:
                    continue
                else:
                    is_correct = False
                    break
            if H != position.original_height(x, y):
                is_correct = False
                break
        if is_correct:
            print("{0} {1} {2}".format(x, y, H))
            sys.exit()
for unsafe_position in unsafe_positions:
    is_correct = True
    for position in position_list:
        is_safe, h = position.original_height(unsafe_position.x, unsafe_position.y)
        if is_safe and unsafe_position.h != h:
            is_correct = False
            break
    if is_correct:
        print("{0} {1} {2}".format(unsafe_position.x, unsafe_position.y, unsafe_position.h))
        break

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

class Position():
    def __init__(self, x, y, h):
        self.x = x
        self.y = y
        self.h = h

    def hamming_distance(self, x, y):
        return abs(self.x - x) + abs(self.y - y)

    def original_height(self, x, y):
        height = self.h + self.hamming_distance(x, y)
        if self.h == 0:
            return False, height
        else:
            return True, height

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

unsafe_positions = []
for x in range(101):
    for y in range(101):
        H = 0
        for position in position_list:
            is_safe, h = position.original_height(x, y)
            if not is_safe:
                H = h
                unsafe_positions.append(Position(x, y, h))
                break
        if H < 1:
            continue
        is_correct = True
        for position in position_list:
            hamming = position.hamming_distance(x, y)
            if hamming > H:
                if position.h == 0:
                    continue
                else:
                    is_correct = False
                    break
            if H != position.original_height(x, y):
                is_correct = False
                break
        if is_correct:
            print("{0} {1} {2}".format(x, y, H))
            sys.exit()
for unsafe_position in unsafe_positions:
    is_correct = True
    for position in position_list:
        is_safe, h = position.original_height(unsafe_position.x, unsafe_position.y)
        if is_safe and unsafe_position.h != h:
            is_correct = False
            break

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

class Position():
    def __init__(self, x, y, h):
        self.x = x
        self.y = y
        self.h = h

    def hamming_distance(self, x, y):
        return abs(self.x - x) + abs(self.y - y)

    def original_height(self, x, y):
        if self.h == 0:
            return None
        else:
            return self.h + self.hamming_distance(x, y)

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

for x in range(101):
    for y in range(101):
        H = 0
        for position in position_list:
            h = position.original_height(x, y)
            if h is not None:
                H = h
                break
        if H < 1:
            continue
        is_correct = True
        for position in position_list:
            hamming = position.hamming_distance(x, y)
            if hamming > H:
                if position.h == 0:
                    continue
                else:
                    is_correct = False
                    break
            if H != position.original_height(x, y):
                is_correct = False
                break
        if is_correct:
            print("{0} {1} {2}".format(x, y, H))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

class Position():
    def __init__(self, x, y, h):
        self.x = x
        self.y = y
        self.h = h

    def hamming_distance(self, x, y):
        return abs(self.x - x) + abs(self.y - y)

    def original_height(self, x, y):
        if self.h == 0:
            return None
        else:
            return self.h + self.hamming_distance(x, y)

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

for x in range(101):
    for y in range(101):
        H = 0
        for position in position_list:
            h = position.original_height(x, y)
            if h is not None:
                H = h
                break
        if H < 1:
            continue
        is_correct = True
        for position in position_list:
            hamming = position.hamming_distance(x, y)
            if hamming > H:
                if position.h != 0:
                    is_correct = False
                    break
            if H != position.original_height(x, y):
                is_correct = False
                break
        if is_correct:
            print("{0} {1} {2}".format(x, y, H))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

class Position():
    def __init__(self, x, y, h):
        self.x = x
        self.y = y
        self.h = h

    def hamming_distance(self, x, y):
        return abs(self.x - x) + abs(self.y - y)

    def original_height(self, x, y):
        if self.h == 0:
            return None
        else:
            return self.h + self.hamming_distance(x, y)

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

for x in range(101):
    for y in range(101):
        H = 0
        for position in position_list:
            h = position.original_height(x, y)
            if h is not None:
                H = h
                break
        if H < 1:
            continue
        is_correct = True
        for position in position_list:
            hamming = position.hamming_distance(x, y)
            if hamming > H:
                if position.x != 0 or position.y != 0:
                    is_correct = False
                    break
            if H != position.original_height(x, y):
                is_correct = False
                break
        if is_correct:
            print("{0} {1} {2}".format(x, y, H))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

class Position():
    def __init__(self, x, y, h):
        self.x = x
        self.y = y
        self.h = h

    def hamming_distance(self, x, y):
        return abs(self.x - x) + abs(self.y - y)

    def original_height(self, x, y):
        return self.h + self.hamming_distance(x, y)

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

for x in range(101):
    for y in range(101):
        H = position_list[0].original_height(x, y)
        if H < 1:
            continue
        is_correct = True
        for i in range(1, len(position_list)):
            if H != position_list[i].original_height(x, y):
                is_correct = False
                break
        if is_correct:
            print("{0} {1} {2}".format(x, y, H))
            sys.exit()

Submission status: Wrong Answer

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

def calc(cx, cy):
    excepth = -1
    for x, y, h in ps:
        if h > 0:
            tmph = h + abs(x - cx) + abs(y - cy)
            if excepth == -1:
                excepth = tmph
            elif excepth != tmph:
                return -1
        elif h == 0:
            tmpd = abs(x - cx) + abs(y - cy)
            if excepth - tmpd > 0:
                return -1
    return excepth

for cy in range(101):
    for cx in range(101):
        resh = calc(cx, cy)
        if resh != -1:
            print(cx, cy, resh)
            break