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 sys
N = int(input())

XYH = []
for _ in range(N):
    x, y, h = list(map(int, input().split()))
    if h != 0:
        XYH.append((x, y, h))

x, y, h = XYH[0]

for cx in range(101):
    for cy in range(101):
        H = abs(cx - x) + abs(cy - y) + h
        for xyh in XYH:
            _x, _y, _h = xyh
            if H - _h == abs(cx-_x) + abs(cy-_y):
                continue
            break
        else:
            print(cx, cy, H)
            sys.exit(0)

Submission status: Wrong Answer

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

XYH = []
for _ in range(N):
    x, y, h = list(map(int, input().split()))
    if h != 0:
        XYH.append((x, y, h))
    elif x == 0 or y == 0 or x == 100 or y == 100:
        XYH.append((x, y, h))


x, y, h = XYH[0]

for cx in range(101):
    for cy in range(101):
        H = abs(cx - x) + abs(cy - y) + h
        for xyh in XYH[1:]:
            _x, _y, _h = xyh
            if H - _h == abs(cx-_x) + abs(cy-_y):
                continue
            break
        else:
            print(cx, cy, H)
            sys.exit(0)

Submission status: Wrong Answer

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

XYH = []
for _ in range(N):
    x, y, h = list(map(int, input().split()))
    if h != 0:
        XYH.append((x, y, h))


x, y, h = XYH[0]

for cx in range(101):
    for cy in range(101):
        H = abs(cx - x) + abs(cy - y) + h
        for xyh in XYH[1:]:
            _x, _y, _h = xyh
            if H - _h == abs(cx-_x) + abs(cy-_y):
                continue
            break
        else:
            print(cx, cy, H)
            sys.exit(0)

Submission status: Wrong Answer

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


x, y, h = XYH[0]

for cx in range(101):
    for cy in range(101):
        H = abs(cx - x) + abs(cy - y) + h
        for xyh in XYH[1:]:
            _x, _y, _h = xyh
            if H - _h == abs(cx-_x) + abs(cy-_y):
                continue
            break
        else:
            print(cx, cy, H)
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
def search_center(xyh_list):
    xyh_list.sort(key=lambda r: r[2], reverse=True)
    highest = xyh_list[0]
    for cx in range(101):
        for cy in range(101):
            ph = highest[2] + abs(highest[0] - cx) + abs(highest[1] - cy)
            matched = True
            for xyh in xyh_list[1:]:
                if xyh[2] == 0:
                    continue
                phh = xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy)
                if ph != phh:
                    matched = False
                    break
            if matched:
                return cx, cy, ph
    return None


def main():
    N = int(input())
    xyh_list = [list(map(int, input().split(' '))) for _ in range(N)]
    xyh_list.sort(key=lambda r: r[2], reverse=True)
    cx, cy, ph = search_center(xyh_list)
    print('{} {} {}'.format(cx, cy, ph))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def search_center(xyh_list):
    highest = xyh_list[0]
    for cx in range(101):
        for cy in range(101):
            hd = abs(highest[0] - cx) + abs(highest[1] - cy)
            matched = True
            for xyh in xyh_list[1:]:
                if xyh[2] == 0:
                    continue
                d = abs(xyh[0] - cx) + abs(xyh[1] - cy)
                if hd + highest[2] != d + xyh[2]:
                    matched = False
                    break
            if matched:
                return cx, cy
    return None


def main():
    N = int(input())
    xyh_list = [list(map(int, input().split(' '))) for _ in range(N)]
    xyh_list.sort(key=lambda r: r[2], reverse=True)
    cx, cy = search_center(xyh_list)
    highest = xyh_list[0]
    ch = abs(highest[0] - cx) + abs(highest[1] - cy) + highest[2]
    print('{} {} {}'.format(cx, cy, ch))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                d.append(H)
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))
        else:
            d = list(set(d))
            if len(d) == 1 and 1 <= d[-1] and d[-1] <= h_max:
                print(c_x, c_y, d[-1])
                exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                d.append(H)
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))
        else:
            d = list(set(d))
            if len(d) == 1 and 1 <= d[-1] and d[-1] < h_max:
                print(c_x, c_y, d[-1])
                exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                d.append(H)
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))
        else:
            d = list(set(d))
            if len(d) == 1 and 1 <= d[-1] and d[-1] < h_max:
                print(h_max)
                print(c_x, c_y, d[-1])
                exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        c = []
        h_max = float("inf")
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                if H < h_max and 1 <= H:
                    if len(d) == 0:
                        d.append(H)
                        c.append(c_x)
                        c.append(c_y)
                    else:
                        if d[-1] != H:
                            break
                else:
                    break
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))

        else:
            if len(d) == 1 and d[-1] < h_max:
                print(c_x, c_y, d[-1])
                exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                if H < h_max and 1 <= H:
                    if len(d) == 0:
                        d.append(H)
                    else:
                        if d[-1] != H:
                            break
                else:
                    break
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))

        else:
            if len(d) == 1 and d[-1] < h_max:
                print(c_x, c_y, d[-1])
                exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        h_max = float("inf")
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                if H < h_max:
                    if len(d) == 0:
                        d.append(H)
                    else:
                        if d[-1] != H:
                            break
                else:
                    break
            else:
                h_max = min(h_max, f(x, y, c_x, c_y))

        else:
            if len(d) == 1 and d[-1] < h_max:
                print(c_x, c_y, d[-1])
                exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                if len(d) == 0:
                    d.append(H)
                else:
                    if d[-1] != H:
                        break
        else:
            if len(d) == 1:
                print(c_x, c_y, d[-1])
                exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                if len(d) == 0:
                    d.append(H)
                else:
                    if d[-1] != H:
                        break
        else:
            print(c_x, c_y, d[-1])
            exit()

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                if len(d) == 0:
                    d.append(H)
                else:
                    if d[-1] != H:
                        break
        else:
            print(c_x, c_y, d[-1])

Submission status: Wrong Answer

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

f = lambda i, j, k, l: abs(i - k) + abs(j - l)

for c_x in range(0, 101):
    for c_y in range(0, 101):
        d = []
        for i in info:
            x, y, h = i[0], i[1], i[2]
            if h >= 0:
                H = f(x, y, c_x, c_y) + h
                if len(d) == 0:
                    d.append(H)
                else:
                    if d[-1] != H:
                        break
        else:
            print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 1
        right = float('inf')
        for i in range(N):
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            if tmp < 1 or not (left <= tmp <= right):
                    flag = 1
                    break
            if xyh[i][2] > 0:
                left = right = tmp
            else:
                right = tmp
        if not flag:
            print(c_x, c_y, tmp)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 1
        right = 10**9
        for i in range(N):
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            if tmp < 1 or not (left <= tmp <= right):
                    flag = 1
                    break
            if xyh[i][2] > 0:
                left = right = tmp
            else:
                right = tmp
        if not flag:
            print(c_x, c_y, tmp)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 1
        right = 10**9
        for i in range(N):
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            if xyh[i][2] > 0:
                if not (left <= tmp <= right):
                    flag = 1
                    break
                left = right = tmp
            else:
                if tmp < 1 or not (left <= tmp <= right):
                    flag = 1
                    break
                #left = max(1, left)
                right = tmp
        if not flag and tmp > 0:
            print(c_x, c_y, tmp)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 1
        right = 10**9
        for i in range(N):
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            if xyh[i][2] > 0:
                if not (left <= tmp <= right):
                    flag = 1
                    break
                left = right = tmp
            else:
                if tmp < 1 or tmp > right:
                    flag = 1
                    break
                left = max(1, left)
                right = tmp
        if not flag and tmp > 0:
            print(c_x, c_y, tmp)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 1
        right = 10**9
        for i in range(N):
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            if xyh[i][2] > 0:
                if not (left <= tmp <= right):
                    flag = 1
                    break
                left = right = tmp
            else:
                if tmp < 1 or tmp > right:
                    flag = 1
                    break
                left = 1
                right = tmp
        if not flag and tmp > 0:
            print(c_x, c_y, tmp)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 0
        right = 10**9
        for i in range(N):
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            if xyh[i][2] > 0:
                if not (left <= tmp <= right):
                    flag = 1
                    break
                left = right = tmp
            else:
                if left > 0 or tmp > right:
                    flag = 1
                    break
                left = 0
                right = tmp
        if not flag:
            print(c_x, c_y, tmp)
            exit()

Submission status: Wrong Answer

Solution code:
from sys import exit

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

n=int(input())			#高々100なのでほとんどが高さ0っていう状況はない
xyh=[0]*n

for i in range(n):
	x,y,h=map(int,input().split())
	xyh[i]=[x,y,h]
xyh.sort(key=lambda x:x[2],reverse=True)			#h=0を選択してしまうことを避ける

for cx in range(101):
	for cy in range(101):
		H=ht(cx,cy,xyh[0][0],xyh[0][1],xyh[0][2])
		for i in range(1,n):
			if max(H-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:			#H=ht(このfor文で選択した座標)にすると、高さ0の場合に合わなくなる
				break
			
		else:			#直前のifが行われなければ、という意味。forの外における
			print(cy,cy,H)
			exit()

Submission status: Wrong Answer

Solution code:
def height(a, b, x, y, h):
	return h + abs(a - x) + abs(b - y)

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)

for i in range(101):
	for j in range(101):
		H = height(i, j, x[0], y[0], h[0])
		for k in range(1, n):
			if max(H - abs(x[k] - i) - abs(y[k] - j), 0) != h[k]:
				break
		else:
			print(i, j, H)
			exit()

Submission status: Wrong Answer

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

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


from itertools import permutations
from itertools import combinations_with_replacement

lst = list(range(0, 101))
lst = list(combinations_with_replacement(lst, 2))

for cx, cy in lst:
	Hmax = height(x[0], y[0], cx, cy, h[0]) # tmp 
	flg = True
	for i in range(1, n):
		xnow, ynow, hnow = x[i], y[i], h[i]
		Htmp = height(xnow, ynow, cx, cy, hnow)
		Hmax = max(Hmax, hnow)
		if Hmax != Htmp: # 矛盾
			flg = False
			break
	if flg:
		print(cx, cy, Hmax)
		exit()

for cx, cy in lst:
	Hmax = height(x[0], y[0], cy, cx, h[0]) # tmp
	flg = True
	for i in range(1, n):
		xnow, ynow, hnow = x[i], y[i], h[i]
		Htmp = height(xnow, ynow, cy, cx, hnow)
		Hmax = max(Hmax, hnow)
		if Hmax != Htmp: # 矛盾
			flg = False
			break
	if flg:
		print(cy, cx, Hmax)
		exit()

Submission status: Wrong Answer

Solution code:
from sys import exit

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hres=-1
nn=n

for i in range(nn):
	xx,yy,hh=map(int,input().split())
	if hh==0:
		n-=1
	else:
		x[i]=xx
		y[i]=yy
		h[i]=hh
		if hres<hh:
			hres=hh
			xres=xx
			yres=yy

if n==1:
	print(xres,yres,hres)
	exit()
else:
	for cx in range(101):
		for cy in range(101):
			cnt=0
			h2=h[0]+abs(x[0]-cx)+abs(y[0]-cy)
			for i in range(1,n):
				h1=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
				if h2!=h1:
					cnt=1
					break
			if cnt==0 and h1>=hres and h1<=10**9:
				hres=h1
				xres=cx
				yres=cy
				
print(xres,yres,hres)

Submission status: Wrong Answer

Solution code:
from sys import exit

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hres=-1
nn=n

for i in range(nn):
	xx,yy,hh=map(int,input().split())
	if hh==0:
		n-=1
		continue
	x[i]=xx
	y[i]=yy
	h[i]=hh
	if hres<hh:
		hres=hh
		xres=xx
		yres=yy

if n==1:
	print(xx,yy,hh)
	exit()
else:
	for cx in range(101):
		for cy in range(101):
			cnt=0
			h2=h[0]+abs(x[0]-cx)+abs(y[0]-cy)
			for i in range(1,n):
				h1=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
				if h2!=h1:
					cnt=1
					break
			if cnt==0 and h1>=hres:
				hres=h1
				xres=cx
				yres=cy
				
print(xres,yres,hres)

Submission status: Wrong Answer

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

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


from itertools import permutations
from itertools import combinations_with_replacement

lst = list(range(0, 101))
lst = list(combinations_with_replacement(lst, 2))

for cx, cy in lst:
	H = height(x[0], y[0], cx, cy, h[0]) # tmp
	Hmax = h[0]
	flg = True
	for i in range(1, n):
		xnow, ynow, hnow = x[i], y[i], h[i]
		Htmp = height(xnow, ynow, cx, cy, hnow)
		Hmax = max(Hmax, hnow)
		if H != Htmp or Htmp < Hmax: # 矛盾
			flg = False
			break
	if flg:
		print(cx, cy, H)
		exit()

for cx, cy in lst:
	H = height(x[0], y[0], cy, cx, h[0]) # tmp
	Hmax = h[0]
	flg = True
	for i in range(1, n):
		xnow, ynow, hnow = x[i], y[i], h[i]
		Htmp = height(xnow, ynow, cy, cx, hnow)
		Hmax = max(Hmax, hnow)
		if H != Htmp or Htmp < Hmax: # 矛盾
			flg = False
			break
	if flg:
		print(cy, cx, H)
		exit()

Submission status: Wrong Answer

Solution code:
from sys import exit

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hres=-1

for i in range(n):
	xx,yy,hh=map(int,input().split())
	x[i]=xx
	y[i]=yy
	h[i]=hh
	if hres<hh:
		hres=hh
		xres=xx
		yres=yy

if n==1:
	print(xx,yy,hh)
	exit()
else:
	for cx in range(101):
		for cy in range(101):
			cnt=0
			h2=h[0]+abs(x[0]-cx)+abs(y[0]-cy)
			for i in range(1,n):
				h1=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
				if h2!=h1:
					cnt=1
					break
			if cnt==0 and h1>=hres and h1<=10**9:
				hres=h1
				xres=cx
				yres=cy
				
print(xres,yres,hres)

Submission status: Wrong Answer

Solution code:
from sys import exit

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hres=-1

for i in range(n):
	xx,yy,hh=map(int,input().split())
	x[i]=xx
	y[i]=yy
	h[i]=hh
	if hres<hh:
		hres=hh
		xres=xx
		yres=yy

if n==1:
	print(xx,yy,hh)
	exit()
else:
	for cx in range(101):
		for cy in range(101):
			cnt=0
			h2=h[0]+abs(x[0]-cx)+abs(y[0]-cy)
			for i in range(1,n):
				h1=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
				if h2!=h1:
					cnt=1
					break
			if cnt==0 and h1>=hres and h1<10**9:
				hres=h1
				xres=cx
				yres=cy
				
print(xres,yres,hres)

Submission status: Wrong Answer

Solution code:
from sys import exit

n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hres=-1

for i in range(n):
	xx,yy,hh=map(int,input().split())
	x[i]=xx
	y[i]=yy
	h[i]=hh
	if hres<hh:
		hres=hh
		xres=xx
		yres=yy

if n==1:
	print(xx,yy,hh)
	exit()
else:
	for cx in range(101):
		for cy in range(101):
			cnt=0
			h2=h[0]+abs(x[0]-cx)+abs(y[0]-cy)
			for i in range(1,n):
				h1=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
				if h2!=h1:
					cnt=1
					break
			if cnt==0 and h1>hres:
				hres=h1
				xres=cx
				yres=cy
				
print(xres,yres,hres)

Submission status: Wrong Answer

Solution code:
from sys import exit

n=int(input())
xyh=[0]*n

for i in range(n):
	x,y,h=map(int,input().split())
	xyh[i]=[x,y,h]
	
for cx in range(101):
	for cy in range(101):
		cnt=0
		h2=-1
		for x,y,h in xyh:
			h1=h+abs(x-cx)+abs(y-cy)
			if h2==-1:
				h2=h1
			elif h2!=h1:
				cnt=1
				break
		if cnt==0:
			print(cx,cy,h1)
			exit()

Submission status: Wrong Answer

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

def H(X,Y,x,y,h):
    return max(0, abs(X-x) + abs(Y-y) + h)

ans = []
for i in range(101):
    for j in range(101):
        for p in range(n):
            tmp = H(i,j,l[p][0],l[p][1],l[p][2])
            if l[p][2] > 0:
                ans.append(tmp)
        if len(set(ans)) != 1:
            ans = []
            continue
        else:
            print(i,j,ans[0])

Submission status: Wrong Answer

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

def H(X,Y,x,y,h):
    return max(0, abs(X-x) + abs(Y-y) + h)

ans = []
for i in range(101):
    for j in range(101):
        for p in range(n):
            tmp = H(i,j,l[p][0],l[p][1],l[p][2])
            if tmp > 0:
                ans.append(tmp)
        if len(set(ans)) != 1:
            ans = []
            continue
        else:
            print(i,j,ans[0])

Submission status: Wrong Answer

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

def H(X,Y,x,y,h):
    return max(0, abs(X-x) + abs(Y-y) + h)

tmp = []
for i in range(101):
    for j in range(101):
        for p in range(n):
            tmp.append(H(i,j,l[p][0],l[p][1],l[p][2]))
        if len(set(tmp)) != 1:
            tmp = []
            continue
        else:
            print(i,j,tmp[0])

Submission status: Wrong Answer

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

def H(X,Y,x,y,h):
    return abs(X-x) + abs(Y-y) + h

tmp = []
for i in range(101):
    for j in range(101):
        for p in range(n):
            tmp.append(H(i,j,l[p][0],l[p][1],l[p][2]))
        if len(set(tmp)) != 1:
            tmp = []
            continue
        else:
            print(i,j,tmp[0])

Submission status: Wrong Answer

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

for i in range(0,101):
  for j in range(0,101):
    temp=0
    onezero=1
    for k in range(0,n):
      xhoukou=abs(i-lis[k][0])
      yhoukou=abs(j-lis[k][1])
      hhoukou=lis[k][2]
      if hhoukou>0:
        keep=xhoukou+yhoukou+hhoukou
        if temp==0:
          temp=keep
        else:
          if keep!=temp:
            onezero=0
      else:
        if xhoukou+yhoukou<temp:
          onezero=0
    if onezero==1:
      print(i,j,temp)

Submission status: Wrong Answer

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

for i in range(0,101):
  for j in range(0,101):
    temp=0
    onezero=1
    for k in range(0,n):
      xhoukou=abs(i-lis[k][0])
      yhoukou=abs(j-lis[k][1])
      hhoukou=lis[k][2]
      if hhoukou>0:
        keep=xhoukou+yhoukou+hhoukou
        if temp==0:
          temp=keep
        else:
          if keep!=temp:
            onezero=0
      else:
        if xhoukou+yhoukou<temp:
          onezero=0
    if onezero==1:
      print(i,j,temp)
      break
  if onezero==1:
    break

Submission status: Wrong Answer

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

for i in range(0,101):
  for j in range(0,101):
    temp=0
    onezero=1
    for k in range(0,n):
      xhoukou=abs(i-lis[k][0])
      yhoukou=abs(j-lis[k][1])
      hhoukou=lis[k][2]
      if hhoukou!=0:
        keep=xhoukou+yhoukou+hhoukou
        if temp==0:
          temp=keep
        else:
          if keep!=temp:
            onezero=0
            break
      else:
        if xhoukou+yhoukou<temp:
          onezero=0
          break
    if onezero==1:
      print(i,j,temp)
      break
  if onezero==1:
    break

Submission status: Wrong Answer

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

for i in range(0,101):
  for j in range(0,101):
    temp=0
    onezero=1
    for k in range(0,n):
      xhoukou=abs(i-lis[k][0])
      yhoukou=abs(j-lis[k][1])
      hhoukou=lis[k][2]
      if hhoukou!=0:
        keep=xhoukou+yhoukou+hhoukou
        if temp!=0:
          if not temp==keep:
            onezero=0
            break
        else:
          temp=keep
      else:
        if not xhoukou+yhoukou>=temp:
          onezero=0
          break
    if onezero==1:
      print(i,j,temp)
      break

Submission status: Wrong Answer

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

for i in range(0,101):
  for j in range(0,101):
    temp=0
    onezero=1
    for k in range(0,n):
      xhoukou=abs(i-lis[k][0])
      yhoukou=abs(j-lis[k][1])
      hhoukou=lis[k][2]
      if hhoukou!=0:
        keep=xhoukou+yhoukou+hhoukou
        if temp!=0:
          if not temp==keep:
            onezero=0
            break
        else:
          temp=keep
    if onezero==1:
      print(i,j,max(1,temp))
      break