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())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
            
    try:
        print('{} {} {}'.format(m[0],m[1],m[2]))
        break
    except NameError:
        continue

Submission status: Wrong Answer

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

for Cx in range(101):
    for Cy in range(101):
        ok = True
        candidate_H = set()
        for xi, yi, hi in points:
            dx = abs(Cx - xi)
            dy = abs(Cy - yi)
            H = hi + dx + dy
            if H >= dx + dy:
                candidate_H.add(H)
        if ok and len(candidate_H) == 1:
            print('{} {} {}'.format(Cx, Cy, H))
            exit()

Submission status: Wrong Answer

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

for Cx in range(101):
    for Cy in range(101):
        ok = True
        candidate_H = set()
        for xi, yi, hi in points:
            dx = abs(Cx - xi)
            dy = abs(Cy - yi)
            H = hi + dx + dy
            if H > dx + dy:
                candidate_H.add(H)
        if ok and len(candidate_H) == 1:
            print('{} {} {}'.format(Cx, Cy, H))
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if k!=0:
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    m=(i[0],i[1],l)
            else: break
    try:
        print('{} {} {}'.format(m[0],m[1],m[2]))
        break
    except NameError:
        continue

Submission status: Wrong Answer

Solution code:
N = int(input())
xyz = []
for i in range(N):
    xyz.append(list(map(int, input().split())))
H = 0
h = 0
flag = False
maxz = xyz[0][2]
maxy = xyz[0][1]
maxx = xyz[0][0]
for k in range(N):
    if xyz[k][2] > maxz:
        maxz = xyz[k][2]
        maxx = xyz[k][0]
        maxy = xyz[k][1]
for i in range(101):
    for j in range(101):
        H = maxz + abs(maxx-i) + abs(maxy-j)
        for k in xyz:
            h = H -abs(k[0]-i)-abs(k[1]-j)
            if h < 0:
                h = 0
            if h == k[2]:
                continue
            else:
                break
        if H != 0:
                flag = True
                print("{} {} {}".format(i, j, H))
                break
    if flag:
        break

Submission status: Wrong Answer

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

for Cx in range(101):
    for Cy in range(101):
        ok = True
        candidate_H = set()
        for xi, yi, hi in points:
            H = hi + abs(Cx - xi) + abs(Cy - yi)
            if H <= 0:
                ok = False
                break
            candidate_H.add(H)
        if ok and len(candidate_H) == 1:
            print('{} {} {}'.format(Cx, Cy, H))
            exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
max_x = 0
max_y = 0
max_h = 0
x = []
y = []
h = []

for i in range(N):
    inp = input().split(' ')
    x.append(int(inp[0]))
    y.append(int(inp[1]))
    h.append(int(inp[2]))
    
tmp = 0
for posY in range(101):
    for posX in range(101):
        needH = -1
        for i in range(N):
            if h[i] > 0:
                tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i])
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
        #ダメだったら別の場所を探す
        if needH == -2:
            continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(posY - y[i]) + abs(posX - y[i])
                #高さ0のとき、中心からの距離distは0以下にならなければならない。そうでなければ、次のループを探索。
                if needH > dist:
                    continue
        
        if needH == -2:
            continue
        print(posX, posY, needH)
        break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]
data.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = data[0][0], data[0][1], data[0][2]
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        for i in range(1, n):
            xi, yi, hi = data[i][0], data[i][1], data[i][2]
            if hi == 0:
                continue
            if hi != max(h - abs(xi - cx) + abs(yi - cy), 0):
                break
        else:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
arr = np.array(arr)
x_min  = arr[:,0].min()
x_max = arr[:,0].max()
y_min = arr[:,1].min()
y_max =  arr[:,1].max()
mx = arr[:,2].max()
dx = x_max-x_min
dy = y_max-y_min
s = (max(dx,dy)//2)+1
for k in range(mx+s,mx-1,-1):
    for i in range(x_min,x_max+1):
        for j in range(y_min,y_max+1):
            for x,y,h in arr:
                if(max(k-abs(i-x)-abs(j-y),0)!=h):
                    break
            else:
                print (i,j,k)
                exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]
data.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = data[0][0], data[0][1], data[0][2]
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        for i in range(1, n):
            xi, yi, hi = data[i][0], data[i][1], data[i][2]
            if hi == 0:
                continue
            if h != hi + abs(xi - cx) + abs(yi - cy):
                break
        else:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

points = []
for i in range(0, N):
    xi, yi, hi = map(int, input().split())
    points.append((xi, yi, hi))

for CX in range(101):
    for CY in range(101):
        ok = True
        Hs = set()
        for x, y, h in points:
            x_diff = abs(x - CX)
            y_diff = abs(y - CY)
            H = h + x_diff + y_diff
            if H < x_diff + y_diff and h != 0:
                ok = False
                break
            Hs.add(H)
        if len(Hs) == 1 and ok:
            print('{} {} {}'.format(CX, CY, H))
            exit()

Submission status: Wrong Answer

Solution code:
import math
import sys
n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        hs = {}
        for k in xyh:
            hs[abs(i - k[0]) + abs(j - k[1]) + k[2]] = 1
            if len(hs) > 1:
                break   
        if len(hs) == 1:
            key = list(hs.keys())
            print(str(i) + ' ' + str(j) + ' ' + str(list(hs.keys())[0]))
            sys.exit

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
max_x = 0
max_y = 0
max_h = 0
x = []
y = []
h = []

for i in range(N):
    inp = input().split(' ')
    x.append(int(inp[0]))
    y.append(int(inp[1]))
    h.append(int(inp[2]))
    
tmp = 0
for posY in range(101):
    for posX in range(101):
        needH = -1
        for i in range(N):
            if h[i] > 0:
                tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i])
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
                    
        if needH == -2:continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(posY - y[i]) + abs(posX - y[i])
                if needH > dist:
                    continue
        
        if needH == -2:
            continue
        print(posX, posY, needH)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]
data.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = data[0][0], data[0][1], data[0][2]
        h = h0 + abs(x0 - cx) + abs(y0 - cy)
        for i in range(1, n):
            xi, yi, hi = data[i][0], data[i][1], data[i][2]
            if h != hi + abs(xi - cx) + abs(yi - cy):
                break
        else:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
max_x = 0
max_y = 0
max_h = 0
x = []
y = []
h = []

for i in range(N):
    inp = input().split(' ')
    x.append(int(inp[0]))
    y.append(int(inp[1]))
    h.append(int(inp[2]))
    
tmp = 0
flag = True
for posY in range(101):
    for posX in range(101):
        needH = -1
        for i in range(N):
            if h[i] > 0:
                tmp = h[i] + abs(posY - y[i]) + abs(posX - x[i])
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
                    
        if needH == -2:continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(posY - y[i]) + abs(posX - y[i])
                if needH > dist:
                    continue
        
        if needH == -2:
            continue
        print(posY, posX, needH)

Submission status: Wrong Answer

Solution code:
N = int(input())

points = [[int(s) for s in input().split()] for i in range(0, N)]

for Cx in range(101):
    for Cy in range(101):
        H_set = set()
        for xi, yi, hi in points:
            H = hi + abs(xi - Cx) + abs(yi - Cy)
            H_set.add(H)
        if len(H_set) == 1:
            print('{} {} {}'.format(Cx, Cy, H))
            exit()

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
L = []
for i in range(N):
    A = list(map(int, input().split()))
    t = A[0], A[1], A[2]
    L.append(t)

tmp_list = []
for i in L:
    input_x = i[0]
    input_y = i[1]
    input_h = i[2]

    for x in range(101):
        for y in range(101):
            tmp = [x, y, (abs(input_x - x) + abs(input_y - y) + input_h)]
            tmp_list.append(tmp)

#print(tmp_list)
c = Counter(tuple(x) for x in tmp_list)
#print(c)

for l, cnt in c.most_common():
    if cnt > 1:
        print(l[0], l[1], l[2])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]
data.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = data[0][0], data[0][1], data[0][2]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for i in range(1, n):
            xi, yi, hi = data[i][0], data[i][1], data[i][2]
            if h != hi + abs(cx - xi) + abs(cy - yi):
                break
        else:
            print(cx, cy, h)

Submission status: Wrong Answer

Solution code:
from itertools import product

N = int(input())

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

for px, py in product(range(100 + 1), repeat=2):
    #print('px: {}, py: {}'.format(px, py))
    Hs = []
    for x, y, h in xyhs:
        H = abs(x - px) + abs(y - py) + h
        Hs.append(H)
    if len(set(Hs)) == 1:
        print('{} {} {}'.format(px, py, Hs[0]))
        break

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

n = int(input())
data = [[int(j) for j in input().split()] for i in range(n)]
data.sort(key=lambda x: x[2])

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = data[0][0], data[0][1], data[0][2]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        for i in range(1, n):
            xi, yi, hi = data[i][0], data[i][1], data[i][2]
            if h != hi + abs(cx - xi) + abs(cy - yi):
                break
        else:
            print(cx, cy, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

points = [[int(s) for s in input().split()] for i in range(0, N)]

for Cx in range(101):
    for Cy in range(101):
        H_set = set()
        for X, Y, h_xy in points:
            H = h_xy + abs(X - Cx) + abs(Y - Cy)
            H_set.add(H)
        if len(H_set) == 1:
            ok = True
            for X, Y, h1 in points:
                h2 = max(H - abs(X - Cx) - abs(Y - Cy), 0)
                if h1 != h2:
                    ok = False
                    break
            if ok:
                print('{} {} {}'.format(Cx, Cy, H))
                exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == "__main__":
    N = int(input())
    inf = []
    list = input().split(" ")
    x = int(list[0])
    y = int(list[1])
    h = int(list[2])
    for i in range(101):
        for j in range(101):
            H = h + abs(x-i) + abs(y-j)
            if H >= 1:
                inf.append([i,j,H])
    for i in range(N-1):
        list = input().split(" ")
        x = int(list[0])
        y = int(list[1])
        h = int(list[2])
        list.clear()
        for j in range(len(inf)):
            if h == inf[j][2] - abs(x-inf[j][0]) - abs(y-inf[j][1]):
                list.append(inf[j])
        inf = list
        if len(inf) == 1:
            print(inf[0][0],inf[0][1],inf[0][2])
            exit()

Submission status: Wrong Answer

Solution code:
import sys
N = input()
x = []
y = []
h = []
for i in range(N):
	_x, _y, _h = map(int, raw_input().split())
	x.append(_x)
	y.append(_y)
	h.append(_h)

for _x in range(101):
	for _y in range(101):
		candH = -1
		for i in range(N):
			if h[i] > 0:
				tmp = h[i] + abs(x[i] - _x) + abs(y[i] - _y)
				if candH == -1:
					candH = tmp
				elif candH == tmp:
					continue
				else:
					candH = -2
					break
		if candH == -2:
			continue
		for i in range(N):
			if h[i] == 0:
				tmp = h[i] + abs(x[i] - _x) + abs(y[i] - _y)
				if tmp > 0:
					candH = -2
					break
					
		if candH == -2:
			continue
		print _x, _y, candH
		sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2], reverse=True)
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h and abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
arr = np.array(arr)
x_min  = arr[:,0].min()
x_max = arr[:,0].max()
y_min = arr[:,1].min()
y_max =  arr[:,1].max()
mx = arr[:,2].max()
for i in range(x_min,x_max+1):
    for j in range(y_min,y_max+1):
        for k in range(mx,mx+9):
            for x,y,h in arr:

                if(max(k-abs(i-x)-abs(j-y),0)!=h):
                    break
            else:
                print (i,j,k)
                exit()

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([]) 
    ok = 0
    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:
                ok = -1
                break
    if ok != -1:
        if len(hh) == 0:
            continue
        else:
            hres = hh.pop()
            for i in range(n):           
                if abs(x[i]-cx)+abs(y[i]-cy) <= hres:
                    continue
                else:
                    ok = -1
                    break
    if ok == 0:
        break
print(cx, cy, hres)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
def c_pyramid(N, Pos):
    from itertools import product
    # 中心座標を全探索
    for cx, cy in product(range(101), repeat=2):
        height = set()
        for x, y, h in Pos:
            if h == 0:
                continue
            height.add(h + abs(cx - x) + abs(cy - y))
        if len(height) == 1:
            ans = (cx, cy, list(height)[0])
            break
    ans = '{0} {1} {2}'.format(*ans)
    return ans

N = int(input())
Pos = [[int(i) for i in input().split()] for j in range(N)]
print(c_pyramid(N, Pos))

Submission status: Wrong Answer

Solution code:
n = int(input())

# maxH - |Cx - x| - |Cy - y| = H
# maxH = H + |Cx - x| + |Cy - y|

xyh = []
for i in range(n):
    px, py, h = list(map(int, input().split()))
    d = {
        'px': px,
        'py': py,
        'h': h
    }
    xyh.append(d)

# 高さ0でない情報を探す
xyh_tmp = {}
for d in xyh:
    if d['h'] >= 1:
        xyh_tmp = d
        break

# 全座標を探索
for cx in range(101):
    for cy in range(101):
        # 仮決めした中心座標で頂点の高さを出す
        max_h = (
            abs(xyh_tmp['px'] - cx) + abs(xyh_tmp['py'] - cy) + xyh_tmp['h']
        )
        # 全ての条件で適切かチェック
        is_ok = True
        for d in xyh:
            if d['h'] != max(
                (max_h - abs(d['px'] - cx) - abs(d['py'] - cy)), 0
            ):
                is_ok = True
                break
        if is_ok:
            print(cx, cy, max_h)

Submission status: Wrong Answer

Solution code:
n = int(input())

# maxH - |Cx - x| - |Cy - y| = H
# maxH = H + |Cx - x| + |Cy - y|

xyh = []
for i in range(n):
    px, py, h = list(map(int, input().split()))
    d = {
        'px': px,
        'py': py,
        'h': h
    }
    xyh.append(d)

# 高さ0でない情報を探す
for d in xyh:
    if d['h'] >= 1:
        xyh_tmp = d
        break

# 全座標を探索
for cx in range(101):
    for cy in range(101):
        # 仮決めした中心座標で頂点の高さを出す
        max_h = (
            abs(xyh_tmp['px'] - cx) + abs(xyh_tmp['py'] - cy) + xyh_tmp['h']
        )
        # 全ての条件で適切かチェック
        is_ok = True
        for d in xyh:
            if d['h'] != max(
                (max_h - abs(d['px'] - cx) - abs(d['py'] - cy)), 0
            ):
                is_ok = True
                break
        if is_ok:
            print(cx, cy, max_h)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

H = []
xy = []
first = True

for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        if h == 0:
            continue
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        if h == 0:
            continue
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        xy = tmpxy
        H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())

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

H = []
xy = []
first = True

for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        if h == 0:
            continue
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        xy = tmpxy
        H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())

X = []
Y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())

    if c > 0:
        p = i
    X.append(a)
    Y.append(b)
    h.append(c)

for Cx in range(101):
    for Cy in range(101):
        works = True
        H = h[p] + abs(X[p] - Cx) + abs(Y[p] - Cy)
        for i in range(N):

            if h[i] != max(H - abs(X[p] - Cx) - abs(Y[p] - Cy), 0):
                works = False
                break
        
        if works:
            print(Cx,Cy,H)
            quit()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
arr = np.array(arr)
x_min  = arr[:,0].min()
x_max = arr[:,0].max()
y_min = arr[:,1].min()
y_max =  arr[:,1].max()
mx = arr[:,1:].max()
for i in range(x_min,x_max+1):
    for j in range(y_min,y_max+1):
        for k in range(mx,mx+199):
            for ls in arr:
                if(max(k-abs(i-ls[0])-abs(j-ls[1]),0)!=ls[2]):
                    break
            else:
                print (i,j,k)
                exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for j in range(101):
    for k in range(101):
        can = True
        needH = a[0][2] + np.abs(a[0][0] - j) + np.abs(a[0][1] - k)
        for i in range(N):
            if a[i][2] > 0:
                if  a[i][2] != needH - np.abs(a[i][0] - j) - np.abs(a[i][1] - k):
                    can = False
                    break
        if can == False:
            continue
        for i in range(N):
            if a[i][2] == 0:
                if  needH > np.abs(a[i][0] - j) - np.abs(a[i][1] - k):
                    can = False
                    break
        if can:
            print("{} {} {}\n".format(j, k, needH))

Submission status: Wrong Answer

Solution code:
N = int(input())
Q = [0]*N
H=0
for j in range(N):
    Q[j] = [ int(i) for i in input().split()]

for x in range(101):
    for y in range(101):
        h_kouho = {-1}
        for i in range(N):
            if  Q[i][2] != 0:
                H1 = Q[i][2] + abs(Q[i][0]- x) + abs(Q[i][1] - y)
                if h_kouho =={-1}:
                    h_kouho = {H1}
                else:
                    h_kouho = h_kouho & {H1}
            else:
                continue
        if h_kouho != set() :
            print(x,y,max(h_kouho))
            break
        else:
            continue

Submission status: Wrong Answer

Solution code:
import sys


n = int(input())
l = [[int(i) for i in input().split()] for j in range(n)]


for i in range(0, 101):
    for j in range(0, 101):
        c = 0
        dict = {}
        for k in range(n):
            if l[k][2] != 0:
                h = l[k][2] + abs(i - l[k][0]) + abs(j - l[k][1])
                c += 1
                if h in dict:
                    dict[h] += 1
                else:
                    dict[h] = 1
        if dict[h] == c:
            if l[k][2] == 0:
                h = l[k][2] + abs(i - l[k][0]) + abs(j - l[k][1])
                if h in dict:
                    dict[h] += 1
                else:
                    dict[h] = 1
            H = max(dict.items(),key = lambda x:x[1])[0]
            print(i, j, H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
 
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
x = np.array([xyh[i][0] for i in range(N)])
y = np.array([xyh[i][1] for i in range(N)])
h = np.array([xyh[i][2] for i in range(N)])
x_ = x[h != 0]
y_ = y[h != 0]
h_ = h[h != 0]
for Cx in range(101):
    for Cy in range(101):
        H = h_ + np.array(list(map(abs, [xi - Cx for xi in x_]))) + np.array(list(map(abs, [yi - Cy for yi in y_])))
        flag1 = False
        flag2 = False
        flag3 = False
        if len(set(H)) == 1:
            flag1 = True
        if flag1 and not list(h[list(np.logical_and([x==Cx],[y==Cy]))]):
            flag2 = True
        if flag1 and not flag2 and list(set(H)) == h[list(np.logical_and([x==Cx],[y==Cy]))]:
            flag3 = True
        if flag2 or flag3:
            break
    else:
        continue
    break
H = list(set(H))
print("{} {} {}".format(Cx, Cy, H[0]))

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for _ in range(N):
    xx,yy,hh = map(int,input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
cm = 100
def dist(cx,cy,x,y):
    return(abs(cx-x)+abs(cy-y))
for cx in range(cm+1):
    for cy in range(cm+1):
        H = -1
        Hm = 10000000000
        contra = False
        for i in range(N):
            Hi = h[i] + dist(cx,cy,x[i],y[i])
            if h[i] == 0:
                Hm = min(Hi,Hm)
                if H != -1 and H < Hm:
                    contra = True
            else:
                if Hi > Hm:
                    contra = True
                else:
                    Hm = min(Hm,Hi)
                    if H == -1:
                        H = Hi
                    else:
                        if H!=Hi:
                            contra = True
        if contra == False:
            print(cx,cy,H)                
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
import itertools

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)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n):
            if max(H[0] - abs(x[j] - cx) - abs(y[j] - cy), 0) != h[j]:
                continue
        break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Wrong Answer

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

hlist = []
argx = []
argy = []
for k in range(N):
    tmplist = []
    tmpx = []
    tmpy = []
    for i in range(101):
        for j in range(101):
            tmplist.append(max(h[k] +abs( x[k] - i ) + abs (y[k] - j ),0))
            tmpx.append(i)
            tmpy.append(j)

    hlist.append(tmplist)
    argx.append(tmpx)
    argy.append(tmpy)

m = 0
xxx = -1
yyy = -1
for i in range(10201):
        lis = []
        for k in range(N):
            lis.append(hlist[k][i])
        if lis.count(hlist[k][i]) == N:
            if m < hlist[k][i]:
                m = hlist[k][i]
                xxx = argx[k][i]
                yyy = argy[k][i]

print(xxx,yyy,m,sep=" ")