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, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()
xyh = [LIST() for _ in range(N)]

h_dict = defaultdict(int)
xyh.sort(key = lambda x:[x[0], x[1]])

for Cx in range(101):
	for Cy in range(101):
		H = 0
		for x, y, h in xyh:
			if H == 0:
				H = h + abs(x-Cx) + abs(y-Cy)
			else:
				if H != h + abs(x-Cx) + abs(y-Cy):
					break
		else:
			print(Cx, Cy, H)
			break
	else:
		continue
	break

Submission status: Wrong Answer

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
XYH = [tuple(map(int,input().split())) for _ in range(N)]

# 高さの降順にソートしておく
#  -> これをしないと 高さ 0 を基準に中心の高さを決めてしまう可能性があるので
XYH.sort(key=lambda x:x[2], reverse=True)

print(XYH)

# 中心座標で全探索
for xi in range(101):
    for yi in range(101):
        flg = True
        x,y,h = XYH[0]
        # 中心の高さ
        hh0 = abs(xi-x) + abs(yi-y) + h
        for i in range(1,N):
            x,y,h = XYH[i]
            if h == 0:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 > hhi:
                    flg = False
                    break

            else:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 != hhi:
                    flg = False
                    break
        if flg:
            print(xi,yi,hh0)
            sys.exit()

Submission status: Wrong Answer

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
XYH = [tuple(map(int,input().split())) for _ in range(N)]

# 中心座標で全探索
for xi in range(101):
    for yi in range(101):
        flg = True
        x,y,h = XYH[0]
        # 中心の高さ
        hh0 = abs(xi-x) + abs(yi-y) + h
        for i in range(1,N):
            x,y,h = XYH[i]
            hhi = abs(xi-x) + abs(yi-y) + h
            if hh0 != hhi:
                flg = False
                break
        if flg:
            print(xi,yi,hh0)
            sys.exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        H = set()
        for x, y, h in XYH:
            if h == 0:
                continue
            H.add(h + abs(x - cx) + abs(y - cy))
        if len(H) != 1:
            continue
        H = list(H)[0]
        for x, y, h in XYH:
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                print(cx, cy, H)
                break

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh = sorted(xyh, key=lambda x:x[2])
ans = []
for i in range(101):
    for j in range(101):
        pre = xyh[-1][2] + abs(i-xyh[-1][0]) + abs(j-xyh[-1][1])
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            if h == 0:
                continue
            a = abs(x-i) + abs(y-j)
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 1:
            print(i, j, pre)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(101):
    for j in range(101):
        pre = xyh[-1][2] + abs(i-xyh[-1][0]) + abs(j-xyh[-1][1])
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            if h == 0:
                continue
            a = abs(x-i) + abs(y-j)
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 1:
            print(i, j, pre)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(101):
    for j in range(101):
        pre = xyh[-1][2] + abs(i-xyh[-1][0]) + abs(j-xyh[-1][1])
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 1:
            ans += [[i, j, pre]]

for Cx, Cy, H in ans:
    valid = True
    for x, y, h in xyh:
        if max(H-abs(x-Cx)-abs(y-Cy), 0) != h:
            valid = False

    if valid:
        print(Cx, Cy, H)
        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(101):
    for j in range(101):
        pre = xyh[-1][2] + abs(i-xyh[-1][0]) + abs(j-xyh[-1][0])
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if k == 0:
                pre = h + a
                continue
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 1:
            ans += [[i, j, pre]]
        
for Cx, Cy, H in ans:
    valid = True
    for x, y, h in xyh:
        if max(H-abs(x-Cx)-abs(y-Cy), 0) != h:
            valid = False

    if valid:
        print(Cx, Cy, H)
        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(101):
    for j in range(101):
        pre = -1
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if k == 0:
                pre = h + a
                continue
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 1:
            ans += [[i, j, pre]]
        
for Cx, Cy, H in ans:
    valid = True
    for x, y, h in xyh:
        if max(H-abs(x-Cx)-abs(y-Cy), 0) != h:
            valid = False

    if valid:
        print(Cx, Cy, H)
        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(101):
    for j in range(101):
        pre = -1
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if k == 0:
                pre = h + a
                continue
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 1:
            ans += [[i, j, pre]]
        
for Cx, Cy, H in ans:
    for x, y, h in xyh:
        if max(H-abs(x-Cx)-abs(y-Cy), 0) == h:
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(101):
    for j in range(101):
        pre = -1
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if k == 0:
                pre = h + a
                continue
            if max(pre-a, 0) != h:
                valid = False

        if valid and pre >= 0:
            ans += [[i, j, pre]]
        
for Cx, Cy, H in ans:
    for x, y, h in xyh:
        if max(H-abs(x-Cx)-abs(y-Cy), 0) == h:
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        pre = -1
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if k == 0:
                pre = h + a
                continue
            if max(pre-a, 0) != h:
                valid = False

        if valid:
            print(i, j, pre)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        #print(i, j)
        
        pre = -1
        valid = True
        for k in range(N):
            x, y, h = xyh[k]
            a = abs(x-i) + abs(y-j)
            if k == 0:
                pre = h + a
                continue
            if pre != h+a:
                valid = False

        if valid:
            print(i, j, pre)
            exit()

Submission status: Wrong Answer

Solution code:
# input
N = int(input())
coords = []
c_append = coords.append
si = -1
for i in range(N):
    x, y, h = map(int, input().split())
    c_append((x, y, h))
    if h > 0:
        si = i
    

# check
ans_x, ans_y, ans_h = -1, -1, -1
temp_x, temp_y, temp_h = coords[si][0], coords[si][1], coords[si][2]
for x in range(101):
    for y in range(101):
        h = temp_h - abs(x - temp_x) - abs(y - temp_y)
        fl = True

        for check_x, check_y, check_h in coords:
            if check_h > 0 and h - check_h != abs(x - check_x) + abs(y - check_y):
                fl = False
            if check_h == 0 and h > abs(x - check_x) + abs(y - check_y):
                fl = False

        if fl is True:
            ans_x, ans_y, ans_h = x, y, h

print("{0} {1} {2}".format(ans_x, ans_y, ans_h))

Submission status: Wrong Answer

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

# check
ans_x, ans_y, ans_h = -1, -1, -1
temp_x, temp_y, temp_h = coords[-1][0], coords[-1][1], coords[-1][2]
for x in range(101):
    for y in range(101):
        h = temp_h - abs(x - temp_x) - abs(y - temp_y)
        fl = True

        for i in range(N):
            check_x, check_y, check_h = coords[i][0], coords[i][1], coords[i][2]
            if check_h > 0 and h - check_h != abs(x - check_x) + abs(y - check_y):
                fl = False
            if check_h == 0 and h > abs(x - check_x) + abs(y - check_y):
                fl = False

        if fl is True:
            ans_x, ans_y, ans_h = x, y, h

print("{0} {1} {2}".format(ans_x, ans_y, ans_h))

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
a=[[0]*3 for _ in range(101)] 

for i in range(n):
    a[i][0],a[i][1],a[i][2]=map(int,input().split())
sorted(a,key=lambda x: x[2] ,reverse=True)
for i in range(n):
    for cx in range(101):
        for cy in range(101):
            height=a[i][2]+abs(a[i][0]-cx)+abs(a[i][1]-cy)
            if a[i][2]>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                if ans[cx][cy]!=None:
                    if ans[cx][cy]>abs(a[i][0]-cx)+abs(a[i][1]-cy):
                        ans[cx][cy]=-1
                else:
                    ans[a[i][0]][a[i][1]]=-1
        

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]==None: 
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                if ans[cx][cy]!=None:
                    if ans[cx][cy]>abs(x-cx)+abs(y-cy):
                        ans[cx][cy]=-1
                else:
                    ans[x][y]=-1
        

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]==None:
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                if ans[cx][cy]!=None:
                    if ans[cx][cy]>abs(x-cx)+abs(y-cy):
                        ans[cx][cy]=-1
                else:
                    ans[x][y]=-1
        

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]!=None:
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    if h>0:
        for cx in range(101):
            for cy in range(101):
                height=h+abs(x-cx)+abs(y-cy)
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
    else:
        ans[x][y]=-1

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]==None:
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    if h>0:
        for cx in range(101):
            for cy in range(101):
                height=h+abs(x-cx)+abs(y-cy)
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
    else:
        ans[x][y]=-1

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                ans[x][y]=-1

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=max(h+abs(x-cx)+abs(y-cy),0)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
ans=[[0]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if ans[cx][cy]==0 or ans[cx][cy]==height:
                ans[cx][cy]=height
            else:
                ans[cx][cy]=-1

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda f:f[2])
p=xyh[-1]
q=xyh[-2]
for cx in range(0,101):
    for cy in range(0,101):
      if abs(p[0]-cx)+abs(p[1]-cy)==abs(q[0]-cx)+abs(q[1]-cy)-p[2]+q[2]:
        ax=cx
        ay=cy
H=p[2]+abs(p[0]-ax)+abs(p[1]-ay)
print(ax,ay,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
m = 0
for x in xyh:
    m = max(m,x[2])
for i in range(101):
    for j in range(101):
        for h in range(m,m+101):
            if h <= 1000000000:
                for x in xyh:
                    if x[2] != max(h-abs(i-x[0])-abs(j-x[1]),0):
                        break
                else:
                    print(i,j,h)
                    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
m = 0
for x in xyh:
    if x[2] > 0:
        base = x
        break
for i in range(101):
    for j in range(101):
        h = base[2] + abs(i-base[0]) + abs(j-base[1])
        if h <= 1000000000:
            for x in xyh:
                if x[2] != max(h-abs(i-x[0])-abs(j-x[1]),0):
                    break
            else:
                print(i,j,h)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
for x in xyh:
    if x[2] > 0:
        base = x
        break
for i in range(101):
    for j in range(101):
        h = base[2] + abs(i-base[0]) + abs(j-base[1])
        if h <= 1000000000:
            for x in xyh:
                if x[2] != h - abs(i-x[0]) - abs(j-x[1]):
                    break
            else:
                print(i,j,h)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
for x in xyh:
    if x[2] > 0:
        base = x
        break
for i in range(101):
    for j in range(101):
        h = base[2] + abs(i-base[0]) + abs(j-base[1])
        for x in xyh:
            if x[2] != h - abs(i-x[0]) - abs(j-x[1]):
                break
        else:
            print(i,j,h)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [tuple(map(int, input().split())) for _ in range(N)]
setxyh = set(xyh)
ans = set()
for x in xyh:
    if x[2] > 0:
        for j in range(101):
            for k in range(101):
                ans.add((j,k,x[2]+abs(j-x[0])+abs(k-x[1])))
        break
for x in xyh:
    temp = set()
    if x[2] == 0:
        broke = False
        for l in range(101):
            for m in range(101):
                if (l,m,abs(l-x[0])+abs(m-x[1])) in setxyh:
                    for j in range(101):
                        for k in range(101):
                            temp.add((j,k,x[2]+abs(j-x[0])+abs(k-x[1])))
                    broke = True
                    break
            if broke:
                break
    else:
        for j in range(101):
            for k in range(101):
                temp.add((j,k,x[2]+abs(j-x[0])+abs(k-x[1])))
    ans = ans & temp
for x in ans:
    print(*x)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
ans = set()
for x in xyh:
    if x[2] > 0:
        for j in range(101):
            for k in range(101):
                ans.add((j,k,x[2]+abs(j-x[0])+abs(k-x[1])))
        break
for x in xyh:
    temp = set()
    for j in range(101):
        for k in range(101):
            temp.add((j,k,x[2]+abs(j-x[0])+abs(k-x[1])))
    if len(ans&temp) > 0:
        ans = ans & temp
for x in ans:
    print(*x)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = set()
for i in range(1,N+1):
    x,y,h = (int(x) for x in input().split())
    if h > 0:
        for j in range(101):
            for k in range(101):
                ans.add((j,k,h+abs(j-x)+abs(k-y)))
        break
for k in range(N-i):
    x,y,h = (int(x) for x in input().split())
    temp = set()
    for j in range(101):
        for k in range(101):
            temp.add((j,k,h+abs(j-x)+abs(k-y)))
    if len(ans&temp) > 0:
        ans = ans & temp
for x in ans:
    print(*x)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = set()
for i in range(1,N+1):
    x,y,h = (int(x) for x in input().split())
    if h > 0:
        for j in range(101):
            for k in range(101):
                ans.add((j,k,h+abs(j-x)+abs(k-y)))
        break
for k in range(N-i):
    x,y,h = (int(x) for x in input().split())
    temp = set()
    if h > 0:
        for j in range(101):
            for k in range(101):
                temp.add((j,k,h+abs(j-x)+abs(k-y)))
    ans = ans & temp
for x in ans:
    print(*x)

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = (int(x) for x in input().split())
ans = set()
for i in range(101):
    for j in range(101):
        ans.add((i,j,h+abs(i-x)+abs(j-y)))
for k in range(N-1):
    x,y,h = (int(x) for x in input().split())
    temp = set()
    for i in range(101):
        for j in range(101):
            temp.add((i,j,h+abs(i-x)+abs(j-y)))
    ans = ans & temp
for x in ans:
    print(*x)

Submission status: Wrong Answer

Solution code:
def resolve():
    n=int(input())
    xyh=[list(map(int,input().split())) for _ in range(n)]
    ans,flg=0,0
    for cx in range(101):
        for cy in range(101):        
            ans,flg=0,0
            for x,y,h in xyh:
                if ans==0:
                    if h==0:
                        continue
                    else:
                        ans=h+abs(x-cx)+abs(y-cy)
                else:
                    if h==0:
                        if ans>abs(x-cx)+abs(y-cy):
                            flg=1
                            break
                        else:
                            continue
                    else:
                        if ans==h+abs(x-cx)+abs(y-cy):
                            continue
                        else:
                            flg=1
                            break
            if flg==0:
                break
        if flg==0:
            break
    print(cx,cy,ans)            

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n=int(input())
    xyh=[list(map(int,input().split())) for _ in range(n)]
    ans,flg=0,0
    for cx in range(2,101):
        for cy in range(101):        
            ans,flg=0,0
            for x,y,h in xyh:
                if ans==0:
                    if h==0:
                        continue
                    else:
                        ans=h+abs(x-cx)+abs(y-cy)
                else:
                    if h==0:
                        if ans>abs(x-cx)+abs(y-cy):
                            flg=1
                            break
                        else:
                            continue
                    else:
                        if ans==h+abs(x-cx)+abs(y-cy):
                            continue
                        else:
                            flg=1
                            break
            if flg==0:
                break
        if flg==0:
            break
    print(cx,cy,ans)            

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
# C - Pyramid

N = int(input())
XYH = [tuple(int(i) for i in input().split()) for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        pre_tmp_H = 0
        for (x, y, h) in XYH:
            if h != 0:
                tmp_H = h + abs(x - cx) + abs(y - cy)
                if pre_tmp_H != 0 and tmp_H != pre_tmp_H:
                    break
                pre_tmp_H = tmp_H
        else:
            ans = (cx, cy, tmp_H)
            break

print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
A=int(input())
l=[]
X=0
for i in range(A):
   B=list(map(int,input().split()))
   if B[2]==100:
      print(*B)
      exit()
   elif B[2] > 0:
      X=i
   l.append(B)
for i in range(101):
   for j in range(101):
      n=0
      S=max(l[X][2]+abs(i-l[X][0])+abs(j-l[X][1]),0)
      for N in l:
         if S==max(N[2]+abs(i-N[0])+abs(j-N[1]),0):
            pass
         else:
            n=1
            break
      if S==0 or n==1:
         continue
      else:
         print(i,j,S)
         exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

infos = []
infos_zero = []
first_info = []
second_info = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        if len(first_info) == 0:
            first_info = [x, y, h]
        elif len(second_info) == 0:
            second_info = [x, y, h]
        else:
            infos.append([x, y, h])
    else:
        infos_zero.append([x, y, h])


if len(second_info) == 0:
    second_info = infos_zero[0]

# cxとcyを1つに絞り込む
x1, y1, h1 = first_info
x2, y2, h2 = second_info
kouhos = []
for cx in range(101):
    for cy in range(101):
        if h1-h2 == abs(x2-cx) + abs(y2-cy) - abs(x1-cx) - abs(y1-cy):
            kouhos.append([cx, cy])

#print(kouhos)
kouho_isvalid = [True for _ in range(len(kouhos))]

for info in infos:
    x2, y2, h2 = info
    for i in range(len(kouhos)):
        cx, cy = kouhos[i]
        if h1-h2 != abs(x2-cx) + abs(y2-cy) - abs(x1-cx) - abs(y1-cy):
            kouho_isvalid[i] = False


for i in range(len(kouhos)):
    if kouho_isvalid[i]:
        cx, cy = kouhos[i]

H = h1 + abs(x1-cx) + abs(y1-cy)
print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

infos = []
first_info = []
second_info = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        if len(first_info) == 0:
            first_info = [x, y, h]
        elif len(second_info) == 0:
            second_info = [x, y, h]
        else:
            infos.append([x, y, h])

if len(second_info) == 0:
    sys.exit(0)

# cxとcyを1つに絞り込む
x1, y1, h1 = first_info
x2, y2, h2 = second_info
kouhos = []
for cx in range(101):
    for cy in range(101):
        if h1-h2 == abs(x2-cx) + abs(y2-cy) - abs(x1-cx) - abs(y1-cy):
            kouhos.append([cx, cy])

#print(kouhos)
kouho_isvalid = [True for _ in range(len(kouhos))]

for info in infos:
    x2, y2, h2 = info
    for i in range(len(kouhos)):
        cx, cy = kouhos[i]
        if h1-h2 != abs(x2-cx) + abs(y2-cy) - abs(x1-cx) - abs(y1-cy):
            kouho_isvalid[i] = False


for i in range(len(kouhos)):
    if kouho_isvalid[i]:
        cx, cy = kouhos[i]

H = h1 + abs(x1-cx) + abs(y1-cy)
print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

infos = []
first_info = []
second_info = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h >= 0 and len(first_info) == 0:
        first_info = [x, y, h]
    elif h >= 0 and len(second_info) == 0:
        second_info = [x, y, h]
    elif h >= 0:
        infos.append([x, y, h])


# cxとcyを1つに絞り込む
x1, y1, h1 = first_info
x2, y2, h2 = second_info
kouhos = []
for cx in range(101):
    for cy in range(101):
        if h1-h2 == abs(x2-cx) + abs(y2-cy) - abs(x1-cx) - abs(y1-cy):
            kouhos.append([cx, cy])

#print(kouhos)
kouho_isvalid = [True for _ in range(len(kouhos))]

for info in infos:
    x2, y2, h2 = info
    for i in range(len(kouhos)):
        cx, cy = kouhos[i]
        if h1-h2 != abs(x2-cx) + abs(y2-cy) - abs(x1-cx) - abs(y1-cy):
            kouho_isvalid[i] = False


for i in range(len(kouhos)):
    if kouho_isvalid[i]:
        cx, cy = kouhos[i]

H = h1 + abs(x1-cx) + abs(y1-cy)
print(cx, cy, H)