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 bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N = int(sys.stdin.readline())
X, Y, H = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

ans = []
for cx in range(101):
    for cy in range(101):
        ch = abs(X[0] - cx) + abs(Y[0] - cy) + H[0]
        ok = True
        for x, y, h in zip(X, Y, H):
            h = abs(x - cx) + abs(y - cy) + h
            if ch != h:
                ok = False
            if not ok:
                break
        if ok:
            ans = cx, cy, ch

print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
for cx in range(101):
    for cy in range(101):
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            break

print(cx,cy,h)

Submission status: Wrong Answer

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

a = d[j]
for x in range(101):
    for y in range(101):
        flag = True
        h = a[2] + abs(a[0] - x) + abs(a[1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y), 0):
                flag = False
                break

        if flag:
            print(x, y, h)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        flag = True
        h = d[N-1][2] + abs(d[N-1][0] - x) + abs(d[N-1][1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y), 0):
                flag = False
                break

        if flag:
            print(x, y, h)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        flag = True
        h = d[0][2] + abs(d[0][0] - x) + abs(d[0][1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y), 0):
                flag = False
                break

        if flag:
            print(x, y, h)
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())
d = []
for _ in range(N):
    d.append(list(map(int,input().split())))
d.sort(key=lambda a: a[2])

for x in range(101):
    for y in range(101):
        flag = True
        h = d[0][2] + abs(d[0][0] - x) + abs(d[0][1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y),0):
                flag = False
                break

        if flag:
            print(x, y, h)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        flag = True
        h = d[0][2] + abs(d[0][0] - x) + abs(d[0][1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y),0):
                flag = False
                break

        if flag:
            print(x, y, h)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        flag = True
        h = d[0][2] + abs(d[0][0] - x) + abs(d[0][1] - y)
        for i in d:
            if i[2] != max(h - abs(i[0] - x) - abs(i[1] - y),0):
                flag = False
                break

        if flag:
            print(x, y, h)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        flag = True
        ansh = d[0][2] + abs(d[0][0] - x) + abs(d[0][1] - y)
        for n in range(N):
            if d[n][2] != max(ansh - abs(d[n][0] - x) - abs(d[n][1] - y),0):
                flag = False
                break

        if flag:
            print(x, y, ansh)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        flg = True
        ansh = d[0][2] + abs(d[0][0] - x) + abs(d[0][1] - y)
        for n in range(N):
            if d[n][2] != max(ansh - abs(d[n][0] - x) - abs(d[n][1] - y),0):
                flg = False

        if flg:
            print(x, y, ansh)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        flg = True
        ansh = d[0][2] + abs(d[0][0] - x) + abs(d[0][1] - y)
        for n in range(N):
            if d[n][2] != ansh - abs(d[n][0] - x) - abs(d[n][1] - y):
                flg = False

        if flg == True:
            print(x, y, ansh)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = []
        for n in range(N):
            h.append(d[n][2] + abs(d[n][0] - x) + abs(d[n][1] - y))
        
        if h.count(h[0]) == N:
            print(x, y, h[0])

Submission status: Wrong Answer

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

if N == 1:
    print(d[0][0],d[0][1],d[0][2])

for x in range(101):
    for y in range(101):
        ansh_old = 0
        for n in range(N):
            if n == 0:
                ansh_old = d[n][2] + abs(d[n][0] - x) + abs(d[n][1] - y)
            else:
                ansh = d[n][2] + abs(d[n][0] - x) + abs(d[n][1] - y)
                if ansh != ansh_old:
                    break
                if ansh == ansh_old and n == N - 1:
                    print(x, y, ansh)
                    exit()
                ansh_old = ansh

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        ansh_old = 0
        for n in range(N):
            if n == 0:
                ansh_old = d[n][2] + abs(d[n][0] - x) + abs(d[n][1] - y)
            else:
                ansh = d[n][2] + abs(d[n][0] - x) + abs(d[n][1] - y)
                if ansh != ansh_old:
                    break
                if ansh == ansh_old and n == N - 1:
                    print(x, y, ansh)
                    exit()
                ansh_old = ansh

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N = int(input())

#ありえるCX, CYの値の範囲
minx = 0
miny = 0
maxx = 100
maxy = 100

#[0], [1], [2]にx, y, hがそれぞれ入る
inf = [list(mi()) for _ in range(N)]

import itertools
#場合分けして、ありえる範囲を狭めていく
for (px, py, ph), (x, y, h) in list(itertools.combinations(inf,2)):
  #どちらもCenterから遠ざかった場合
  if abs(x-px)+abs(y-py)==ph-h:
    if x>px: maxx = px
    elif px>x: minx = px
    if y>py: maxy = py
    elif py>y: miny = py
  #どちらも近づいた場合
  elif abs(x-px)+abs(y-py)==h-ph:
    if x>px: minx = x
    elif px>x: maxx = x
    if y>py: miny = y
    elif py>y: maxy = y
  #どちらかが同じだった場合
  if x == px: #x==pxならy!=py。elifなので
    #高さが変わっていなければ、中間地点がCenter
    if ph==h: miny, maxy = (y+py)//2, (y+py)//2
    elif abs(h-ph)==abs(y-py):
      if h>ph and y>py: miny = y
      elif h>ph and y<py: maxy = y
      elif h<ph and y>py:  maxy = y
      else: miny = y
    elif abs(h-ph)==abs(x-px):
      if x>px and x>px: minx = x
      elif x>px and x<px: maxx = x
      elif x<px and x>px:  maxx = x
      else: minx = x
  if y == py: #x==pxならy!=py。elifなので
    #高さが変わっていなければ、中間地点がCenter
    if ph==h: minx, maxx = (x+px)//2, (x+px)//2
    elif abs(h-ph)==abs(x-px):
      if h>ph and x>px: minx = x
      elif h>ph and x<px: maxx = x
      elif h<ph and x>px:  maxx = x
      else: minx = x
    elif abs(h-ph)==abs(y-py):
      if y>py and y>py: miny = y
      elif y>py and y<py: maxy = y
      elif y<py and y>py:  maxy = y
      else: miny = y

  if minx==maxx and miny==maxy: break

cx = minx
cy = miny

print(cx, cy, inf[0][2] + abs(inf[0][0]-cx) + abs(inf[0][1]-cy))

Submission status: Wrong Answer

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

ll = [[-1] * 101 for i in range(101)]

for i in l:
    for j in range(101):
        for k in range(101):
            x = abs(i[0] - j)
            y = abs(i[1] - k)
            if ll[j][k] == -1:
                ll[j][k] = x + y + i[2]
            elif ll[j][k] != x + y + i[2]:
                ll[j][k] = 0


ans = ''
for i in range(101):
    for j in range(101):
        if ll[i][j] > 0:
            ans = str(i) + ' ' + str(j) + ' ' + str(ll[i][j])

print(ans)

Submission status: Wrong Answer

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

ll = [[0] * 101 for i in range(101)]

for i in l:
    for j in range(101):
        for k in range(101):
            x = abs(i[0] - j)
            y = abs(i[1] - k)
            if ll[j][k] == 0:
                ll[j][k] = x + y + i[2]
            elif ll[j][k] != x + y + i[2]:
                ll[j][k] = -1

ans = ''
for i in range(101):
    for j in range(101):
        if ll[i][j] != -1:
            ans = str(i) + ' ' + str(j) + ' ' + str(ll[i][j])

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[]]*n
for i in range(n):
    l[i]=list(map(int,input().split()))
lst=sorted(l,key=lambda x:-x[2])
flag=False

for i in range(0,101):#i=X
    if flag:
        break
    for j in range(0,101):#j=Y
        if flag:
            break
        tmp=lst[0][2]+abs(lst[0][0]-i)+abs(lst[0][1]-j)
        for k in range(n):
            #print(k,'ループ目')
            sum=abs(lst[k][0]-i)+abs(lst[k][1]-j)
            H=lst[k][2]+sum
            if tmp!=H and (not (lst[k][2]==0 and H<sum)):
                break
            if k==n-1:
                flag=True
                #print('tmp:',tmp,'H:',H,'k',k)
                print(i,j,H)

Submission status: Wrong Answer

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

for cy in range(101):
	for cx in range(101):
		ch = None
		for x, y, h in XYH:
			if 0 == h:
				continue
			dy, dx = abs(y - cy), abs(x - cx)
			th = h + dy + dx
			if not ch:
				ch = th
				continue
			else:
				if h != max(0, ch - dy - dx):
					break
		else:
			print(cx, cy, ch)
			exit()

Submission status: Wrong Answer

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

for cy in range(101):
	for cx in range(101):
		ch = 0
		for x, y, h in XYH:
			if 0 == h:
				continue
			dy, dx = abs(y - cy), abs(x - cx)
			th = h + dy + dx
			if 0 < th and 0 == ch:
				ch = th
			else:
				if ch != th:
					break
		else:
			print(cx, cy, ch)
			exit()

Submission status: Wrong Answer

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

for cy in range(101):
	for cx in range(101):
		ch = 0
		for x, y, h in XYH:
			if 0 == h:
				continue
			dy, dx = abs(y - cy), abs(x - cx)
			th = h + dy + dx
			if 0 == ch:
				ch = th
			else:
				if ch != th:
					break
		else:
			print(cx, cy, ch)
			exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
cod = []
rx, ry, rh = 0, 0, 0
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        rx, ry, rh = x, y, h
    cod.append([x, y, h])

for i in range(101):
    for j in range(101):
        H = rh+abs(rx-i)+abs(ry-j)
        if H < 0 or H > 10**9:
            continue
        flg = True
        for x, y, h in cod:
            if H - abs(x-i) - abs(y-j) != h:
                flg = False
                break
        if flg:
            print(i, j, H)
            quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
cod = []
rx, ry, rh = 0, 0, 0
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        rx, ry, rh = x, y, h
    cod.append([x, y, h])

for i in range(101):
    for j in range(101):
        H = rh+abs(rx-i)+abs(ry-j)
        if H < 0:
            continue
        flg = True
        for x, y, h in cod:
            if H - abs(x-i) - abs(y-j) != h:
                flg = False
                break
        if flg:
            print(i, j, H)
            quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
cod = []
rx, ry, rh = 0, 0, 0
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        rx, ry, rh = x, y, h
    cod.append([x, y, h])

for i in range(101):
    for j in range(101):
        H = max(rh+abs(rx-i)+abs(ry-j), 0)
        flg = True
        for x, y, h in cod:
            if H - abs(x-i) - abs(y-j) != h:
                flg = False
                break
        if flg:
            print(i, j, H)
            quit()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        x, y, h = cod[0]
        H = max(h+abs(x-i)+abs(y-j), 0)
        flg = True
        for x, y, h in cod:
            if H - abs(x-i) - abs(y-j) != h:
                flg = False
                break
        if flg:
            print(i, j, H)
            quit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        before = 0
        count = 0
        for xi,yi,hi in lst:
            if hi == 0:
                count += 1
                continue

            H = hi + abs(xi-x)+abs(yi-y)
            if before == 0:
                before = H
            
            if before != H:
                break
            
            count += 1
            before = H

        if count == N:
            print(x,end=" ")
            print(y,end=" ")
            print(before)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        x0,y0,h0 = lst[0]
        before = h0 + abs(x0-x) + abs(y0-y)
        count = 0
        for xi,yi,hi in lst:
            if hi == 0:
                count += 1
                continue

            H = hi + abs(xi-x)+abs(yi-y)
            if before != H:
                break
            
            count += 1
            before = H

        if count == N:
            print(x,end=" ")
            print(y,end=" ")
            print(before)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        x0,y0,h0 = lst[0]
        before = h0 + abs(x0-x) + abs(y0-y)
        count = 0
        for xi,yi,hi in lst:
            H = hi + abs(xi-x)+abs(yi-y)
            if before != H:
                break
            
            count += 1
            before = H

        if count == N:
            print(x,end=" ")
            print(y,end=" ")
            print(before)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

xyhs = [list(map(int, input().split())) for _ in range(n)]
xyhs.sort(key=lambda i: i[2], reverse=True)

print(xyhs)

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

xyhs = [list(map(int, input().split())) for _ in range(n)]
xyhs.sort(key=lambda i: i[2], reverse=True)

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([ch == max(h + 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())

xyhs = [list(map(int, input().split())) for _ in range(n)]
xyhs.sort(key=lambda i: i[2], reverse=True)

for cx in range(100):
    for cy in range(100):
        x, y, h = xyhs[0]
        ch = h + abs(cy - y) + abs(cx - x)

        if all([ch == max(h + 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())
xyhs = [list(map(int, input().split())) for _ in range(N)]

minH = int(1e9)
for xyh in xyhs:
  minH = min(minH, xyh[2])

cx, cy, H = 0, 0, 0
for h in range(minH, int(1e9)):
  if H != 0: break
  for x in range(101):
    if H != 0: break
    for y in range(101):
      if H != 0: break
      for xyh in xyhs:
        if max(h - abs(xyh[0]-x) - abs(xyh[1]-y), 0) != xyh[2]:
          break
      else:
        cx, cy, H = x, y, h
        break

print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

# C_xとC_yを10000通り全探索してHが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        first_flag = True
        for i in range(N):
            tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
            if tmp_H == 0:
                break
            if first_flag:
                H = tmp_H
                first_flag = False
            else:
                if H != tmp_H:
                    break
            if i == N - 1:
                print(C_x, C_y, H)

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

# C_xとC_yを10000通り全探索してHが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        first_flag = True
        for i in range(N):
            if h[i] > 0:
                tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
                if tmp_H == 0:
                    break
                if first_flag:
                    H = tmp_H
                    first_flag = False
                else:
                    if H != tmp_H:
                        break
            if i == N - 1:
                print(C_x, C_y, H)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
pyramid = []

for _ in range(N):
    pyramid.append(list(map(int,input().split())))

# 総当たり
for i in range(101):
    cx = i
    for j in range(101):
        cy = j
        H = []
        for k in range(N): 
            H.append(abs(pyramid[k][0]-cx) + abs(pyramid[k][1]-cy) + pyramid[k][2])
        if len(set(H)) == 1:
            print(cx,cy,H[0])
            sys.exit()

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

# C_xとC_yを10000通り全探索してHが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        first_flag = True
        for i in range(N):
            if h[i] > 0:
                tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
                if first_flag:
                    H = tmp_H
                    first_flag = False
                else:
                    if H != tmp_H:
                        break
            if i == N - 1:
                if H > 1:
                    print(C_x, C_y, H)

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())
    if N == 1:
        print(x[0], y[0], h[0])
        exit(0)

# C_xとC_yを10000通り全探索してHが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        first_flag = True
        for i in range(N):
            if h[i] > 0:
                tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
                if first_flag:
                    H = tmp_H
                    first_flag = False
                else:
                    if H != tmp_H:
                        break
            if i == N - 1:
                if H >= 1:
                    print(C_x, C_y, H)

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

# C_xとC_yを10000通り全探索してHが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        first_flag = True
        for i in range(N):
            if h[i] > 0:
                tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
                if first_flag:
                    H = tmp_H
                    first_flag = False
                else:
                    if H != tmp_H:
                        break
            if i == N - 1:
                if H >= 1:
                    print(C_x, C_y, H)

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

# C_xとC_yを10000通り全探索してHが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        first_flag = True
        for i in range(N):
            if h[i] > 0:
                tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
                if first_flag:
                    H = tmp_H
                    first_flag = False
                else:
                    if H != tmp_H:
                        break
            if i == N - 1:
                print(C_x, C_y, H)

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

# C_xとC_yを10000通り全探索してH-hが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        same_H_count = 0
        for i in range(N):
            if h[i] > 0:
                tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
                if same_H_count == 0:
                    H = tmp_H
                    same_H_count += 1
                else:
                    if H == tmp_H:
                        same_H_count += 1
                        if same_H_count == N:
                            print(C_x, C_y, H)
                        continue
                    else:
                        break

Submission status: Wrong Answer

Solution code:
# 入力
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = map(int, input().split())

# C_xとC_yを10000通り全探索してH-hが全式で同じ値のものを出力
for C_x in range(101):
    for C_y in range(101):
        same_H_count = 0
        for i in range(N):
            tmp_H = abs(x[i] - C_x) + abs(y[i] - C_y) + h[i]
            if i == 0:
                H = tmp_H
                same_H_count += 1
            else:
                if H == tmp_H:
                    same_H_count += 1
                    if same_H_count == N:
                        print(C_x, C_y, H)
                    continue
                else:
                    break

Submission status: Wrong Answer

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

for x, y, h in l:
    if h == 0:
        continue
        
for Cx in range(0, 101):
    for Cy in range(0, 101):
        H = abs(Cx-x) + abs(Cy-y) + h
        if all(hh == max(H - abs(Cx-xx) - abs(Cy-yy), 0) for xx, yy, hh in l):
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

x = [0] * n
y = [0] * n
h = [0] * n

for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())
    
ans_x = 0 
ans_y = 0  
ans_h = 0

for i in range(101):
    for j in range(101):
        H_candidate = []
        for k in range(n):
            if h[k] != 0:
                H_candidate.append(abs(x[k]-i)+abs(y[k]-j)+h[k])
        if len(set(H_candidate)) == 1:
            ans_x = i
            ans_y = j
            ans_h = H_candidate[0]
if H_candidate == []:
        ans_x = [int(i) for i in range(101) if i not in x][0]
        ans_y = [int(i) for i in range(101) if i not in y][0]
        ans_h = 1
print(ans_x,ans_y,ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())

x = [0] * n
y = [0] * n
h = [0] * n

for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())
    
ans_x = 0 
ans_y = 0  
ans_h = 0

for i in range(101):
    for j in range(101):
        H_candidate = []
        for k in range(n):
            if h[k] != 0:
                H_candidate.append(abs(x[k]-i)+abs(y[k]-j)+h[k])
        if len(set(H_candidate)) == 1:
            ans_x = i
            ans_y = j
            ans_h = H_candidate[0]
print(ans_x,ans_y,ans_h)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ansers = defaultdict(int)
for x, y, h in l:
    if h == 0:
        N -= 1
        continue
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            ansers[Cx, Cy, H] += 1
            
for k, v in ansers.items():
  if v == N and k[2] > 0:
    print(*k, sep=' ')
    break

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ansers = defaultdict(int)
for x, y, h in l:
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            ansers[Cx, Cy, H] += 1
            
for k, v in ansers.items():
  if v == N and k[2] > 0:
    print(*k, sep=' ')
    break

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ansers = defaultdict(int)
for x, y, h in l:
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = max(abs(Cx-x) + abs(Cy-y) + h, 0)
            ansers[Cx, Cy, H] += 1
            
for k, v in ansers.items():
  if v == N and k[2] > 0:
    print(*k, sep=' ')
    break

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ansers = defaultdict(int)
for x, y, h in l:
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = max(abs(Cx-x) + abs(Cy-y) + h, 0)
            ansers[Cx, Cy, H] += 1
            
print(*max(ansers, key=ansers.get), sep=' ')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

ansers = defaultdict(int)
for x, y, h in l:
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = abs(Cx-x) + abs(Cy-y) + h
            ansers[Cx, Cy, H] += 1
            
print(*max(ansers, key=ansers.get), sep=' ')

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[]
for i in range(n):
    s.append([int(i) for i in input().split()])
for i in range(101):
    for j in range(101):
        for r in range(n-1):
            if abs(s[r][0]-i)+abs(s[r][1]-j)+s[r][2]==abs(s[r+1][0]-i)+abs(s[r+1][1]-j)+s[r+1][2]:
                t=1
                continue
            else:
                t=0
                break
        if t==1:
            H=[str(i),str(j),str(abs(s[1][0]-i)+abs(s[1][1]-j)+s[1][2])]
            print(' '.join(H))
            quit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

#
#すべての条件についてある入力からhを求める
#そのhについて、その他の条件をすべて満たせればOK
ans_x, ans_y, ans_h = -1,-1,-1
indexes = [i for i, x in enumerate(xyh) if x[2] > 0]

for cx in range(101):
    for cy in range(101):
        H = xyh[indexes[-1]][2] + abs(xyh[indexes[-1]][0] - cx) + abs(xyh[indexes[-1]][1] - cy)
        match = 1
        for i in range(N):
            h = H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy)
            if xyh[i][2] > 0 and (h != xyh[i][2]):
                match = 0
            if xyh[i][2] == 0 and (H > (abs(xyh[-1][0] - cx) + abs(xyh[-1][1] - cy)) ):
                match = 0
        
        if match:
            ans_x = cx
            ans_y = cy
            ans_h = H
            
print(str(ans_x) + ' ' + str(ans_y) + ' ' + str(ans_h))