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 = [list(map(int, input().split())) for i in range(N)]

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
f = False
for x in range(101):
    for y in range(101):
        for i in range(N):
            if xyh[i][2] != 0:
                H = abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]
                break
        for i in range(N):
            if xyh[i][2] != 0 and H != abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]:
                break
        else:
            f = True
            break
    if f:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
f = False
for x in range(101):
    for y in range(101):
        H = abs(xyh[0][0]-x) + abs(xyh[0][1]-y) + xyh[0][2]
        for i in range(1,N):
            if xyh[i][2] != 0 and H != abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]:
                break
        else:
            f = True
            break
    if f:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
f = False
for x in range(101):
    for y in range(101):
        H = abs(xyh[0][0]-x) + abs(xyh[0][1]-y) + xyh[0][2]
        for i in range(1,N):
            if H != abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]:
                break
        else:
            f = True
            break
    if f:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
n=int(input())
high=[]
for _ in range(n):
  a=list(map(int,input().split()))
  high.append(a)
inf=float('inf')
  
for x in range(0,101):
  
  for y in range(0,101):
    highlimit=inf
    ans=-1
    ch=-1
    for hi1 in high:
      p,q,r=hi1
      g=r+abs(p-x)+abs(q-y)
      if r<=0:
        G=abs(p-x)+abs(q-y)
        if ans>G:
          break
        if G<=highlimit:
          highlimit=G
        
        continue
      else:
        if g>highlimit:
          break
        else:
          if ans!=-1 and ans!=g:
            ch+=1
            break
          else:
            ans=g
    
    if ans!=-1 and ch==-1:
      print(x,y,ans)
      exit()

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	info = []
	for i in range(N):
		x, y, h = [int(a) for a in input().split(" ")]
		if h > 0:
			info.append({"x": x, "y": y, "h": h})
	info.sort(key=lambda f: -f["h"])
	for cx in range(101):
		for cy in range(101):
			H = 0
			for i in range(len(info)):
				h = info[i]["h"] + abs(info[i]["x"] - cx) + abs(info[i]["y"] - cy)
				if i == 0:
					H = h
				else:
					if h != H:
						break
			else:
				print(cx, cy, H)
				return 0
	if info[0]["x"] in [0, 100] and info[0]["y"] in [0, 100]:
		print(info[0]["x"], info[0]["y"], info[0]["h"])
		return 0

main()

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	info = []
	for i in range(N):
		x, y, h = [int(a) for a in input().split(" ")]
		if h > 0:
			info.append({"x": x, "y": y, "h": h})
	info.sort(key=lambda f: -f["h"])
	for cx in range(101):
		for cy in range(101):
			H = 0
			for i in range(len(info)):
				h = info[i]["h"] + abs(info[i]["x"] - cx) + abs(info[i]["y"] - cy)
				if i == 0:
					H = h
				else:
					if h != H:
						break
			else:
				print(cx, cy, H)
				return 0
	if info[0]["x"] in [0, 100] and info[0]["y"] in [0, 100] and info[0]["h"] != info[1]["h"]:
		print(info[0]["x"], info[0]["y"], info[0]["h"])
		return 0

main()

Submission status: Wrong Answer

Solution code:
def main():
	N = int(input())
	info = []
	for i in range(N):
		x, y, h = [int(a) for a in input().split(" ")]
		if h > 0:
			info.append({"x": x, "y": y, "h": h})
	info.sort(key=lambda f: -f["h"])
	if info[0]["x"] in [0, 100] and info[0]["y"] in [0, 100] and info[0]["h"] != info[1]["h"]:
		print(info[0]["x"], info[0]["y"], info[0]["h"])
		return 0
	for cx in range(101):
		for cy in range(101):
			H = 0
			for i in range(len(info)):
				h = info[i]["h"] + abs(info[i]["x"] - cx) + abs(info[i]["y"] - cy)
				if i == 0:
					H = h
				else:
					if h != H:
						break
			else:
				print(cx, cy, H)
				return 0

main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7

def mapline(t = int):
    return map(t, sysread().split())
def mapread(t = int):
    return map(t, read().split())

def run():
    N = int(sysread())
    V = []
    x0, y0, h0 = None, None, None
    for _ in range(N):
        x,y,h = mapline()
        if h > 0 and x0 == None:
            x0, y0, h0 = x,y,h
        V.append((x, y, h))

    for x in range(0, 101):
        for y in range(0, 101):
            H = h0 + abs(x0-x) + abs(y0-y)
            done = True
            for xk, yk, hk in V:
                _H = hk + abs(xk-x) + abs(yk-y)
                if _H != H:
                    done = False
                    break
            if done:
                print(f'{x} {y} {H}')
                return


if __name__ == "__main__":
    run()

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    l = [i_list() for i in range(n)]

    L = []

    for i in l:
        if i[2] != 0:
            L.append(i)

    for x in range(101):
        for y in range(101):
            H = L[0][2] + abs(x-L[0][0]) + abs(y-L[0][1])
            flg = True
            for x1, y1, h1 in L[1:]:
                if h1 == 0:
                    pass
                if H != h1 + abs(x-x1) + abs(y-y1):
                    flg = False
                    break
            if flg == True:
                ans = [x,y]
    H = L[0][2] + abs(ans[0]-L[0][0]) + abs(ans[1]-L[0][1])
    print(" ".join(map(str, ans)) +" "+str(H))



if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]

def main():
    n = i_input()
    l = [i_list() for i in range(n)]

    L = []

    for i in l:
        if i[2] != 0:
            L.append(i)

    for x in range(101):
        for y in range(101):
            H = L[0][2] + abs(x-L[0][0]) + abs(y-L[0][1])
            flg = True
            for x1, y1, h1 in L[1:]:
                if h1 == 0:
                    pass
                if H != h1 + abs(x-x1) + abs(y-y1):
                    flg = False
                    break
            if flg == True:
                ans = [x,y]
    H = l[0][2] + abs(ans[0]-l[0][0]) + abs(ans[1]-l[0][1])
    print(" ".join(map(str, ans)) +" "+str(H))



if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        x, y, h = xyhs[0]
        ch = h + abs(cy - y) + abs(cx - x)
 
        if all([h == max(ch - abs(cy - y) - abs(cx - x), 0) for x, y, h in xyhs[1:]]):
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())

xl=[]
yl=[]
hl=[]



for i in range(n):
    xx,yy,hh=list(map(int,input().split()))
    xl.append(xx)
    yl.append(yy)
    hl.append(hh)

for cx in range(0,101):
    for cy in range(0,101):
        ok=True
        for i in range(n):
            x=xl[i]
            y=yl[i]
            h=hl[i]
            if h!=0:
                old = h + abs(x - cx) + abs(y - cy)
                break
        
        for i in range(n):
            x=xl[i]
            y=yl[i]
            h=hl[i]
            high=h+abs(x-cx)+abs(y-cy)
            if old!=high:
                ok=False
                break
        if ok:
            print(cx,cy,high)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())

xl=[]
yl=[]
hl=[]



for i in range(n):
    xx,yy,hh=list(map(int,input().split()))
    xl.append(xx)
    yl.append(yy)
    hl.append(hh)

for cx in range(0,101):
    for cy in range(0,101):
        old=-1
        ok=True
        for i in range(n):
            x=xl[i]
            y=yl[i]
            h=hl[i]
            if h==0:
                continue
            high=h+abs(x-cx)+abs(y-cy)
            if old==-1:
                old=high
            else:
                if old!=high:
                    ok=False
                    break
        if ok:
            print(cx,cy,high)
            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):
        x, y, h = XYH[0]
        H = h + abs(x-cx) + abs(y-cy)
        res = []
        for x, y, h in XYH[1:]:
            temp = (h == max(H-abs(x-cx)-abs(y-cy), 0))
            res.append(temp)
        if all(res):
            print(cx, cy, H)
            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):
        x, y, h = XYH[0]
        H = h + abs(x-cx) + abs(y-cy)
        res = []
        for x, y, h in XYH:
            temp = (h == max(H-abs(x-cx)-abs(y-cy), 0))
            res.append(temp)
        if all(res):
            print(cx, cy, H)
            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):
        i = 0
        for x, y, h in XYH:
            if h == 0:
                continue
            H = h + abs(x-cx) + abs(y-cy)
            if i != 0:
                if H != lastH:
                    break
            i += 1
            lastH = H
        else:
            print(cx, cy, H)
            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):
        i = 0
        for x, y, h in XYH:
            if h == 0:
                continue
            H = h + abs(x-cx) + abs(y-cy)
            if H < 1:
                break
            if i != 0:
                if H != lastH:
                    break
            i += 1
            lastH = H
        else:
            print(cx, cy, H)
            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):
        i = 0
        for x, y, h in XYH:
            if h == 0:
                break
            H = h + abs(x-cx) + abs(y-cy)
            if H < 1:
                break
            if i != 0:
                if H != lastH:
                    break
            i += 1
            lastH = H
        else:
            print(cx, cy, H)
            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):
        i = 0
        for x, y, h in XYH:
            H = h + abs(x-cx) + abs(y-cy)
            if H < 1:
                break
            if i != 0:
                if H != lastH:
                    break
            i += 1
            lastH = H
        else:
            print(cx, cy, H)
            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):
        i = 0
        for x, y, h in XYH:
            H = h + abs(x-cx) + abs(y-cy)
            if i != 0:
                if H != lastH:
                    break
            i += 1
            lastH = H
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

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

num_cnd = len(conditions)

for cx in range(101):
    for cy in range(101):
        cnt = 0
        h = 0
        for i,cnd in enumerate(conditions):
            h_tmp = getH(cnd[0], cx, cnd[1], cy, cnd[2])
            if h_tmp >= 1:
                if i==0:
                    h = h_tmp
                    cnt += 1
                elif h == h_tmp:
                    cnt += 1
                    if cnt == num_cnd:
                        print(cx,cy,h)
                        exit(0)
                else:
                    break
            else:
                break
        

print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

N = int(input())
conditions = []
for i in range(N):
    tmp = list(map(int, input().split()))
    conditions.append(tmp)

for cx in range(101):
    for cy in range(101):
        cnt = 0
        h = 0
        for i,cnd in enumerate(conditions):
            h_tmp = getH(cnd[0], cx, cnd[1], cy, cnd[2])
            if h_tmp >= 1:
                if i==0:
                    h = h_tmp
                    cnt += 1
                elif h == h_tmp:
                    cnt += 1
                    if cnt == N:
                        print(cx,cy,h)
                        exit(0)
                else:
                    break
            else:
                break
        

print('No')

Submission status: Wrong Answer

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

def main():
    n = int(input())
    x = [-1] * n; y = [-1] * n; h = [-1] * n
    for i in range(n):
        x[i], y[i], h[i] = map(int, input().split())

    # full search
    for i in range(n):
        if h[i] > 0:
            ind = i
        break

    for cx in range(101):
        for cy in range(101):
            try:
                height = h[ind] + abs(x[ind] - cx) + abs(y[ind] - cy)
            except:
                # h == [0] * n
                height = 1

            flag = True
            for i in range(n):
                if h[i] == 0:
                    if height - abs(x[i] - cx) - abs(y[i] - cy) > 0:
                        flag = False
                        break
                else:
                    if height - abs(x[i] - cx) - abs(y[i] - cy) != h[i]:
                        flag = False
                        break
            if flag:
                print(cx, cy, height)
                exit()

main()

Submission status: Wrong Answer

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

def main():
    n = int(input())
    x = [-1] * n; y = [-1] * n; h = [-1] * n
    for i in range(n):
        x[i], y[i], h[i] = map(int, input().split())

    # full search
    for cx in range(101):
        for cy in range(101):
            height = h[0] + abs(x[0] - cx) + abs(y[0] - cy)
            for i in range(1, n):
                if height != h[i] + abs(x[i] - cx) + abs(y[i] - cy):
                    break
            else:
                print(cx, cy, height)

main()

Submission status: Wrong Answer

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

for cx in range(101):
  for cy in range(101):
    H = P[0][0] + abs(P[0][1]-cx) + abs(P[0][2]-cy)
    for i in range(1,n):
      if max(H-abs(P[i][1]-cx)-abs(P[i][2]-cy), 0) != P[0][0]:
        break
    else:
      print(cx, cy, H)
      exit()

Submission status: Wrong Answer

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

for cx in range(101):
  for cy in range(101):
    H = h[0] + abs(x[0]-cx) + abs(y[0]-cy)
    for i in range(1,n):
      if H != h[i] + abs(x[i]-cx) + abs(y[i]-cy):
        break
    else:
      print(cx, cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

flg = False
for i in range(101):
    if flg:
        break
    for j in range(101):
        if flg:
            break
        for k in range(N):
            h = abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]

            if k>=1 and h != h_before:
                break
            elif k == N-1 and h == h_before:
                flg = True

            h_before = h
            ans = [i, j, h]


print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
for i in range(101):
  for j in range(101):
    s=L[0][2]+abs(i-L[0][0])+abs(j-L[0][1])
    for l in L[1:]:
      h=l[2]+abs(i-l[0])+abs(j-l[1])
      if s<h:
        break
    else:
      print(i,j,s)
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
for i in range(101):
  for j in range(101):
    s=L[0][2]+abs(i-L[0][0])+abs(j-L[0][1])
    for l in L[1:]:
      h=l[2]+abs(i-l[0])+abs(j-l[1])
      if s==h:
        continue
      elif l[2]==0 and s<h:
        continue
      else:
        break
    else:
      print(i,j,s)
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
for i in range(101):
  for j in range(101):
    s=L[0][2]+abs(i-L[0][0])+abs(j-L[0][1])
    for l in L[1:]:
      if l[2]==0 or s==l[2]+abs(i-l[0])+abs(j-l[1]):
        continue
      else:
        break
    else:
      print(i,j,s)
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[list(map(int,input().split())) for i in range(N)]
for i in range(101):
  for j in range(101):
    s=L[0][2]+abs(i-L[0][0])+abs(j-L[0][1])
    for l in L[1:]:
      if s==l[2]+abs(i-l[0])+abs(j-l[1]):
        continue
      else:
        break
    else:
      print(i,j,s)
      exit()

Submission status: Wrong Answer

Solution code:
#
# abc112 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
2 3 5
2 1 5
1 2 5
3 2 5"""
        output = """2 2 6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
0 0 100
1 1 98"""
        output = """0 0 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3
99 1 191
100 1 192
99 0 192"""
        output = """100 0 193"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """4
59 3 0
64 94 56
5 62 11
3 93 14"""
        output = """55 80 79"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    XYH = [list(map(int, input().split())) for _ in range(N)]

    CX = CY = H = 0
    flag = False
    for cx in range(101):
        if flag == True:
            break
        for cy in range(101):
            H = 0
            for xyh in XYH:
                x, y, h = xyh
                if h == 0:
                    continue
                elif H == 0:
                    H = h+abs(x-cx)+abs(y-cy)
                    continue
                if h != max(H - abs(x-cx) - abs(y-cy), 0):
                    break
            else:
                flag = True
                CX = cx
                CY = cy
                break

    print(f"{CX} {CY} {H}")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
#
# abc112 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4
2 3 5
2 1 5
1 2 5
3 2 5"""
        output = """2 2 6"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
0 0 100
1 1 98"""
        output = """0 0 100"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3
99 1 191
100 1 192
99 0 192"""
        output = """100 0 193"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    XYH = [list(map(int, input().split())) for _ in range(N)]

    CX = CY = H = 0
    flag = False
    for cx in range(101):
        if flag == True:
            break
        for cy in range(101):
            x1 = XYH[0][0]
            y1 = XYH[0][1]
            h1 = XYH[0][2]
            H = h1+abs(x1-cx)+abs(y1-cy)
            for xyh in XYH[1:]:
                x, y, h = xyh
                if h != max(H - abs(x-cx) - abs(y-cy), 0):
                    break
            else:
                flag = True
                CX = cx
                CY = cy
                break

    print(f"{CX} {CY} {H}")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [tuple(map(int,input().split())) for i in range(n)]
for xi,yi,hi in xyh:
    if hi:
        xt,yt,ht = xi,yi,hi

for i in range(101):
    for j in range(101):
        a = ht+abs(i-xt)+abs(j-yt)
        for xi,yi,hi in xyh:
            x = hi+abs(i-xi)+abs(j-yi)
            if a != x:
                break
        else:
            print(i,j,a)
            exit(0)

Submission status: Wrong Answer

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


for i in range(101):
    for j in range(101):
        a = -1
        for xi,yi,hi in xyh:
            if hi:
                x = hi+abs(i-xi)+abs(j-yi)
                if a == -1:
                    a = x
                else:
                    if a != x:
                        break
        else:
            print(i,j,a)
            exit(0)

Submission status: Wrong Answer

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


for i in range(101):
    for j in range(101):
        a = -1
        for xi,yi,hi in xyh:
            if not hi:
                x = hi+abs(i-xi)+abs(j-yi)
                if a == -1:
                    a = x
                else:
                    if a != x:
                        break
        else:
            print(i,j,a)
            exit(0)

Submission status: Wrong Answer

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


for i in range(101):
    for j in range(101):
        a = -1
        for xi,yi,hi in xyh:
            x = hi+abs(i-xi)+abs(j-yi)
            if a == -1:
                a = x
            else:
                if a != x:
                    break
        else:
            print(i,j,a)

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[list(map(int,input().split())) for i in range(N)]
fx,fy,fh=l[0]
for i in range(0,101):
   for j in range(0,101):
      sw=0
      cer_h=fh+abs(fx-i)+abs(fy-j)
      for x,y,h in l:
         if cer_h-abs(i-x)-abs(j-y)!=h:
            sw=1
            break
      if sw==0:
         print(i,j,cer_h)
         exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
l=[list(map(int,input().split())) for i in range(N)]
fx,fy,fh=l[0]
for i in range(0,3):#x
   for j in range(0,3):#y
      sw=0
      cer_h=fh+abs(fx-i)+abs(fy-j)
      for x,y,h in l:
         if cer_h-abs(i-x)-abs(j-y)!=h:
            sw=1
            break
      if sw==0:
         print(i,j,cer_h)
         exit()

Submission status: Wrong Answer

Solution code:
# vim: fileencoding=utf-8


def main():

    n = int(input())
    li = []
    for i in range(n):
        x, y, h = map(int, input().split())
        li.append({"x": x, "y": y, "h": h})
    li.sort(key=lambda x: x["h"], reverse=True)

    tops = []
    for i in range(101):
        for j in range(101):
            h = li[0]["h"] + abs(li[0]["x"] - i) + abs(li[0]["y"] - j)
            tops.append({"x": i, "y": j, "h": h})

    for i in range(1, n):
        tmp = []
        for j in range(len(tops)):
            x = li[i]["x"]
            y = li[i]["y"]
            h = li[i]["h"]
            topX = tops[j]["x"]
            topY = tops[j]["y"]
            topH = tops[j]["h"]
            if h == max(topH - abs(topX - x) - abs(topY - y), 0):
                tmp.append(tops[j])
        tops = tmp
    print(list(tops[0].values()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cnt = 1
for x in range(101):
    for y in range(101):
        diff_x = abs(XYH[0][0] - x)
        diff_y = abs(XYH[0][1] - y)
        H = XYH[0][2] + diff_x + diff_y
        for xyh in XYH[1:]:
            if xyh[2] != max(H - abs(xyh[0] - x) - abs(xyh[1] - y), 0):
                break
        else:
            print(x, y, H)
            exit()

Submission status: Wrong Answer

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

cnt = 1
for x in range(101):
    for y in range(101):
        diff_x = abs(XYH[0][0] - x)
        diff_y = abs(XYH[0][1] - y)
        H = XYH[0][2] + diff_x + diff_y
        for xyh in XYH[1:]:
            if xyh[2] != max(H - abs(xyh[0] - x) - abs(xyh[1] - y), 0):
                break
        else:
            print(x, y, H)
            break

Submission status: Wrong Answer

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

cnt = 1
for x in range(101):
    for y in range(101):
        diff_x = abs(XYH[0][0] - x)
        diff_y = abs(XYH[0][1] - y)
        H = XYH[0][2] + diff_x + diff_y
        for xyh in XYH[1:]:
            if xyh[2] != max(H - abs(xyh[0] - x) - abs(xyh[1] - y), 0):
                break
            else:
                cnt += 1
                if cnt == N:
                    print(x, y, H)
                    exit()