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 math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N = I()
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x,y,h])


for i in range(100+1):
    for j in range(100+1):
        cx, cy = i, j
        H = []
        for item in xyh:
            #  print(item)
            if item[2] == 0:
                continue

            new_H = max(item[2] + abs(item[0] - cx) + abs(item[1] - cy), 0)
            H.append(new_H)
        else:
            if not all([h == 0 for h in H]) and len(set(H)) == 1:
                print(i, j, H[0])
                exit()

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N = I()
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x,y,h])


for i in range(100+1):
    for j in range(100+1):
        cx, cy = i, j
        H = []
        for item in xyh:
            new_H = max(item[2] + abs(item[0] - cx) + abs(item[1] - cy), 0)
            H.append(new_H)
        else:
            if not all([h == 0 for h in H]) and len(set(H)) == 1:
                print(i, j, H[0])
                exit()

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N = I()
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x,y,h])


for i in range(100+1):
    for j in range(100+1):
        cx, cy = i, j
        H = []
        for item in xyh:
            new_H = max(item[2] + abs(item[0] - cx) + abs(item[1] - cy), 0)
            H.append(new_H)
        else:
            if not all([h == 0 for h in H]) and len(set(H)) == 1:
                print(i, j, H[0])
                exit()

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N = I()
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x,y,h])


for i in range(100+1):
    for j in range(100+1):
        cx, cy = i, j
        H = []
        for item in xyh:
            new_H = max(item[2] + abs(item[0] - cx) + abs(item[1] - cy), 0)
            H.append(new_H)
        else:
            if len(set(H)) == 1:
                print(i, j, H[0])
                exit()

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N = I()
xyh = []
for i in range(N):
    x, y, h = LI()
    xyh.append([x,y,h])


for i in range(100+1):
    for j in range(100+1):
        cx, cy = i, j
        H = []
        for item in xyh:
            new_H = max(item[2] + abs(item[0] - cx) + abs(item[1] - cy), 0)
            H.append(new_H)
        else:
            if len(set(H)) == 1:
                print(i, j, H[0])

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=set(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=set()
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.add((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.add((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.add((X,Y))
  else:
    t=s.copy()-{(l[A][0],l[A][1]),(l[B][0],l[B][1])}    

  s=t.copy()
for a,b in s:
  h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
  print(a,b,h)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
li = []
for nu,nuu,nuuu in lis:
  if nuuu != 0:li.append([nu,nuu,nuuu])
for i in range(101):
  for j in range(101):
    s = set()
    for h in range(len(li)):
      num = abs(li[h][0]-i)+abs(li[h][1]-j)
      if num + li[h][2] < 0:
        s.add(num + li[h][2] + 1)
      s.add(num + li[h][2])
    if len(s) == 1:
      for num in s:
        print(i,j,num)

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
for i in range(101):
  for j in range(101):
    s = set()
    for h in range(n):
      num = abs(lis[h][0]-i)+abs(lis[h][1]-j)
      if num + lis[h][2] < 0:
        s.add(num + lis[h][2] + 1)
      s.add(num + lis[h][2])
    if len(s) == 1:
      for num in s:
        print(i,j,num)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  else:
    t=s[:]
    if (l[A][0],l[A][1]) in t:
      t.remove((l[A][0],l[A][1]))
    if (l[B][0],l[B][1]) in t:
      t.remove((l[B][0],l[B][1]))    

  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  else:
    for X,Y in s:
      if (X,Y)!=(l[A][0],l[A][1]) and (X,Y)!=(l[B][0],l[B][1]):
        t.append((X,Y))
  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  else:
    for X,Y in s:
      if (X,Y)!=(l[A][0],l[A][1]) and (X,Y)!=(l[B][0],l[B][1]):
        t.append((X,Y))
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
s=list(itertools.product(range(0,101),repeat=2))
for A,B in itertools.combinations(range(N),2):
  if len(s)==1:
    break
  t=[]
  if l[A][2]>l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])<abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]<l[B][2]:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  elif l[A][2]!=0:
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]):
        t.append((X,Y))
  else:
    t=s[:]
  s=t[:]
a,b=s[0][0],s[0][1]
h=abs(a-l[0][0])+abs(b-l[0][1])+l[0][2]
print(a,b,h)

Submission status: Wrong Answer

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N=ri()
X=[0]*N
Y=[0]*N
H=[0]*N
for i in range(N):
    X[i],Y[i],H[i]=rl()

ans=[-1]*3
for x in range(101):
    if ans[0] != -1:
        break
    for y in range(101):
        if ans[0] != -1:
            break
        rst = H[0]+abs(x-X[0])+abs(y-Y[0])
        for i in range(1,N):
            if rst != H[i]+abs(x-X[i])+abs(y-Y[i]):
                break
            elif i == N-1:
                ans = [x,y,rst]

if ans[0] == -1 and N==1:
    ans = [X[0],Y[0],H[0]]
print("{} {} {}".format(ans[0],ans[1],ans[2]))

Submission status: Wrong Answer

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N=ri()
X=[0]*N
Y=[0]*N
H=[0]*N
for i in range(N):
    X[i],Y[i],H[i]=rl()

ans=[-1]*3
for x in range(101):
    if ans[0] != -1:
        break
    for y in range(101):
        if ans[0] != -1:
            break
        rst = H[0]+abs(x-X[0])+abs(y-Y[0])
        for i in range(1,N):
            if rst != H[i]+abs(x-X[i])+abs(y-Y[i]):
                break
            elif i == N-1:
                ans = [x,y,rst]

print("{} {} {}".format(ans[0],ans[1],ans[2]))

Submission status: Wrong Answer

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

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

if len(a) == [x[2] for x in a].count(0):
    print(5050 - sum(a[0]), 5050 - sum(a[1]), 1)

for i in range (101):
    for j in range (101):
        H = []
        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))
                #print(H)
        if len(H) == H.count(H[0]):
            print(i, j, H[0])
            sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(n):
	xtemp, ytemp, htemp = map(int, input().split())
	x.append(xtemp)
	y.append(ytemp)
	h.append(htemp)
H = 1000000000
for i in range(0, 101):
	for j in range(0, 101):
		f = 0
		for k in range(n):
			if h[k] != 0:
				H = h[k] + abs(i - x[k]) + abs(j - y[k])
				f += 1
		count = 0
		for k in range(n):
			if (h[k] == max(H - abs(i - x[k]) - abs(j - y[k]), 0)) and (H == h[k] + abs(i - x[k]) + abs(j - y[k])):
				count += 1
			else:
				break
		if count == f:
			print(i, j, H)
			exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(n):
	xtemp, ytemp, htemp = map(int, input().split())
	x.append(xtemp)
	y.append(ytemp)
	h.append(htemp)
H = 1000000000
for i in range(0, 101):
	for j in range(0, 101):
		f = 0
		for k in range(n):
			if h[k] != 0:
				H = h[k] + abs(i - x[k]) + abs(j - y[k])
				f += 1
		count = 0
		for k in range(n):
			if (h[k] != 0) and (H == h[k] + abs(i - x[k]) + abs(j - y[k])):
				count += 1
			else:
				break
		if count == f:
			print(i, j, H)
			exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(n):
	xtemp, ytemp, htemp = map(int, input().split())
	x.append(xtemp)
	y.append(ytemp)
	h.append(htemp)
H = 1000000000
for i in range(0, 101):
	for j in range(0, 101):
		for k in range(n):
			if h[k] != 0:
				H = h[k] + abs(i - x[k]) + abs(j - y[k])
				break
		count = 0
		for k in range(n):
			if (h[k] != 0) and (H == h[k] + abs(i - x[k]) + abs(j - y[k])):
				count += 1
			else:
				break
		if count == n:
			print(i, j, H)
			exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(n):
	xtemp, ytemp, htemp = map(int, input().split())
	x.append(xtemp)
	y.append(ytemp)
	h.append(htemp)
H = 10000000000
for i in range(0, 101):
	for j in range(0, 101):
		H = h[0] + abs(i - x[0]) + abs(j - y[0])
		count = 0
		for k in range(n):
			if H == h[k] + abs(i - x[k]) + abs(j - y[k]):
				count += 1
			else:
				break
		if count == n:
			print(i, j, H)
			exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(n):
	xtemp, ytemp, htemp = map(int, input().split())
	x.append(xtemp)
	y.append(ytemp)
	h.append(htemp)
H = 10000000000
for i in range(0, 101):
	for j in range(0, 101):
		H = h[0] + abs(i - x[0]) + abs(j - y[0])
		count = 0
		for k in range(1, n):
			if H == h[k] + abs(i - x[k]) + abs(j - y[k]):
				count += 1
			else:
				break
		if count == n - 1:
			print(i, j, H)
			exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []

for i in range(n):
	xtemp, ytemp, htemp = map(int, input().split())
	x.append(xtemp)
	y.append(ytemp)
	h.append(htemp)
H = 1000000000
for i in range(0, 101):
	for j in range(0, 101):
		H = h[0] + abs(i - x[0]) + abs(j - y[0])
		count = 0
		for k in range(1, n):
			if H == h[k] + abs(i - x[k]) + abs(j - y[k]):
				count += 1
			else:
				break
		if count == n - 1:
			print(i, j, H)
			exit()

Submission status: Wrong Answer

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

def peak_height(x,y,h,cx,cy):
    peak = max(h + abs(x-cx) + abs(y-cy), 0)
    return peak

ans = ''
not0_points = [p for p in points if p[2]!=0]
if len(not0_points)==1:
    ans = map(str, not0_points[0])

for cx in range(101):
    if ans: break
    for cy in range(101):
        if ans: break
        peak = 0
        flg = 0
        for x,y,h in points:
            temp = peak_height(x,y,h,cx,cy)
            if temp and not peak:
                peak = temp
            elif temp*peak and temp!=peak:
                flg = 1
                break
        if not flg: ans = map(str, [cx,cy,peak])

print(' '.join(ans))

Submission status: Wrong Answer

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

def peak_height(x,y,h,cx,cy):
    peak = max(h + abs(x-cx) + abs(y-cy), 0)
    return peak

ans = ''
not0_points = [p for p in points if p[2]!=0]
if len(not0_points)==1:
    ans = map(str, not0_points[0])

for cx in range(101):
    if ans: break
    for cy in range(101):
        if ans: break
        peaks = []
        for x,y,h in points:
            peaks.append(peak_height(x,y,h,cx,cy))
        if len(set(peaks)-set([0]))==1:
            ans = map(str, [cx,cy,max(peaks)])

print(' '.join(ans))

Submission status: Wrong Answer

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

def peak_height(x,y,h,cx,cy):
    peak = max(h + abs(x-cx) + abs(y-cy), 0)
    return peak

for cx in range(101):
    for cy in range(101):
        peaks = []
        ans = ''
        for x,y,h in points:
            peaks.append(peak_height(x,y,h,cx,cy))
        if len(set(peaks)-set([0]))==1:
            ans = map(str, [cx,cy,max(peaks)])
        if ans: break
    if ans: break

print(' '.join(ans))

Submission status: Wrong Answer

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

def peak_height(x,y,h,cx,cy):
    peak = max(h + abs(x-cx) + abs(y-cy), 0)
    return peak

for cx in range(3):
    for cy in range(3):
        peaks = []
        ans = ''
        for x,y,h in points:
            peaks.append(peak_height(x,y,h,cx,cy))
        if len(set(peaks)-set([0]))==1:
            ans = map(str, [cx,cy,max(peaks)])
        if ans: break
    if ans: break

print(' '.join(ans))

Submission status: Wrong Answer

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

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and max(h0) >= max(hc)) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break

Submission status: Wrong Answer

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

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        h0 = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] == 0}
        if len(hc) == 1:
            if (len(h0) > 0 and max(h0) <= max(hc)) or len(h0) == 0:
                print(x, y, list(hc)[0])
                break

Submission status: Wrong Answer

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

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)

C = [[False] * 101 for _ in range(101)]
for x in range(101):
    for y in range(101):
        hc = {H[i] + abs(X[i] - x) + abs(Y[i] - y) for i in range(N) if H[i] > 0}
        if len(hc) == 1:
            print(x, y, list(hc)[0])
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
for j in range(N):
  if L[j][2] != 0:
    karix = L[j][0]
    kariy = L[j][1]
    karih = L[j][2]
    break
for p in range(0,101):
  for q in range(0,101):
    cnt = 0
    kouhoH = karih+abs(karix-p)+abs(kariy-q)
    for r in range(N):
      if kouhoH == L[r][2]+abs(L[r][0]-p)+abs(L[r][1]-q):
        cnt += 1
    if cnt == N:
      print(p,q,kouhoH)
      exit()

Submission status: Wrong Answer

Solution code:
from itertools import product


def solve(string):
    n, *xyh = map(int, string.split())
    xyh = sorted([(x, y, h) for x, y, h in zip(xyh[::3], xyh[1::3], xyh[2::3])],
                 key=lambda x: x[-1], reverse=True)
    for i, j in product(range(101), range(101)):
        h = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]
        check = [_h == max(h - abs(_x - i) - abs(_y - j), 0) for _x, _y, _h in xyh[1:]]
        if all(check):
            return "{} {} {}".format(i, j, h+1)


if __name__ == '__main__':
    n = int(input())
    print(solve("{}\n".format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
from itertools import product


def solve(string):
    n, *xyh = map(int, string.split())
    xyh = sorted([(x, y, h) for x, y, h in zip(xyh[::3], xyh[1::3], xyh[2::3])],
                 key=lambda x: x[-1])
    for i, j in product(range(101), range(101)):
        h = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]
        check = [_h == max(h - abs(_x - i) - abs(_y - j), 0) for _x, _y, _h in xyh[1:]]
        if all(check):
            return "{} {} {}".format(i, j, h)


if __name__ == '__main__':
    n = int(input())
    print(solve("{}\n".format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
from itertools import product


def solve(string):
    n, *xyh = map(int, string.split())
    xyh = [(x, y, h) for x, y, h in zip(xyh[::3], xyh[1::3], xyh[2::3])]
    for i, j in product(range(101), range(101)):
        h = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]
        check = [_h == h - abs(_x - i) - abs(_y - j) for _x, _y, _h in xyh[1:]]
        if all(check):
            return "{} {} {}".format(i, j, h)


if __name__ == '__main__':
    n = int(input())
    print(solve("{}\n".format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *xyh = map(int, string.split())
    xyh = [(x, y, h) for x, y, h in zip(xyh[::3], xyh[1::3], xyh[2::3]) if h > 0]
    for i in range(101):
        for j in range(101):
            h = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]
            check = [_h == h - abs(_x - i) - abs(_y - j) for _x, _y, _h in xyh[1:]]
            if all(check):
                return "{} {} {}".format(i, j, h)


if __name__ == '__main__':
    n = int(input())
    print(solve("{}\n".format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *xyh = map(int, string.split())
    xyh = [(x, y, h) for x, y, h in zip(xyh[::3], xyh[1::3], xyh[2::3]) if h > 0]
    print(xyh)
    for i in range(101):
        for j in range(101):
            h = abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2]
            check = [_h == h - abs(_x - i) - abs(_y - j) for _x, _y, _h in xyh[1:]]
            if all(check):
                return "{} {} {}".format(i, j, h)


if __name__ == '__main__':
    n = int(input())
    print(solve("{}\n".format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

Solution code:
def solve(string):
    n, *xyh = map(int, string.split())
    for i in range(101):
        for j in range(101):
            h = abs(xyh[0] - i) + abs(xyh[1] - j) + xyh[2]
            check = [
                _h == h - abs(_x - i) - abs(_y - j)
                for _x, _y, _h in zip(xyh[::3], xyh[1::3], xyh[2::3])
            ]
            if all(check):
                return "{} {} {}".format(i, j, h)


if __name__ == '__main__':
    n = int(input())
    print(solve("{}\n".format(n) + '\n'.join([input() for _ in range(n)])))

Submission status: Wrong Answer

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

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

for i in range (101):
    for j in range (101):
        H = []
        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))
                #print(H)
        if len(H) == H.count(H[0]):
            print(i, j, H[0])
            sys.exit()

Submission status: Wrong Answer

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

for i in range (101):
    for j in range (101):
        H = []
        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))
                #print(H)
        if len(H) == H.count(H[0]):
            print(i, j, H[0])
            sys.exit()

Submission status: Wrong Answer

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

if all([h==0 for x,y,h in coord]):
  H = 1
  while True:
    for cx in range(0,101):
      for cy in range(0,101):
        if all([H-abs(x-cx)-abs(y-cy)<=0 for x,y,h in coord]):
          print(cx, cy, H)
          sys.exit()
    H+=1

for cx in range(0,101):
  for cy in range(0,101):
    x = set([h + abs(x-cx)+abs(y-cy) for x,y,h in coord if h>0])
    if len(x)==1:
      print(cx,cy,list(x)[0])
      sys.exit()

Submission status: Wrong Answer

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

for cx in range(0,101):
  for cy in range(0,101):
    x = set([h + abs(x-cx)+abs(y-cy) for x,y,h in coord if h!=0])
    if len(x)==1:
      print(cx,cy,list(x)[0])
      sys.exit()

Submission status: Wrong Answer

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

flag = False
ans = [0, 0, 0]
for i in range(101):
  for j in range(101):
    for k in range(N):
      Xt, Yt, Ht = L[k][0], L[k][1], L[k][2]
      if Ht > 0:
        break
    H = Ht + abs(Xt - i) + abs(Yt - j)
    result = []
    for k in range(N):
      l = L[k]
      if (l[2] == 0 and H - abs(i - l[0]) - abs(i - l[1]) <= 0) or H - abs(i - l[0]) - abs(j - l[1]) == l[2]:
        result.append(True)
      else:
        result.append(False)
    if result.count(True) == N:
      ans[0], ans[1], ans[2] = i, j, H
      flag = True
      break
  if flag:
    break

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

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

flag = False
ans = [0, 0, 0]
for i in range(101):
  for j in range(101):
    for k in range(N):
      Xt, Yt, Ht = L[k][0], L[k][1], L[k][2]
      if Ht > 0:
        break
    H = Ht + abs(Xt - i) + abs(Yt - j)
    result = []
    for k in range(N):
      l = L[k]
      if l[2] == 0 or H - abs(i - l[0]) - abs(j - l[1]) == l[2]:
        result.append(True)
      else:
        result.append(False)
    if result.count(True) == N:
      ans[0], ans[1], ans[2] = i, j, H
      flag = True
      break
  if flag:
    break

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

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

flag = False
ans = [0, 0, 0]
for i in range(101):
  for j in range(101):
    for k in range(N):
      Xt, Yt, Ht = L[k][0], L[k][1], L[k][2]
      if Ht > 0:
        break
    H = Ht + abs(Xt - i) + abs(Yt - j)
    result = []
    for k in range(N):
      l = L[k]
      if (l[2] == 0 and H - abs(i - l[0]) - abs(i - l[1]) == 0) or H - abs(i - l[0]) - abs(j - l[1]) == l[2]:
        result.append(True)
      else:
        result.append(False)
    if result.count(True) == N:
      ans[0], ans[1], ans[2] = i, j, H
      flag = True
      break
  if flag:
    break

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

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

for cxi in range(101):
    for cyi in range(101):
        hight_ = params[0][2] + abs(params[0][0] - cxi) + abs(params[0][1] - cyi)
    
        for k in range(N):
            if params[k][2] > 0:
                hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)
    
                if hight < 1:
                    break
                else:
                    if hight != hight_:
                        break
                    else:
                        hight_ = hight
                        continue
    
            elif params[k][2] == 0:
                if 1 > (abs(params[k][0] - cxi) + abs(params[k][1] - cyi)):
                    break
        
        else:
            print(cxi, cyi, hight)