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())
xs = []
for i in range(n):
    x,y,h = list(map(int,input().split()))
    xs.append((x,y,h))

#print(xs)
ans = True
htop = -1
for i in range(101):
    for j in range(101):
        htop = -1
        ans = True
        #print("----", i,j)
        for k in range(n):
            x,y,h = xs[k]
            #print(x,y,h,htop,h+abs(x-i)+abs(y-i))
            if h == 0:
                continue
            if htop == -1:
                htop = h + abs(x-i) + abs(y-j)
            if htop > 0 and htop != h + abs(x-i) + abs(y-j):
                ans = False
                break
            #print(htop,  h+abs(x-i) + abs(y-j), x,y,h)
        if ans:
            break
    if ans:
        break
print(i,j,htop)

Submission status: Wrong Answer

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

#print(xs)
ans = True
htop = -1
for i in range(101):
    for j in range(101):
        htop = -1
        ans = True
        #print("----", i,j)
        for k in range(n):
            x,y,h = xs[k]
            #print(x,y,h,htop,h+abs(x-i)+abs(y-i))
            if h == 0:
                continue
            if htop == -1:
                htop = h + abs(x-i) + abs(y-j)
            if htop != h + abs(x-i) + abs(y-j):
                ans = False
                break
            #print(htop,  h+abs(x-i) + abs(y-j), x,y,h)
        if ans:
            break
    if ans:
        break
print(i,j,htop)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    X,Y,H=[0]*n,[0]*n,[0]*n
    for i in range(n):
        X[i],Y[i],H[i]=map(int,input().split())

    def check(x0,y0):
        h=H[-1]+abs(X[-1]-x0)+abs(Y[-1]-y0) # 最後の条件から h をfix
        # この h に対して、残りが整合しているかcheck
        for i in range(n-1):
            if(H[i]!=max(0,h-abs(X[i]-x0)-abs(Y[i]-y0))):
                return False
        return x0,y0,h

    from itertools import product
    for x0,y0 in product(range(101),repeat=2):
        A=check(x0,y0)
        if(A):
            print(*A)
            return
resolve()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        ch = []
        z = []
        for x, y, h in l:
            if h == 0: z.append((x, y))
            else: ch.append(abs(x - j) + abs(y - i) + h)
        if len(set(ch)) == 1:
            for x, y in z:
                if h - abs(j - x) - abs(i - y) > 0: break
            else:
                print(j, i, ch[0])
                exit()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        ch = []
        for x, y, h in l:
            if h != 0: ch.append(abs(x - j) + abs(y - i) + h)
        if len(set(ch)) == 1:
            print(j, i, ch[0])
            exit()

Submission status: Wrong Answer

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

for i in range(101):
    for j in range(101):
        ch = [0] * n
        for k, (x, y, h) in enumerate(l):
            ch[k] = abs(x - j) + abs(y - i) + h
        if len(set(ch)) == 1:
            print(j, i, ch[0])
            exit()

Submission status: Wrong Answer

Solution code:
from collections import deque
import numpy as np

vect = ((-1, 0), (0, -1), (1, 0), (0, 1))
s = 201
t = s//2
field = np.full((s, s), -1)
field[t][t] = s-1
q =  deque([(t, t)])

while q:
    y, x = q.popleft()
    for dy, dx in vect:
        ny, nx = y + dy, x + dx
        if ny < 0 or ny >= s or nx < 0 or nx >= s or field[ny][nx] != -1: continue
        field[ny][nx] = field[y][x] - 1
        q.append((ny, nx))

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

for i in range(s-t):
    for j in range(s-t):
        f = field[i:t+1+i, j:t+1+j]
        diff = [0] * n
        for k, (x, y, h) in enumerate(l):
            diff[k] = h - f[y][x]
        if len(set(diff)) == 1:
            print(t-j, t-i, int(s-1 + diff[0]))
            exit()

Submission status: Wrong Answer

Solution code:
from collections import deque
import numpy as np

vect = ((-1, 0), (0, -1), (1, 0), (0, 1))
s = 201
t = s//2
field = np.full((s, s), -1)
field[t][t] = s-1
q =  deque([(t, t)])

while q:
    y, x = q.popleft()
    for dy, dx in vect:
        ny, nx = y + dy, x + dx
        if ny < 0 or ny >= s or nx < 0 or nx >= s or field[ny][nx] != -1: continue
        field[ny][nx] = field[y][x] - 1
        q.append((ny, nx))

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

for i in range(s-t):
    for j in range(s-t):
        f = field[i:t+1+i, j:t+1+j]
        diff = None
        for x, y, h in l:
            d = h - f[y][x]
            if diff == None: diff = d
            elif d != diff: break
        else:
            print(t - j, t - i, int(s-1 + diff))
            exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

xyh = []
minh = 0

for i in range(N):

    x,y,h = map(int,input().split())
    xyh.append([x,y,h])
    minh = max(minh,h)


for cx in range(101):

    for cy in range(101):

        for ch in range(201):

            flag = True
            ch += minh 

            for i in range(N):

                if xyh[i][2] == 0 and ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -cy) > 0:
                    flag = False
                    break

                elif ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -cy) != xyh[i][2]:
                    flag = False
                    break

            if flag:
                print (cx,cy,ch)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

xyh = []
minh = 0

for i in range(N):

    x,y,h = map(int,input().split())
    xyh.append([x,y,h])
    minh = max(minh,h)


for cx in range(101):

    for cy in range(101):

        for ch in range(101):

            flag = True
            ch += minh 

            for i in range(N):

                if xyh[i][2] == 0 and ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -cy) > 0:
                    flag = False
                    break

                elif ch - abs(xyh[i][0] - cx) - abs(xyh[i][1] -cy) != xyh[i][2]:
                    flag = False
                    break

            if flag:
                print (cx,cy,ch)
                sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xs = []
ys = []
hs = []
for i in range(N):
	x, y, h = map(int, input().split())
	xs.append(x)
	ys.append(y)
	hs.append(h)
for cx in range(101):
	for cy in range(101):
		h = 0
		for i in range(N):
			if hs[i] > 0:
				h = hs[i] + abs(cx - xs[i]) + abs(cy - ys[i])
				break
		ok = True
		for i in range(N):
			if h - abs(cx - xs[i]) - abs(cy - ys[i]) != hs[i]:
				ok = False
				break
		if ok:
			print(cx, cy, h)
			exit(0)

Submission status: Wrong Answer

Solution code:
xyh = []
n = int(input())
for i in range(n):
	x, y, h = map(int, input().split())
	if h != 0:
		xyh.append([x, y, h])

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		h = []
		for k in range(len(xyh)):
			h.append(xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy))
		if len(h) == 1:
			lst = [cx, cy, h[k]]
			lst = [str(i) for i in lst]
			print(" ".join(lst))
			exit(0)
		for k in range(len(h)-1):
			if h[k] != h[k+1]:
				break
			if k == len(h)-2:
				lst = [cx, cy, h[k]]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)

Submission status: Wrong Answer

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

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		h = []
		for k in range(n):
			h.append(xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy))
		for k in range(len(h)-1):
			if h[k] != h[k+1]:
				break
			if k == len(h)-2:
				lst = [cx, cy, h[k]]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)

Submission status: Wrong Answer

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

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		h = []
		lim = 1000000000
		for k in range(n):
			if xyh[k][2] != 0:
				h.append(xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy))
			else:
				lim = min(lim, abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy))
		for k in range(len(h)-1):
			if h[k] != h[k+1]:
				break
			if k == len(h)-2 and h[k] <= lim:
				lst = [cx, cy, h[k]]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)

Submission status: Wrong Answer

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

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		h = []
		for k in range(n):
			if xyh[k][2] != 0:
				h.append(xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy))
		for k in range(len(h)-1):
			if h[k] != h[k+1]:
				break
			if k == len(h)-2:
				lst = [cx, cy, h[k]]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)

Submission status: Wrong Answer

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

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		fi = 0
		for k in range(n):
			if fi == 0 and xyh[k][2] != 0:
				H = xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy)
				fi = 1
			elif xyh[k][2] != 0:
				hh = xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy)
				if H != hh:
					judge = 1
			if judge == 1:
				judge = 0
				break
			if fi != 0 and k == n-1:
				lst = [cx, cy, H]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)

Submission status: Wrong Answer

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

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		for k in range(n):
			if k == 0:
				H = xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy)
			elif xyh[k][2] != 0:
				hh = xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy)
				if H != hh:
					judge = 1
			if judge == 1:
				judge = 0
				break
			if k == n-1:
				lst = [cx, cy, H]
				lst = [str(i) for i in lst]
				print(" ".join(lst))
				exit(0)

Submission status: Wrong Answer

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

judge = 0
for i in range(101):
	cx = i
	for j in range(101):
		cy = j
		for k in range(n):
			if k == 0:
				H = xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy)
			elif xyh[k][2] != 0:
				hh = xyh[k][2] + abs(xyh[k][0]-cx) + abs(xyh[k][1]-cy)
				if H != hh:
					judge = 2
				elif k == n-1:
					judge = 1
			if judge == 2:
				judge = 0
				break
			elif judge == 1:
				break
		if judge == 1:
			break
	if judge == 1:
		break
lst = [cx, cy, H]
lst = [str(i) for i in lst]
print(" ".join(lst))

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
data = [[int(str) for str in input().strip().split()] for _ in range(N)]

data.sort(key=lambda x: x[2], reverse=True)

for cx in range(101):
    for cy in range(101):
        H = set()
        flag = True
        for x, y, h in data:
            if h == 0 and max(H) > abs(x - cx) + abs(y - cy):
                flag = False
                break
            H.add(abs(x - cx) + abs(y - cy) + h)
        
        if flag and len(H) == 1:
            print(cx, cy, H.pop())
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
data = [[int(str) for str in input().strip().split()] for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        Hs = set()
        flag = True
        for x, y, h in data:
            H = abs(x - cx) + abs(y - cy) + h
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                Hs.add(H)
            else:
                flag = False
                break
        
        if flag and (len(Hs) == 1):
            print(cx, cy, Hs.pop())
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
datas = [[int(str) for str in input().strip().split()] for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        H = set()
        for data in datas:
            if data[2] == 0:
                continue
            H.add(abs(data[0] - cx) + abs(data[1] - cy) + data[2])
        
        if len(H) == 1:
            print(cx, cy, H.pop())
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
datas = [[int(str) for str in input().strip().split()] for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        H = set()
        for data in datas:
            H.add(abs(data[0] - cx) + abs(data[1] - cy) + data[2])
        
        if len(H) == 1:
            print(cx, cy, H.pop())
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]
ans = -1
for i in range(101):
    for j in range(101):
        x0, y0, h0 = XYH[0]
        H = h0 + abs(i - x0) + abs(j - y0)
        if (H > 0):
            isTop = all([H == h + abs(i - x) + abs(j - y) for x,y,h in XYH[1:]])
            if (isTop):
                print(i, j, H)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]
ans = -1
for i in range(101):
    for j in range(101):
        x0, y0, h0 = XYH[0]
        H = h0 + abs(i - x0) + abs(j - y0)
        if (H <= 0): continue
        isTop = all([H == h + abs(i - x) + abs(j - y) for x,y,h in XYH])
        if (isTop):
            print(i, j, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

p = points[0][0]
q = points[0][1]
r = points[0][2]

points.sort(key=lambda x: x[2], reverse = True)

for i in range(0,101):
  for j in range(0,101):
    H= r + abs(p - i) + abs(q - j)
    for x,y,z in points:
      if z != max(H - abs(x - i) - abs(y - j),0):
        break
    else:
      print(i,j,H)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

p = points[0][0]
q = points[0][1]
r = points[0][2]

points.sort(key=lambda x: x[2], reverse = True)

for i in range(0,101):
  for j in range(0,101):
    H = abs(p - i) + abs(q - j) + r
    for x,y,z in points:
      if z == max(H - abs(x - i) - abs(y - j),0):
        continue
      else:
        break
    else:print(i,j,H)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

p = points[0][0]
q = points[0][1]
r = points[0][2]

points.sort(key=lambda x: x[2], reverse = True)

for i in range(0,101):
  for j in range(0,101):
    H = abs(p - i) + abs(q - j) + r
    for x,y,z in points:
      if z != max(H - abs(x - i) - abs(y - j),0):
        break
    else:print(i,j,H)

Submission status: Wrong Answer

Solution code:
N = int(input())

points = [list(map(int, input().split())) for _ in range(N)]
    
p = points[0][0]
q = points[0][1]
r = points[0][2]

points.sort(key=lambda x: x[2], reverse=True)

for cx in range(0,101):
  for cy in range(0,101):
    h = points[0][2] + abs(points[0][0] - cx) + abs(points[0][1] - cy)
    for x,y,z in points:
      if z == max(z - abs(cx - x) - (cy - y),0):
        continue
      else:break
    else:
      print(cx,cy,h)

Submission status: Wrong Answer

Solution code:
N = int(input()) 
  
grid = []
p, q, r = (0, 0, 0)
for _ in range(N):
    (x, y, z) = map(int, input().split())
    grid.append([x, y, z])
    if N:
        p = x
        q = y
        r = z
 
 
for cx in range(101):
    for cy in range(101):
        h = r + abs(p - cx) + abs(q - cy)
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print("{} {} {}".format(cx, cy, h))
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input()) 
  
grid = []
p, q, r = (0, 0, 0)
for _ in range(N):
    (l, m, n) = map(int, input().split())
    grid.append([l, m, n])
    if N:
        p = l
        q = m
        r = n
 
 
for cx in range(101):
    for cy in range(101):
        h = r + abs(p - cx) + abs(q - cy)
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print("{} {} {}".format(cx, cy, h))
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
grid = []
p,q,r = (0,0,0)

for _ in range(N):
    (l,m,n) = map(int, input().split())
    grid.append([l, m, n])
    if N:
      p = l
      q = m
      r = n


#101*101通りのため、中心座標cx,cyについて全探索を行う 
for cx in range(101):
    for cy in range(101):
        #各cs,cyについての座標の高さを求める
        h = r + abs(p - cx) + abs(q - cy)
        #標準入力から与えられた座標の値を順に代入していき、
        #条件を満たすcx,cyの組み合わせに当たれば出力する
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print("{} {} {}".format(cx, cy, h))
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
grid = []
p,q,r = (0,0,0)

for _ in range(N):
    l,m,n = map(int, input().split())
    grid.append([l, m, n])
    if N:
      p = l
      q = m
      r = n


#101*101通りのため、中心座標cx,cyについて全探索を行う 
for cx in range(101):
    for cy in range(101):
        #各cs,cyについての座標の高さを求める
        h = r + abs(p - cx) + abs(q - cy)
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print("{} {} {}".format(cx, cy, h))
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
grid = []
p,q,r = (0,0,0)

for _ in range(N):
    l,m,n = map(int, input().split())
    grid.append([l, m, n])
    if N:
      p = l
      q = m
      r = n

flag = 0

#101*101通りのため、中心座標cx,cyについて全探索を行う 
for cx in range(101):
    for cy in range(101):
        #各cs,cyについて座標の高さを求める
        h = r + abs(p - cx) + abs(q - cy)
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print(cx,cy,h)
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
grid = []
p,q,r = (0,0,0)

for _ in range(N):
    l,m,n = map(int, input().split())
    grid.append([l, m, n])
    if N:
      p = l
      q = m
      r = n

flag = 0

#101*101通りのため、中心座標cx,cyについて全探索を行う 
for cx in range(101):
    for cy in range(101):
        h = r + abs(p - cx) + abs(q - cy)
        #各座標の高さを求める
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print(cx,cy,h)
            flag = 1
            break
    if flag == 1:
      break

Submission status: Wrong Answer

Solution code:
N = int(input())
 
grid = []
p,q,r = (0,0,0)

for _ in range(N):
    l,m,n = map(int, input().split())
    grid.append([l, m, n])
    p = l
    q = m
    r = n

flag = 0
 
for cx in range(101):
    for cy in range(101):
        h = r + abs(p - cx) + abs(q - cy)
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print(cx,cy,h)
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
grid = []
p,q,r = (0,0,0)

for _ in range(N):
    l,m,n = map(int, input().split())
    grid.append([l, m, n])
    p = l
    q = m
    r = n

flag = 0
 
for cx in range(101):
    for cy in range(101):
        h = r + abs(p - cx) + abs(q - cy)
        if all(c == max(h - abs(a - cx) - abs(b - cy), 0) for a, b, c in grid):
            print(cx,cy,h)
            flag = 1
            break
    if flag == 1:
      break

Submission status: Wrong Answer

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

#Cx,Cyそれぞれ101個ずつ(計10201通り)
#全探索して、全部満たすHを特定ｗ
for Cx in range(101):
  for Cy in range(101):
    H=None
    flag=True
    for i in range(n):
      if li[i][2]<0:
        continue
      elif H==None:
        H=abs(li[i][0]-Cx)+abs(li[i][1]-Cy)+li[i][2]
      elif H!=abs(li[i][0]-Cx)+abs(li[i][1]-Cy)+li[i][2]:
        flag=False #Hが矛盾する場合は、このCxCyの組み合わせは否定される
        break
      else: #Hが同一の場合は、次の組以降も条件に一致するか調べる
        continue
    if flag==False:
      continue
    elif H==None:
      print(Cx,Cy,1)
      exit()
    else: #Hが全て条件を満たす場合は、それが解
      print(Cx,Cy,H)
      exit()

#座標が0の時の条件も利用してHを絞らなければならない疑惑。。
#(上のコードだと、入力例のようなものはACできてるが、全部0の時に条件を絞る事ができない…)

Submission status: Wrong Answer

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

#Cx,Cyそれぞれ100個ずつ(計10000通り)
#全探索して、全部満たすHを特定ｗ
for Cx in range(101):
  for Cy in range(101):
    H=None
    flag=True
    for i in range(n):
      if li[i][2]<0:
        continue
      elif H==None:
        H=abs(li[i][0]-Cx)+abs(li[i][1]-Cy)+li[i][2]
      elif H!=abs(li[i][0]-Cx)+abs(li[i][1]-Cy)+li[i][2]:
        flag=False #Hが矛盾する場合は、このCxCyの組み合わせは否定される
        break
      else: #Hが同一の場合は、次の組以降も条件に一致するか調べる
        continue
    if flag==False:
      continue
    else: #Hが全て条件を満たす場合は、それが解
      print(Cx,Cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

h = []

for i in range(n):
    h.append(list(map(int,input().split())))

ans = -1

for x in range(101):
    for y in range(101):
        ans = [abs(i[0]-x) + abs(i[1]-y) + i[2] for i in h]
        
        if len(set(ans)) == 1 and ans[0]>0:
            break
    if len(set(ans)) == 1 and ans[0]>0:
        break

print(x,y,ans[0])

Submission status: Wrong Answer

Solution code:
n = int(input())

h = []

for i in range(n):
    h.append(list(map(int,input().split())))

ans = -1

for x in range(101):
    for y in range(101):
        ans = [abs(i[0]-x) + abs(i[1]-y) + i[2] for i in h]
        
        if len(set(ans)) == 1 and ans[0]>0:
            break
    if len(set(ans)) == 1:
        break

print(x,y,ans[0])

Submission status: Wrong Answer

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

n = int(input())

h = []

for i in range(n):
    h.append(list(map(int,input().split())))

ans = -1

for x in range(101):
    for y in range(101):
        ans = [abs(i[0]-x) + abs(i[1]-y) + i[2] for i in h]
        
        if len(set(ans)) == 1:
            break
    if len(set(ans)) == 1:
        break

print(x,y,ans[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
global flag
flag = 0
for cx in range(101):
  for cy in range(101):
    ch_arr = []
    cnt = 0
    for x,y,h in arr:
      if h != 0:
      	ch = h + abs(x-cx) + abs(y-cy)
      	ch_arr.append(ch)
      	if cnt > 0:
          if ch_arr[-2] != ch_arr[-1]:
          	break
          cnt += 1
    if len(set(ch_arr))==1:
      flag = 1
      break
  if flag:
    break

print(cx,cy,ch)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
global flag
flag = 0
for cx in range(101):
  for cy in range(101):
    ch_arr = []
    cnt = 0
    for x,y,h in arr:
      if h != 0:
      	ch = h + abs(x-cx) + abs(y-cy)
      	ch_arr.append(ch)
      	if cnt > 0:
          if ch_arr[-2] != ch_arr[-1]:
          	break
    if (len(set(ch_arr))==1)&(list(set(ch_arr))[0] != 0):
      flag = 1
      break
  if flag:
    break

print(cx,cy,ch)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
global flag
flag = 0
for cx in range(101):
  for cy in range(101):
    ch_arr = []
    cnt = 0
    for x,y,h in arr:
      ch = h + abs(x-cx) + abs(y-cy)
      ch_arr.append(ch)
      if cnt > 0:
        if ch_arr[-2] != ch_arr[-1]:
          break
    if (len(set(ch_arr))==1)&(list(set(ch_arr))[0] > 0):
      flag = 1
      break
  if flag:
    break

print(cx,cy,ch)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
global flag
flag = 0
for cx in range(101):
  for cy in range(101):
    ch_arr = []
    cnt = 0
    for x,y,h in arr:
      ch = h + abs(x-cx) + abs(y-cy)
      ch_arr.append(ch)
      if cnt > 0:
        if ch_arr[-2] != ch_arr[-1]:
          break
    if (len(set(ch_arr))==1)&(list(set(ch_arr))[0] != 0):
      flag = 1
      break
  if flag:
    break

print(cx,cy,ch)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = [list(map(int,input().split())) for _ in range(N)]
global flag
flag = 0
for cx in range(101):
  for cy in range(101):
    ch_arr = []
    cnt = 0
    for x,y,h in arr:
      ch = h + abs(x-cx) + abs(y-cy)
      ch_arr.append(ch)
      if cnt > 0:
        if ch_arr[-2] != ch_arr[-1]:
          break
    if len(set(ch_arr))==1:
      flag = 1
      break
  if flag:
    break

print(cx,cy,ch)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

flag = False    
while True:
    for i in range(101):
        for j in range(101):
            count = 0
            for k in range(min(N, 4)):
                if xyh[k][2] == max(max_h - abs(xyh[k][0] - i) - abs(xyh[k][1] - j), 0):
                    count += 1
            if count == min(N, 4):
                cx = i
                cy = j
                H = max_h
                flag = True
                break
        if flag == True:
            break
            
    max_h += 1
    if flag == True:
        break

print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
x = []
y = []
h = []
for i in range(N):
    x1,y1,h1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    h.append(h1)

for cx in range (0,101):
  for cy in range (0,101):
    ans = 1
    m = 0
  
    for i in range (0,N):
      if h[i] != 0:
        m = h[i] + np.abs(x[i]-cx) + np.abs(y[i]-cy)
        break
    for k in range (0,N):
      if(max(m - np.abs(x[k]-cx) - np.abs(y[k]-cy),0)!= h[k]):
        ans = 0
    if (ans):
      print(cx,cy,m)
    break

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
x = []
y = []
h = []
for i in range(N):
    x1,y1,h1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    h.append(h1)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
x = []
y = []
h = []
for i in range(N):
    x1,y1,h1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    h.append(h1)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
x = []
y = []
h = []
for i in range(N):
    x1,y1,h1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
    h.append(h1)

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

Submission status: Wrong Answer

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    xyh = [list(map(int, input().rstrip('\n').split())) for _ in range(n)]
    xyh.sort(key=lambda x: x[2], reverse=True)
    for i in range(101):
        for j in range(101):
            th = -1
            b = True
            for x, y, h in xyh:
                if th == -1:
                    th = h + abs(x - i) + abs(y - j)
                else:
                    if th != h + abs(x - i) + abs(y - j):
                        b = False
                        break
            if b:
                print(i, j, th)
                exit()


if __name__ == '__main__':
    slove()

Submission status: Wrong Answer

Solution code:
N = int(input())

Q = []
for _ in range(N):
    x, y, h = map(int, input().split())
    Q.append((h, x, y))
Q.sort(reverse=True)

seikai = True
for yc in range(101):
    seikai = False
    for xc in range(101):
        valid = True
        h, x, y = Q[0]
        hc = abs(x-xc) + abs(y-yc) + h
        for (h, x, y) in Q:
            if h == 0:
                if hc > abs(x-xc) + abs(y-yc) + h:
                    valid = False
                    break
            else:
                if hc > abs(x-xc) + abs(y-yc) + h:
                    valid = False
                    break
        if not valid:
            continue
        seikai = True
        break
    if seikai:
        break

print(xc, yc, hc)