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

for i in range(101):
    for j in range(101):
        p=abs(i-x)+abs(j-y)+h
        for a,b,c in d:
            if (c==0 and p-abs(i-a)+abs(j-b)<1) or (c==(p-abs(i-a)-abs(j-b))):
                pass
            else:
                p=-1
                break
        if p!=-1:
            print(i,j,p)
            exit()

Submission status: Wrong Answer

Solution code:
A=abs
_,*p=[list(map(int,t.split()))for t in open(0)]
x,y,h=sorted(p)[-1]
r=range(101)
for i in r:
 for j in r:H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

Solution code:
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
C = [[0]*101 for i in range(101)]
for X in range(101):
  for Y in range(101):
    tmp1 = -1
    flg = 0
    for i in range(N):
      x,y,h = P[i]
      if h != 0 and tmp1 == -1:
        tmp1 = abs(X-x)+abs(Y-y)+h
      elif h != 0 and tmp1 != -1:
        tmp2 = abs(X-x)+abs(Y-y)+h
        if tmp1 != tmp2:
          flg = 1
          break
    if flg == 0:
      print(X, Y, tmp1)        
      exit()

Submission status: Wrong Answer

Solution code:
A=abs
p=[x for x in[list(map(int,t.split()))for t in open(0)][1:]if x[2]]
x,y,h=p[0]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : list(map(int, stdin.readline().split()))
ni = lambda : int(sn())

n = ni()
xyz = [0] * n
for i in range(n):
  xyz[i] = an()

xyz.sort(key = lambda x: x[2])

sx, sy, sh = xyz[0]
for Cy in range(101):
  for Cx in range(101):
    H = sh + abs(sx - Cx) + abs(sy - Cy)
    if all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x, y, h in xyz):
      print(Cx, Cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

sn = lambda : stdin.readline().rstrip()
an = lambda : list(map(int, stdin.readline().split()))
ni = lambda : int(sn())

n = ni()
xyz = [0] * n
for i in range(n):
  xyz[i] = an()

sx, sy, sh = xyz[0]
for Cy in range(101):
  for Cx in range(101):
    H = sh + abs(sx - Cx) + abs(sy - Cy)
    if all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x, y, h in xyz):
      print(Cx, Cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
A=abs;_,*p=[list(map(int,t.split()))for t in open(0)];x,y,h=p[-1]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

Solution code:
A=abs;_,*p=[list(map(int,t.split()))for t in open(0)];x,y,h=p[0]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A=abs;_,(x,y,h),*p=[list(map(int,t.split()))for t in open(0)]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

Solution code:
A=abs;_,*p,(x,y,h)=[list(map(int,t.split()))for t in open(0)]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

Solution code:
A=abs;(x,y,h),*p=[t for t in[list(map(int,t.split()))for t in open(0)][1:]if t[2]]
for I in range(10201):j,i=I//101,I%101;H=h+A(x-j)+A(y-i);print(*(j,i,H)*all(u==max(H-A(s-j)-A(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

# お約束
INF = float("inf")
MOD = int(1e9 + 7)

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

# お約束
INF = float("inf")
MOD = int(1e9 + 7)

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

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

Submission status: Wrong Answer

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

for x0 in range(101):
    for y0 in range(101):
        a = -1
        ok = True
        for x, y, h in XYH:
            if h == 0:
                continue
            if a == -1:
                a = abs(x-x0) + abs(y-y0) + h
                continue
            if a != abs(x-x0) + abs(y-y0) + h:
                ok = False
                break
        if ok:
            print(x0, y0, a)
            break
    if ok:
        break

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  qx,qy,qh = (-1,-1,-1)
  get = 0
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
    if h >= 0:
      if not get:
        qx,qy,qh = (x,y,h)
        get = 1
  if qx*qy*qh == -1:
    qx,qy,qh = query[0]

  for cx in range(101):
    for cy in range(101):
 
      karih = qh+abs(qx-cx)+abs(qy-cy)
      if karih <= 0:
        continue
      else:
       flag = 0
       for j in range(n):
        tx,ty,h = query[j]
        if h == max(karih-abs(tx-cx)-abs(ty-cy),0):
          continue
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)

solve()

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  qx,qy,qh = (-1,-1,-1)
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
    if h >= 0:
      qx,qy,qh = (x,y,h)
  if qx*qy*qh == -1:
    qx,qy,qh = query[0]
  if n == 1:
    print(*(qx,qy,h))
    exit()
  for cx in range(101):
    for cy in range(101):
 
      karih = qh+abs(qx-cx)+abs(qy-cy)
      if karih <= 0:
        continue
      else:
       flag = 0
       for j in range(n):
        tx,ty,h = query[j]
        if h == max(karih-abs(tx-cx)-abs(ty-cy),0):
          continue
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
    if h >= 0:
      qx,qy,qh = (x,y,h)
    
    
  for cx in range(101):
    for cy in range(101):
 
      karih = qh+abs(qx-cx)+abs(qy-cy)
      if karih <= 0:
        continue
      else:
       flag = 0
       for j in range(n):
        tx,ty,h = query[j]
        if h == max(karih-abs(tx-cx)-abs(ty-cy),0):
          continue
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  if n == 1:
    print(*(x,y,h))
    exit()
  for cx in range(101):
    for cy in range(101):
      x,y,h = query[0]
      karih = h+abs(x-cx)+abs(y-cy)
      if karih <= 0:
        continue
      else:
       flag = 0
       for j in range(n):
        x,y,h = query[j]
        if h == max(karih-abs(x-cx)-abs(y-cy),0):
          flag *= 1
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  if n == 1:
    print(*(x,y,h))
    exit()
  for cx in range(101):
    for cy in range(101):
      x,y,h = query[0]
      karih = max(h+abs(x-cx)+abs(y-cy),0)
      if karih == 0:
        continue
      else:
       flag = 0
       for j in range(n):
        x,y,h = query[j]
        if h == max(karih-abs(x-cx)-abs(y-cy),0):
          flag *= 1
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

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

  for cx in range(101):
    for cy in range(101):
      x,y,h = query[0]
      karih = max(h+abs(x-cx)+abs(y-cy),0)
      if karih == 0:
        continue
      else:
       flag = 0
       for j in range(n):
        x,y,h = query[j]
        if h == max(karih-abs(x-cx)-abs(y-cy),0):
          flag *= 1
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

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

  for cx in range(101):
    for cy in range(101):
      x,y,h = query[0]
      karih = max(h+abs(x-cx)+abs(y-cy),0)
      if karih == 0:
        continue
      else:
       flag = 0
       for j in range(n):
        x,y,h = query[j]
        if h == max(karih-abs(x-cx)-abs(y-cy),0):
          continue
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
    
  if n== 1:
    exit()
  
  for cx in range(101):
    for cy in range(101):
      x,y,h = query[0]
      karih = max(h+abs(x-cx)+abs(y-cy),0)
      if karih == 0:
        continue
      else:
       flag = 0
       for j in range(n-1):
        x,y,h = query[j+1]
        if h == max(karih-abs(x-cx)-abs(y-cy),0):
          continue
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  for cx in range(101):
    for cy in range(101):
      x,y,h = query[0]
      karih = max(h+abs(x-cx)+abs(y-cy),0)
      if karih == 0:
        continue
      else:
       flag = 0
       for j in range(n-1):
        x,y,h = query[j+1]
        if h == max(karih-abs(x-cx)-abs(y-cy),0):
          continue
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        exit()
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:

def solve():
  n = int(input())
  query = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  for cx in range(101):
    for cy in range(101):
      x,y,h = query[0]
      karih = max(h+abs(x-cx)+abs(y-cy),0)
      if karih == 0:
        continue
      else:
       flag = 0
       for j in range(n-1):
        x,y,h = query[j+1]
        if h == max(karih-abs(x-cx)-abs(y-cy),0):
          continue
        else:
          flag = 1
      if flag == 0:
        ans = (cx,cy,karih)
        print(*ans)
        flag = 0
solve()

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
L=[]
Lappend=L.append
for _ in range(n):
  Lappend(list(map(int,input().split())))
for i in range(101):
  for j in range(101):
    H=[]
    Happend=H.append
    for k in L:
      if k[2]!=0:
        Happend(k[2]+abs(k[0]-i)+abs(k[1]-j))
    if len(set(H))==1:
      print(i,j,H[0])

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]

for cx in range(101):
  for cy in range(101):
    c = Counter(h + abs(cx - x) + abs(cy - y) for x, y, h in L if h != 0)
    if len(c) == 1:
      print(cx, cy, c.most_common()[0][0])
      exit()

Submission status: Wrong Answer

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

for i in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))
if n == 1:
    print("{} {} {}".format(x, y, h))
    exit()
ch = -1

for cx in range(101):
    for cy in range(101):
        flag = True
        h_d = 0
        for i in range(n):
            for j in range(n):
                if i == j:
                    continue
                if xyh[i][2] == 0 or xyh[j][2] == 0:
                    continue
                h_d = (abs(xyh[i][2] - xyh[j][2])) / ((abs(xyh[i][0] - xyh[j][0]) +  abs(xyh[i][1] - xyh[j][1])))
                ch = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
                if h_d > 0:
                    break
            if h_d > 0:
                break
        for(x, y, h) in xyh:
            if h != max(ch - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print("{} {} {}".format(cx, cy, ch))
            exit()

Submission status: Wrong Answer

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

for i in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))
if n == 1:
    print("{} {} {}".format(x, y, h))
    exit()
ch = -1

for cx in range(101):
    for cy in range(101):
        flag = True
        h_d = (abs(xyh[0][2] - xyh[1][2])) / ((abs(xyh[0][0] - xyh[1][0]) +  abs(xyh[0][1] - xyh[1][1])))
        ch = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for(x, y, h) in xyh:
            if h != max(ch - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print("{} {} {}".format(cx, cy, ch))
            exit()

Submission status: Wrong Answer

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

for i in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))

ch = -1

for cx in range(101):
    for cy in range(101):
        flag = True
        h_d = (abs(xyh[0][2] - xyh[1][2])) / ((abs(xyh[0][0] - xyh[1][0]) +  abs(xyh[0][1] - xyh[1][1])))
        ch = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for(x, y, h) in xyh:
            if h != max(ch - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print("{} {} {}".format(cx, cy, ch))
            exit()

Submission status: Wrong Answer

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

for i in range(n):
    x, y, h = map(int, input().split())
    xyh.append((x, y, h))

ch = -1

for cx in range(101):
    for cy in range(101):
        flag = True
        h_d = (abs(xyh[0][2] - xyh[1][2])) / ((abs(xyh[0][0] - xyh[1][0]) +  abs(xyh[0][1] - xyh[1][1])))
        ch = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        for(x, y, h) in xyh:
            if h != max(ch - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print("{} {} {}".format(cx, cy, ch))

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []

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


for i in range(101):
    for j in range(101):
        h1 = h[0] + abs(i - x[0]) + abs(j - y[0])
        flag = True
        for k in range(1, len(x)):
            h2 = h[k] + abs(i - x[k]) + abs(j - y[k])
            if h1 != h2:
                flag = False
                break
        if flag:
            ans = [str(i), str(j), str(h1)]
            break
    if flag:
        break

print(ans[0] + " " + ans[1] + " " + ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
x, y, h = [], [], []
for i in range(n):
    xyh = list(map(int, input().split()))
    x.append(xyh[0])
    y.append(xyh[1])
    h.append(xyh[2])
for i in range(101):
    for j in range(101):
        flag = True
        ch = -1
        for k in range(n):
            if h[k] != 0 and (h[k] + abs(x[k] - i) + abs(y[k] - j)) > 0:
                if ch == -1:
                    ch = h[k] + abs(x[k] - i) + abs(y[k] - j)
                else:
                    if ch != h[k] + abs(x[k] - i) + abs(y[k] - j) and flag:
                        flag = False
        if flag:
            ans = list(map(str, [i, j, ch]))
print(ans[0] + " " + ans[1] + " " + ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
x, y, h = [], [], []
for i in range(n):
    xyh = list(map(int, input().split()))
    x.append(xyh[0])
    y.append(xyh[1])
    h.append(xyh[2])
for i in range(101):
    for j in range(101):
        flag = True
        ch = -1
        for k in range(n):
            if h[k] != 0:
                if ch == -1:
                    ch = h[k] + abs(x[k] - i) + abs(y[k] - j)
                else:
                    if ch != h[k] + abs(x[k] - i) + abs(y[k] - j) and flag:
                        flag = False
        if flag:
            ans = list(map(str, [i, j, ch]))
print(ans[0] + " " + ans[1] + " " + ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
x, y, h = [], [], []
for i in range(n):
    xyh = list(map(int, input().split()))
    x.append(xyh[0])
    y.append(xyh[1])
    h.append(xyh[2])
for i in range(101):
    for j in range(101):
        flag = True
        ch = 0
        for k in range(n):
            if h[k] != 0:
                if ch == 0:
                    ch = h[k] + abs(x[k] - i) + abs(y[k] - j)
                else:
                    if ch != h[k] + abs(x[k] - i) + abs(y[k] - j) and flag:
                        flag = False
        if flag:
            ans = list(map(str, [i, j, ch]))
print(ans[0] + " " + ans[1] + " " + ans[2])

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    xyh = list(list(map(int, input().split())) for _ in range(n))
    x, y, h = max(xyh, key=lambda i: i[-1])
    for cx in range(101):
        for cy in range(101):
            H_estimated = h + abs(x - cx) + abs(y - cy)
            if all([True if hi + abs(xi - cx) + abs(yi - cy) == H_estimated else False for xi, yi, hi in xyh]):
                return " ".join([str(cx), str(cy), str(H_estimated)])


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    xyh = list(list(map(int, input().split())) for _ in range(n))
    x, y, h = max(xyh, key=lambda i: i[-1])
    for cx in range(101):
        for cy in range(101):
            H_estimated = h + abs(x - cx) + abs(y - cy)
            if all([True if hi + abs(xi - cx) + abs(yi - cy) == H_estimated else False for xi, yi, hi in xyh]):
                print(" ".join([str(cx), str(cy), str(H_estimated)]))


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
for i in range(n):
    if l[i][2]==100:
        print(l[i][0], l[i][1], l[i][2])
        break
else:    
    p=[]
    count=0
    for i in range(n):
        for cx in range(101):
            for cy in range(101):
                if l[i][2]!=0:
                    H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
                    p.append([cx,cy,H])
                else:
                    count+=1
    p.sort()
    ans=0
    n=n-count//10201
    for i in range(101*101*n-1):
        if p[i]==p[i+1]:
            ans+=1
            if ans==n-1:
                print(' '.join(map(str,p[i])))
                break
        else:
            ans=0

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
    if l[i][2]==100:
        print(l[i][0], l[i][1], l[i][2])
        break
else:    
    p=[]
    count=0
    for i in range(n):
        for cx in range(101):
            for cy in range(101):
                if l[i][2]!=0:
                    H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
                    p.append([cx,cy,H])
                else:
                    count+=1
    p.sort()
    ans=0
    n=n-count//10201
    for i in range(101*101*n-1):
        if p[i]==p[i+1]:
            ans+=1
            if ans==n-1:
                print(' '.join(map(str,p[i])))
                break
        else:
            ans=0

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
    if l[1][2]==100:
        print(l[i][0], l[i][1], l[i][2])
        break
else:    
    p=[]
    count=0
    for i in range(n):
        for cx in range(101):
            for cy in range(101):
                if l[i][2]!=0:
                    H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
                    p.append([cx,cy,H])
                else:
                    count+=1
    p.sort()
    ans=0
    n=n-count//10201
    for i in range(101*101*n-1):
        if p[i]==p[i+1]:
            ans+=1
            if ans==n-1:
                print(' '.join(map(str,p[i])))
                break
        else:
            ans=0

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
p=[]
count=0
for i in range(n):
    for cx in range(101):
        for cy in range(101):
            if l[i][2]!=0:
                H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
                p.append([cx,cy,H])
            else:
                count+=1
p.sort()
ans=0
n=n-count//10201
if n==1:
    print(l[0][0], l[0][1], l[0][2])
else:
    for i in range(101*101*n-1):
        if p[i]==p[i+1]:
            ans+=1
            if ans==n-1:
                print(' '.join(map(str,p[i])))
                break
        else:
            ans=0

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
p=[]
count=0
for i in range(n):
    for cx in range(101):
        for cy in range(101):
            if l[i][2]!=0:
                H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
                p.append([cx,cy,H])
            else:
                count+=1
p.sort()
ans=0
n=n-count//10201
if n==1:
    print('0 0 100')
else:
    for i in range(101*101*n-1):
        if p[i]==p[i+1]:
            ans+=1
            if ans==n-1:
                print(' '.join(map(str,p[i])))
                break
        else:
            ans=0

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[0,0,0] for _ in range(n)]
for i in range(n):
    l[i][0],l[i][1],l[i][2]=map(int,input().split())
p=[]
count=0
for i in range(n):
    for cx in range(101):
        for cy in range(101):
            if l[i][2]!=0:
                H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
                p.append([cx,cy,H])
            else:
                count+=1
p.sort()
ans=0
n=n-count//10201
for i in range(101*101*n-1):
    if p[i]==p[i+1]:
        ans+=1
        if ans==n-1:
            print(' '.join(map(str,p[i])))
            break
    else:
        ans=0

Submission status: Wrong Answer

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

top = [[] for _ in range(101*101)]

for i in range(101):
    for j in range(101):
        top[i*101+j] = [i, j]

#print(top)

H = 0

for i in range(len(top)):
    topx = top[i][0]
    topy = top[i][1]
    H = 0
    h_list = []
    for j in range(N):
        if h[j] != 0:
            tmp = abs(topx - x[j]) + abs(topy - y[j]) + h[j]
            h_list.append(tmp)
    if h_list.count(h_list[0]) == N - h.count(0) :
        ansx = topx
        ansy = topy
        ansH = h_list[0]
        break

print(ansx, ansy, ansH)

Submission status: Wrong Answer

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

top = [[] for _ in range(101*101)]

for i in range(101):
    for j in range(101):
        top[i*101+j] = [i, j]

#print(top)

H = 0

for i in range(len(top)):
    topx = top[i][0]
    topy = top[i][1]
    H = 0
    h_list = []
    for j in range(N):
        if h[j] != 0:
            tmp = abs(topx - x[j]) + abs(topy - y[j]) + h[j]
            h_list.append(tmp)
    if h_list.count(h_list[0]) >= N - h.count(0) :
        ansx = topx
        ansy = topy
        ansH = h_list[0]
        break

print(ansx, ansy, ansH)

Submission status: Wrong Answer

Solution code:
import math,fractions,sys
from collections import Counter
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
tmp = 0
if n == 1:
    print(x[0],y[0],h[0])
    sys.exit()
def max(i,j):
    for _ in range(n):
        H = abs(i-x[_]) + abs(j-y[_]) + h[_]
        if _ == 0:
            tmp = H
        elif tmp != H:
            return -1
    return H                        
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

for i in range(101):   #x
    for j in range(101):   #y
        if max(i,j) != -1:
            print(i,j,max(i,j))

Submission status: Wrong Answer

Solution code:
import math,fractions,sys
from collections import Counter
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
tmp = 0
if n == 1:
    print(x[0],y[0],h[0])
def max(i,j):
    for _ in range(n):
        H = abs(i-x[_]) + abs(j-y[_]) + h[_]
        if _ == 0:
            tmp = H
        elif tmp != H:
            return -1
    return H                        
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

for i in range(101):   #x
    for j in range(101):   #y
        if max(i,j) != -1:
            print(i,j,max(i,j))

Submission status: Wrong Answer

Solution code:
import math,fractions
from collections import Counter
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
tmp = 0
def max(i,j):
    for _ in range(n):
        H = abs(i-x[_]) + abs(j-y[_]) + h[_]
        if _ == 0:
            tmp = H
        elif tmp != H:
            return -1
    return H                        
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

for i in range(101):   #x
    for j in range(101):   #y
        if max(i,j) != -1:
            print(i,j,max(i,j))

Submission status: Wrong Answer

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

ans_cx,ans_cy,ans_H = 0,0,1
for cx in range(101):
    for cy in range(101):
        pro_height = []
        for i in range(n):
            if lst[i][2] != 0:
                h = lst[i][2] + abs(lst[i][0]-cx) + abs(lst[i][1]-cy)
                pro_height.append(h)
        if len(set(pro_height)) == 1:
            ans_H = pro_height[0]
            ans_cx = cx
            ans_cy = cy
            for a,b,c in lst:
                if c != max(ans_H - abs(ans_cx-a) - abs(ans_cy-b),0):
                    break
            print(ans_cx,ans_cy,ans_H)
            break

Submission status: Wrong Answer

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

ans_cx,ans_cy,ans_H = 0,0,1
for cx in range(101):
    for cy in range(101):
        pro_height = []
        for i in range(n):
            if lst[i][2] != 0:
                h = lst[i][2] + abs(lst[i][0]-cx) + abs(lst[i][1]-cy)
                pro_height.append(h)
            else:
              continue
        if len(set(pro_height)) == 1:
            ans_H = pro_height[0]
            ans_cx = cx
            ans_cy = cy
            break
print(ans_cx,ans_cy,ans_H)

Submission status: Wrong Answer

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

ans_cx,ans_cy,ans_H = 0,0,0
for cx in range(101):
    for cy in range(101):
        pro_height = []
        for i in range(n):
            if lst[i][2] != 0:
                h = lst[i][2] + abs(lst[i][0]-cx) + abs(lst[i][1]-cy)
                pro_height.append(h)
            else:
              continue
        if len(set(pro_height)) == 1:
            ans_H = pro_height[0]
            ans_cx = cx
            ans_cy = cy
            break
print(ans_cx,ans_cy,ans_H)

Submission status: Wrong Answer

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

ans_cx,ans_cy,ans_H = 0,0,1
for cx in range(101):
    for cy in range(101):
        pro_height = []
        for i in range(n):
            h = lst[i][2] + abs(lst[i][0]-cx) + abs(lst[i][1]-cy)
            pro_height.append(h)
        if len(set(pro_height)) == 1:
            ans_H = pro_height[0]
            ans_cx = cx
            ans_cy = cy
            break
print(ans_cx,ans_cy,ans_H)