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
Input = sys.stdin.readline

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = None

if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for x, y, h in x_y_h:
                if h > 0:
                    H = abs(c_x - x) + abs(c_y - y) + h
                    break
            for x, y, h in x_y_h:
                if abs(c_x - x) + abs(c_y - y) + h >= 0:
                    if H != abs(c_x - x) + abs(c_y - y) + h:
                        break
            else:
                    print("{0} {1} {2}".format(c_x, c_y, H))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

def calc_candidates(x, y, h):
    result = []
    for cy in range(0, 101):
        dy = abs(cy - y)
        tmp = []
        for cx in range(0, 101):
            dx = abs(cx - x)
            hs = list([h+(dx + dy)])
            hs = list(set([_ for _ in hs if _ >= 1]))
            tmp.append(hs)
        result.append(tmp)
    return result

def update_candidates(prev, x, y, h):
    for cy, data_y in enumerate(prev):
        dy = abs(cy - y)
        for cx, data_x in enumerate(data_y):
            if(data_x):
                dx = abs(cx - x)
                hs = [h+(dx + dy)]
                data_x[:] = [_ for _ in data_x if _ in hs]
    return prev


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

candidates = calc_candidates(*inputs[0])

def pr(cands):
    for cy, data_y in enumerate(cands):
        if cy > 10: break
        for cx, data_x in enumerate(data_y):
            if cx > 10: break
            print((data_x), end=' ')
        print()

def pr_result(cands):
    for cy, data_y in enumerate(cands):
        for cx, data_x in enumerate(data_y):
            if data_x:
                print(cx, cy, data_x[0])
                return

for args in inputs[1:]:
    update_candidates(candidates, *args)


pr_result(candidates)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
a = []
for i in range(N):
    a.append(map(int, raw_input().split()))

for i in range(101):
    for j in range(101):
        count = 0
        H =[]
        itr = -1
        for k in range(N):
            if a[k][2] != 0:
                H.append(a[k][2]+abs(a[k][0]-i)+abs(a[k][1]-j))
                itr = itr + 1
                #print(a[k][2]+abs(a[k][0]-i)+abs(a[k][1]-j))

            if itr > 0:
                #print(H)
                #print(itr)
                if H[itr-1] != H[itr]:
                    break
                else:
                    count = k
        if count == N-1:
            print i, j ,H[0]

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(min(X), max(X)+1):
    for Cy in range(min(Y), max(Y)+1):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and h == H[i] + abs(X[i]-Cx) + abs(Y[i]-Cy):
            i += 1
        if i == N:
            print(Cx, Cy, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>5:
    print(cand[-2][0],cand[-2][1],cand[-2][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
x = N*[0]
y = N*[0]
h = N*[0]

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

for i in range(101):
    for j in range(101):
        for k in range(N):
            if(h[k] != 0):
                H = h[k] + abs(x[k] - i) + abs(y[k] - j)
                break
        flag = 1
        for k in range(N):
            if(h[k] == 0): continue
            if(H != (h[k] + abs(x[k] - i) + abs(y[k] - j))):
                flag = 0
                break
        if(flag == 1):
            print("%d %d %d" %(i, j, H))
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
card = []

for i in range(n):
    x,y,h = [int(i) for i in input().split()]
    card.append([x,y,h])

def check(cx,cy):
    Hs = []
    
    for i in range(n):
        x,y,h = card[i]
        if h != 0:
            H = abs(x-cx)+abs(y-cy)+h
            break
        
    for i in range(n):
        x,y,h = card[i]
        if h == 100:
            print("{} {} {}".format(x,y,h))
            exit()

        if h == max((H-abs(x-cx)-abs(y-cy)),0):
            continue
        else:
            return False
    else:
        return True
    
for i in range(101):
    for j in range(101):
        if check(i,j):
            ax = i
            ay = j
            
            x1,y1,h1 = card[0]
            ah = abs(x1-i)+abs(y1-j)+h1

            print("{} {} {}".format(ax,ay,ah))
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>5:
    print(cand[-1][0],cand[-1][1],cand[-1][2])

Submission status: Wrong Answer

Solution code:
import sys
import itertools


def height(x, y, Cx, Cy, H):
    return max([H - abs(x - Cx) - abs(y - Cy), 0])


N = int(sys.stdin.readline().strip())

set_list = []
for line in sys.stdin.readlines():
    x, y, h = list(map(int, line.strip().split()))
    if h == 0:
        continue
    ans_set = set()
    for Cx, Cy in itertools.product(range(101), range(101)):
        dx = abs(x - Cx)
        dy = abs(y - Cy)
        d = dx + dy
        H = h + d
        if H >= d:
            ans_set.add((Cx, Cy, H))
    set_list.append(ans_set)

ans_set = set_list[0]
for s in set_list[1:]:
    ans_set = ans_set & s

if len(ans_set) == 1:
    Cx, Cy, H = list(ans_set)[0]
    print(Cx, Cy, H)
else:
    print("error,", ans_set)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xi, yi, hi = list(map(int, input().split()))
    x.append(xi)
    y.append(yi)
    h.append(hi)


for cx, cy in itr.product(range(101),range(101)):
    hh = set([])  
    for i in range(n):
        if h[i] > 0:
            hh.add(abs(x[i]-cx)+abs(y[i]-cy)+h[i])
            #print(cx, cy, i, hh)
            if  len(hh) > 1:
                break
        elif abs(x[i]-cx)+abs(y[i]-cy) < 1:
            break
    else:
        if len(hh) == 1:
            print(cx, cy, hh.pop())
            break

Submission status: Wrong Answer

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

H = -1
C_x = 0
C_y = 0

def height(C_x,C_y,x,y,h):
  H = h + abs(x-C_x) + abs(y-C_y)
  return H

def koud(C_x,C_y,H,x,y):
  h = H - abs(x-C_x) - abs(y-C_y)
  return max(h,0)

flag = False
for i in range(0,101):
  C_x = i
  for j in range(0,101):
    C_y = j
    H = -1
    for k in range(N):
      if zahyou[k][2] == 0:#高度が0のとき
        continue
      if H < 0:
        H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
      else:
        if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
          break
        else:
          continue        
    else:
      flag = True
      break
    if flag:
      break
  if flag:
    break

print(C_x,C_y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())
x = N*[0]
y = N*[0]
h = N*[0]

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

for i in range(101):
    for j in range(101):
        for i in range(N):
            if(h[i] != 0):
                H = h[0] + abs(x[0] - i) + abs(y[0] - j)
                break
        flag = 1
        for k in range(N):
            if(h[k] == 0): continue
            if(H != (h[k] + abs(x[k] - i) + abs(y[k] - j))):
                flag = 0
                break
        if(flag == 1):
            print("%d %d %d" %(i, j, H))
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = []
for cx in range(101): #Cx 0~100
    for cy in range(101): #Cy 0~100
        h = []
        for i in range(n):
            #x[i], y[i], h[i]のときの高さHを求める（h[i] == 0の場合を除く）
            #H = |x[i] - Cx| + |y[i] - Cy| + h[i]
            if xyh[i][2] != 0:
                h.append(abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2])

        # Hがすべて一致するときのCx, Cyが答えである
        if len(set(h)) == 1:
            ans.append(cx)
            ans.append(cy)
            ans.append(h[0])
            print(ans[0], ans[1], ans[2])
            exit()

print(ans[0], ans[1], ans[2])

Submission status: Wrong Answer

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = None

x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for x, y, h in x_y_h_tmp:
                if h > 0:
                    H = abs(c_x - x) + abs(c_y - y) + h
                    break
            for x, y, h in x_y_h_tmp:
                if abs(c_x - x) + abs(c_y - y) + h >= 0:
                    if H != abs(c_x - x) + abs(c_y - y) + h:
                        break
            else:
                    print("{0} {1} {2}".format(c_x, c_y, H))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
numss = [[int(i) for i in input().split()] for i in range(n)]

def h(x,y,h,cx,cy):
    return h+abs(x-cx)+abs(y-cy)
def hc(x,y,cx,cy,H):
    return H-abs(x-cx)-abs(y-cy)
def check(cx,cy,H):
    flag = True
    for nums in numss:
        if hc(nums[0],nums[1],cx,cy,H) == nums[2]:
            pass
        else:
            flag=False
            break
    return flag
ans=[]
for cx in range(0,101):
    for cy in range(0,101):
        for nums in numss:
            H=h(nums[0],nums[1],nums[2],cx,cy)
            if check(cx,cy,H):
                ans.append(cx)
                ans.append(cy)
                ans.append(H)
                break
if len(ans)==0:
    print("0 0 0")
else:
    print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
inp=[]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    inp.append([xi,yi,hi])
    if hi==0:
        pass
    else:
            
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
flag=0
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            flag=1
            print(x,y,xymap[x][y])
if flag==0:
    xymap=[[-1 for j in range(101)] for i in range(101)]
    for i in range(len(inp)):
        xi=inp[i][0]
        yi=inp[i][1]
        hi=inp[i][2]
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
    for x in range(101):
        for y in range(101):
            if xymap[x][y]!=-2:
                print(x,y,xymap[x][y])

Submission status: Wrong Answer

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


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

if not any(h for x, y, h in xyh if h > 0):
    for cx in range(0, 101):
        for cy in range(0, 101):
            TH = set(H(cx, cy, x, y, h) for x, y, h in xyh)
            if len(TH) == 1:
                print(cx, cy, TH.pop())

else:
    for cx in range(0, 101):
        for cy in range(0, 101):
            TH = set(H(cx, cy, x, y, h) for x, y, h in xyh if h > 0)
            if len(TH) == 1:
                print(cx, cy, TH.pop())

Submission status: Wrong Answer

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

N = int(input())

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


ans_list = []
for xi in range(101):
    for yi in range(101):
        H_list = []
        for x,y,h in xyhn:
            if h > 0:
                H = h + abs(x - xi) + abs(y - yi)
                H_list.append(H)

        if min(H_list) == max(H_list):
            ans_list.append([xi,yi,H_list[0]])
            # print("%d %d %d"%(xi,yi,H_list[0]))
            # exit()

ans_list.sort(key=lambda x:-x[2])
print("%d %d %d"%(ans_list[0][0],ans_list[0][1],ans_list[0][2]))

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
for i in range(N):
  x1=list(map(int,input().split()))
  list1.append(x1)
flag=0
for i in range(101):
  for j in range(101):
    list2=[]
    flag2=0
    for k in range(N):
      Hx=list1[k][2]+abs(list1[k][0]-i)+abs(list1[k][1]-j)
      if Hx-abs(list1[k][0]-i)-abs(list1[k][1]-j)<0:
        flag2=1
      else:
        list2.append(Hx)
    if flag2==1:
      break
    if len(set(list2))==1 and Hx>=1:
      print(i,j,Hx)
      flag=1
    else:
        pass
    if flag==1:
      break
  if flag==1:
    break

Submission status: Wrong Answer

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

M = len(x)
H = [0 for i in range(0,M)]

for X in range(0,101):
    for Y in range(0,101):
        for i in range(0,M):
            H[i] = h[i] + abs(x[i]-X) + abs(y[i]-Y)
        if max(H) == min(H):
            print("{} {} {}".format(X,Y,max(H)))

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xyh = []
for _ in range(n):
    xyh.append(tuple(list(li())))
    

# 中心になりうる点を全探索
def search_cent(xyh: list):
    n = len(xyh)
    for x_cent in range(101):
        for y_cent in range(101):
            
            # 各点と中心との距離
            dist = []
            is_cent = True
            for x,y,_ in xyh:
                dist.append((abs(x-x_cent), abs(y-y_cent)))
                
            # 中心との距離と高さの差に矛盾が無いかチェック
            for i in range(n):
                for j in range(n):
                    if xyh[i][2] - sum(dist[i]) < 0 or xyh[j][2] - sum(dist[j]) < 0:
                        continue
                    
                    if (xyh[i][2]-xyh[j][2]) != -(sum(dist[i]) - sum(dist[j])):
                        is_cent = False
                        break
                if not is_cent:
                    break

            if is_cent:
                return x_cent, y_cent

                
x_cent, y_cent = search_cent(xyh)
h_cent = xyh[0][2] + abs(xyh[0][0] - x_cent) + abs(xyh[0][1] - y_cent)

print(x_cent, y_cent, h_cent)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xi, yi, hi = list(map(int, input().split()))
    x.append(xi)
    y.append(yi)
    h.append(hi)


for cx, cy in itr.product(range(101),range(101)):
    hh = set([])  
    for i in range(n):
        if h[i] > 0:
            hh.add(abs(x[i]-cx)+abs(y[i]-cy)+h[i])
            #print(cx, cy, i, hh)
            if  len(hh) > 1:
                break
        if abs(x[i]-cx)+abs(y[i]-cy) < 1:
            break
    else:
        if len(hh) == 1:
            print(cx, cy, hh.pop())
            break

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = []
for cx in range(101): #Cx 0~100
    for cy in range(101): #Cy 0~100
        h = []
        for i in range(n):
            #x[i], y[i], h[i]のときの高さHを求める（h[i] == 0の場合を除く）
            #H = |x[i] - Cx| + |y[i] - Cy| + h[i]
            if xyh[i][2] != 0:
                h.append(abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2])

        # Hがすべて一致するときのCx, Cyが答えである
        if len(set(h)) == 1:
            ans.append(cx)
            ans.append(cy)
            ans.append(h[0])
            print(ans[0], ans[1], ans[2])

print(ans[0], ans[1], ans[2])

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import Counter

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

x_arr = xyh[:,0]
y_arr = xyh[:,1]
h_arr = xyh[:,2]

res = [0,0,0]
ans_len = 999

for x in range(0,101):
    for y in range(0,101):
        arr = abs(x_arr-x) + abs(y_arr-y) + h_arr
        s = set(arr)
        if len(s) < ans_len:
            ans_len = len(s)
            res = [x,y,arr]
counter = Counter(res[2])
print(res[0], res[1], counter.most_common()[0][0])

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


heights = []
N = getN()
xmax, ymax, xmin, ymin = (-1,0,0), (0,-1,0), (200,0,0), (0,200,0)

for i in range(N):
    data = getlist()
    x,y,h = data[0],data[1],data[2]
    heights.append(data)
    if x > xmax[0]:
        xmax = (x,y,h)
    if x < xmin[0]:
        xmin = (x,y,h)
    if y > ymax[1]:
        ymax = (x,y,h)
    if y < ymin[1]:
        ymin = (x,y,h)
ansx, ansy, ansh = 0,0,0
first = heights[0]
fx,fy,fh = first[0], first[1], first[2]
for x in range(0,101):
    for y in range(0,101):
        flag = 1
        cand_h = fh + abs(fx-x) + abs(fy-y)
        #print(cand_h, x,y)
        for i in range(0,N):
            comp = heights[i]
            if (cand_h - abs(comp[0]-x) - abs(comp[1]-y)) >= 0:
                if (comp[2] + abs(comp[0]-x) + abs(comp[1]-y)) != cand_h:
                    #print("break",x,y)
                    flag = 0

        if flag == 1:
            if cand_h <= 1000000000:
            #print("success", x,y)
                ansx, ansy, ansh = x, y, cand_h
if N == 1:
    print(fx, fy, fh)
else:
    print(ansx,ansy,ansh)

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
for i in range(N):
  x1=list(map(int,input().split()))
  list1.append(x1)
flag=0
flag2=0
for i in range(101):
  for j in range(101):
    list2=[]
    for k in range(N):
      Hx=list1[k][2]+abs(list1[k][0]-i)+abs(list1[k][1]-j)
      if Hx-abs(list1[k][0]-i)-abs(list1[k][1]-j)<0:
        flag2=1
      else:
        list2.append(Hx)
    if flag2==1:
      break
    if len(set(list2))==1 and Hx>=1:
      print(i,j,Hx)
      flag=1
    else:
        pass
    if flag==1:
      break
  if flag==1:
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = []
xyh0 = []
for i in range(0,n):
    X,Y,h = map(int,input().split())
    if h != 0:
        xyh.append((X,Y,h))
    else:
        xyh0.append((X,Y))
ans = []
for i in range(0,101):
    for j in range(0,101):
        flag = "f"
        if len(xyh)>0:
            x,y,h = xyh[0]
            H = h + abs(x-i)+abs(y-j)
            flag = "t"
        for x,y,h in xyh:
            if H !=  h + abs(x-i)+abs(y-j):
                flag = "f"
                break
        if flag == "t":
            ans.append((i,j,H))
if len(ans) > 0:
    for i,j,H in ans:
        for x,y in xyh0:
            if H < h + abs(x-i)+abs(y-j):
                break
        ans = [(i,j,H)]
        if len(ans) == 1:
            break
if len(ans) == 0:
    x = [0 for i in range(0,101)]
    y = [0 for i in range(0,101)]
    for i,j in xyh0:
        x[i] = 1
        y[j] = 1
    for xx in x:
        if xx == 0:
            break
    for yy in y:
        if xx == 0:
            break
    ans = [(xx,yy,1)]
x,y,h = ans[0]
print(x,y,h)













#

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):
        ans = 1
        H = 1
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = abs(x - CX) + abs(y - CY) + h
            if H < 1:
                ans = -1
                break
            #print(CX, CY)
            
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if h != max(H - abs(x - CX) - abs(y - CY), 0):
                ans = -1
                break

        if ans == 1:
            print(CX, CY, H)
            break
    if ans == 1:
        break

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
a = [list(map(int,input().split())) for i in range(N)]

for j in range(101):
    for k in range(101):
        first = a[0][2] + np.abs(a[0][0] - j) + np.abs(a[0][1] - k)
        for i in range(N):
            v = np.abs(a[i][0] - j) + np.abs(a[i][1] - k)
            if first >= v:
                second = a[i][2] + v
            else:
                second = a[i][2]
            if first != second:
                break
        else:
            for i in range(N):
                if  a[i][2] != np.max(first - np.abs(a[i][0] - j) - np.abs(a[i][1] - k), 0):
                    break
            else:
                print("{} {} {}\n".format(j, k, first))

Submission status: Wrong Answer

Solution code:
N = int(input())

info_list = []

def abs(x):
    if x < 0:
        return -x
    else:
        return x

for i in range(N):
    x, y, h = input().split(' ')
    info_list.append([int(x), int(y), int(h)])

def solve():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            flag = True
            H = -1
            for x, y, h in info_list:
                #print(x, y, h)
                if h > 0:
                    if H == -1:
                        H = h + abs(x - Cx) + abs(y - Cy)
                    else:
                        if H != h + abs(x - Cx) + abs(y - Cy):
                            flag = False
                            break
                else:
                    if H != -1:
                        if H < abs(x - Cx) + abs(y - Cy):
                            flag = False
                            break
                    else:
                        if 1 <= abs(x - Cx) + abs(y - Cy):
                            flag = False
                            break

            if flag:
                print(Cx, Cy, H)
                return

solve()

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = []
for cx in range(101): #Cx 0~100
    for cy in range(101): #Cy 0~100
        h = []
        for i in range(n):
            #x[i], y[i], h[i]のときの高さHを求める（h[i] == 0の場合を除く）
            #H = |x[i] - Cx| + |y[i] - Cy| + h[i]
            if xyh[i][2] != 0:
                h.append(abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2])

        # Hがすべて一致するときのCx, Cyが答えである
        if len(set(h)) == 1:
            ans.append(cx)
            ans.append(cy)
            ans.append(h[0])
            print(ans[0], ans[1], ans[2])

Submission status: Wrong Answer

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

N = int(input())

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


ans_list = []
for xi in range(101):
    for yi in range(101):
        H_list = []
        for x,y,h in xyhn:
            if h > 0:
                H = h + abs(x - xi) + abs(y - yi)
                H_list.append(H)

        if min(H_list) == max(H_list):
            ans_list.append([xi,yi,H_list[0]])
            # print("%d %d %d"%(xi,yi,H_list[0]))
            # exit()

ans_list.sort(key=lambda x:x[2])
print("%d %d %d"%(ans_list[-1][0],ans_list[-1][1],ans_list[-1][2]))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
li = [list(map(int,input().split())) for i in range(n)]
h = 0
flag = False
for i in range(101):
    #if flag == True:
        #break
    for j in range(101):
        co = 0
        h = 0
        #if flag == True:
            #break
        for k in li:
            h1 = k[2] + abs(i-k[0]) + abs(j-k[1])
            if co == 0:
                h = h1
            if h != h1:
                break
            co +=1
            if co == n:
                flag = True
                print(str(i)+" "+str(j)+" "+str(h1))

Submission status: Wrong Answer

Solution code:
n = int(input())

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)
    
end = 0
if n >=3:
    for x in range(101):
        for y in range(101):
            H = info[0][2] + abs(x-info[0][0]) + abs(y-info[0][1])
            if H <= 10**9:
                for i in range(1,n):
                    if info[i][2] != H - abs(x-info[i][0]) - abs(y- info[i][1]):
                        break
                else:
                    print(x,y,H)
                    end = 1
                
            if end == 1:
                break
        if end == 1:
            break
elif n ==2:
    info = sorted(info, key = lambda x:x[2])
    if info[0][0] > info[1][0]:
        h = info[1][2] + info[1][0]
        x = 0
    else:
        h = info[1][2] + 100- info[1][0]
        x = 100
    if info[0][1] > info[1][1]:
        h += info[1][1]
        y = 0
    else:
        h += 100 - info[1][1]
        y =100
    ans = list(map(str,(x,y,h)))
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
inp=[]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    if hi==0:
        inp.append([xi,yi,hi])
        pass
    else:
            
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
flag=0
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            flag=1
            print(x,y,xymap[x][y])
if flag==0:
    xymap=[[-1 for j in range(101)] for i in range(101)]
    for i in range(len(inp)):
        xi=inp[i][0]
        yi=inp[i][1]
        hi=inp[i][2]
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
    for x in range(101):
        for y in range(101):
            if xymap[x][y]!=-2:
                print(x,y,xymap[x][y])

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
lx=[];ly=[]
for p in range(n):
  lx.append(l[p][0]+l[p][1])
for q in range(n):
  ly.append(l[q][0]-l[q][1])
if n>=4:
  L=[l[lx.index(min(lx))],l[lx.index(max(lx))],l[ly.index(min(ly))],l[ly.index(max(ly))]]
  for x in range(101):
    for y in range(101):
      if abs(L[0][0]-x)+abs(L[0][1]-y)+L[0][2]==abs(L[1][0]-x)+abs(L[1][1]-y)+L[1][2]==abs(L[2][0]-x)+abs(L[2][1]-y)+L[2][2]==abs(L[3][0]-x)+abs(L[3][1]-y)+L[3][2]:
        print(x,y,abs(L[0][0]-x)+abs(L[0][1]-y)+L[0][2])
elif n>=3:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]==abs(l[2][0]-x)+abs(l[2][1]-y)+l[2][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
else:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])