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())
XYH = []
for n in range(N):
  x, y, h = [int(xyh) for xyh in input().split()]
  if h > 0:
    XYH.append([x, y, h])

l_XYH = len(XYH)
HH = []
ans_H = 0
for cx in range(0, 101):
  for cy in range(0, 101):
    for k in range(l_XYH):
      xk, yk, hk = XYH[k]
      H = hk + abs(xk - cx) + abs(yk - cy)
      if k < l_XYH - 1:
        HH.append(H)
      elif (HH.count(H) == l_XYH - 1) and (H >= 1):
        ans_H = H
        break
      else:
        HH = []
        break
    else:
      continue
    if ans_H == H:
      break
  else:
    continue
  break

ans = str(cx) + " " + str(cy) + " " + str(ans_H)
print(ans)

Submission status: Wrong Answer

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

l_XYH = len(XYH)
HH = []
ans_H = 0
for cx in range(0, 101):
  for cy in range(0, 101):
    for k in range(l_XYH):
      xk, yk, hk = XYH[k]
      H = hk + abs(xk - cx) + abs(yk - cy)
      if k < l_XYH - 1:
        HH.append(H)
      elif HH.count(H) == l_XYH - 1:
        ans_H = H
        break
      else:
        HH = []
        break
    else:
      continue
    if ans_H == H:
      break
  else:
    continue
  break

ans = str(cx) + " " + str(cy) + " " + str(ans_H)
print(ans)

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        H = -1
        ok = True
        for x, y, h in P:
            if h == 0:
                continue
            Hi = abs(x-cx) + abs(y-cy) + h
            if H == -1:
                H = Hi
                continue
            if Hi != H:
                ok = False
                break
        if ok:
            print(cx, cy, H)
            break
    if ok:
        break

Submission status: Wrong Answer

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

for i in range(N):
    xt, yt, ht = map(int, input().split())
    x.append(xt)
    y.append(yt)
    h.append(ht)
    if ht != 0:
        cx = xt
        cy = yt
        htt = ht

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

Submission status: Wrong Answer

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

for i in range(N):
    xt, yt, ht = map(int, input().split())
    x.append(xt)
    y.append(yt)
    h.append(ht)
    if ht != 0:
        cx = xt
        cy = yt
        htt = ht

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

Submission status: Wrong Answer

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

for i in range(N):
    xt, yt, ht = map(int, input().split())
    x.append(xt)
    y.append(yt)
    h.append(ht)
    if ht !=0:
        cx = xt
        cy =yt
        htt =ht


for j in range(101):
    for k in range(101):
        H=htt +abs(cx-j)+abs(cy-k)
        for i in range(N):
            if H != abs(x[i] - j) + abs(y[i] - k) + h[i]:
                break
        if i==N-1:
            print(j, k, H)

Submission status: Wrong Answer

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

for i in range(N):
    xt, yt, ht = map(int, input().split())
    x.append(xt)
    y.append(yt)
    h.append(ht)
    if ht !=0:
        cx = xt
        cy =yt
        htt =ht


for j in range(101):
    for k in range(101):
        H=htt +abs(cx-j)+abs(cy-k)
        for i in range(N):
            if H != abs(x[i] - j) + abs(y[i] - k) + h[i]:
                break
            if i == N - 1:
                H = abs(x[0] - j) + abs(y[0] - k) + h[0]
                print(j, k, H)

Submission status: Wrong Answer

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

for j in range(101):
    for k in range(101):
        for i in range(1,len(x)):
            if abs(x[i-1]-j)+abs(y[i-1]-k)+h[i-1]!=abs(x[i]-j)+abs(y[i]-k)+h[i]:
                break
            if i == len(x)-1:
                H = abs(x[0]-j)+abs(y[0]-k)+h[0]
                print(j,k,H)

Submission status: Wrong Answer

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

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

ans_x = -1
ans_y = -1
ans_h = -1

for x in range(101):
  for y in range(101):
    flg = True
    H = s[0][2] + abs(s[0][0] - x) + abs(s[0][1] - y)
    if(H <= 0):
      flg = False
      break

    else:
      for i in range(n - 1):
        h = max( ( H - abs(s[i+1][0] - x) - abs(s[i+1][1] - y) ) ,0)
        if(h != s[i+1][2]):
          flg = False
          break
    if flg:
      ans_y = y
      ans_h = H
      break

  if flg:
    ans_x = x
    break

print("{} {} {}".format(ans_x,ans_y,ans_h))

Submission status: Wrong Answer

Solution code:


import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n=getint()

values=[getints() for _ in range(n)]

check = []
for h in values:
    if h[2] > 0:
        check = h
        break

check_x, check_y, check_h = check

for cx in range(101):
    for cy in range(101):
        H = check_h + abs(check_x - cx) + abs(check_y - cy)
        ok = True
        for x,y,h in values:
            h_prime = max(0, H - abs(x-cx) - abs(y-cy))
            if h_prime != h:
                ok = False
                break
        if ok:
            print(cx,cy,h)
            sys.exit(0)

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        mh = 10000000000
        h = []
        for i in range(n):
            x,y,z = xyz[i][0],xyz[i][1],xyz[i][2]
            if z == 0:
                mh = min(mh,abs(x-cx)+abs(y-cy))
            else:
                if len(h) == 0:
                    h.append(z+abs(x-cx)+abs(y-cy))
                else:
                    if h[0] != z+abs(x-cx)+abs(y-cy):
                        h = []
                        break
                    elif h[0]>mh:
                        h = []
                        break
            if len(h)>0 and h[0]>mh:
                break
        if len(h) > 0:
            ans = str(cx)+" "+str(cy)+" "+str(h[0])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = 0
    identified = True
    for survey in surveys:
      if survey[2] == 0:
        continue
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != 0 and before != height:
        identified = False
        continue
      before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = 0
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != 0 and height != 0 and before != height:
        identified = False
        continue
      if height != 0:
        before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = 0
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if height != 0 and before != height:
        identified = False
        continue
      if height != 0:
        before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
surveys = [list(map(int, input().split())) for _ in range(N)]
for x in range(101):
  for y in range(101):
    before = 0
    identified = True
    for survey in surveys:
      height = survey[2] + abs(x-survey[0]) + abs(y-survey[1])
      if before != 0 and before != height:
        identified = False
        continue
      before = height
    if identified:
      print(x, y, before)

Submission status: Wrong Answer

Solution code:
N = int(input())
Z = [list(map(int, input().split())) for i in range(N)]
Z = sorted(Z, key = lambda x:x[2])
last = Z[-1]

for i in range(101):
  for j in range(101):
    H = last[2] + abs(i - last[0]) + abs(j - last[1])
    k, count = 0, 0 
    while count == 0 and k <= N - 1:
      if H != max(Z[k][2] + abs(i - Z[k][0]) +abs(j - Z[k][1]), 0):
        count += 1
      k += 1
    if count == 0:
      print(i, j, H)
      quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
Z = [list(map(int, input().split())) for i in range(N)]
Z = sorted(Z, key = lambda x:x[2])
last = Z[-1]

for i in range(101):
  for j in range(101):
    H = last[2] + abs(i - last[0]) + abs(j - last[1])
    k, count = 0, 0 
    while count == 0 and k <= N - 1:
      if H != max(Z[k][2] + abs(i - Z[k][0]) +abs(j - Z[k][1]), 0):
        count += 1
      k += 1
    if count == 0:
      print(i, j, H)
      break

Submission status: Wrong Answer

Solution code:
N = int(input())
Z = [list(map(int, input().split())) for i in range(N)]
Z = sorted(Z, key = lambda x:x[2])
last = Z[-1]

for i in range(101):
  for j in range(101):
    H = last[2] + abs(i - last[0]) + abs(j - last[1])
    k, count = 0, 0 
    while count == 0 and k <= N - 1:
      if H != Z[k][2] + abs(i - Z[k][0]) +abs(j - Z[k][1]):
        count += 1
      k += 1
    if count == 0:
      print(i, j, H)
      break

Submission status: Wrong Answer

Solution code:
n = int(input())
x=[0 for i in range(n)]
y=[0 for i in range(n)]
h=[0 for i in range(n)]


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

chk = [-1 for i in range(n)]
'''
座標を一個ずつ見ていき，
今いる座標が頂点だったとき，与えられた全ての点から見て今の位置が一様であることを調べる。
'''
for i in range(100+1):
    for j in range(100+1):
        for k in range(n):
            chk[k] = h[k] + abs(x[k]- i) + abs(y[k]-j)
            if len(set(chk)) == 1:
                print(i,j,chk[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
x=[0 for i in range(n)]
y=[0 for i in range(n)]
h=[0 for i in range(n)]


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

#pointを1つずつ見ていって，pontが頂点とした時，各点の位置
#理論通りかを調べる
for i in range(100+1):
    for j in range(100+1):
        h_tmp0 = h[0]+abs(x[0]- i) + abs(y[0]-j)
        for k in range(1,n):
            h_tmp1 = h[k] + abs(x[k]- i) + abs(y[k]-j)
            #print("dubug",h_tmp0,h_tmp1,i,j)
            if h_tmp0 != h_tmp1:
                break            
            elif k == n-1:
                print(i,j,h_tmp1)

Submission status: Wrong Answer

Solution code:
N = int(input())
data = []

min_x = 9999
max_x = 0
min_y = 9999
max_y = 0
for i in range(N):
    x, y, h = map(int, input().split())
    min_x = min(min_x, x)
    max_x = max(max_x, x)
    min_y = min(min_y, y)
    max_y = max(max_y, y)
    data.append([x, y, h])

data = sorted(data, key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        flag = True
        H = data[0][2] + abs(data[0][0]-cx) + abs(data[0][1]-cy)

        for i in range(N):
            if data[i][2] == max(H - abs(data[i][0]-cx) - abs(data[i][1]-cy), 0):
                flag = True
            else:
                flag = False

        if flag:
            if max_x > cx and cx > min_x and max_y > cy and cy > min_y:
                print(cx, cy, H)
                exit()

Submission status: Wrong Answer

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

data = sorted(data, key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        flag = True
        H = data[0][2] + abs(data[0][0]-cx) + abs(data[0][1]-cy)

        for i in range(N):
            if data[i][2] == max(H - abs(data[i][0]-cx) - abs(data[i][1]-cy), 0):
                flag = True
            else:
                flag = False

        if flag:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

data = []

max_x = 0
max_y = 0
for i in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        continue
    max_x = max(x, max_x)
    max_y = max(y, max_y)
    data.append([x, y, h])


for cx in range(101):
    for cy in range(101):
        hoge = 0
        valid_data = 0
        tmp = 0
        for i in range(len(data)):
            if len(data) == 1:
                if data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy) > 0:
                    print(cx, cy, data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy))
                    exit()
            if i == 0:
                tmp = data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
            else:
                if tmp == data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy):
                    hoge += 1
                    if hoge == len(data)-1:
                        print(cx, cy, data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy))

Submission status: Wrong Answer

Solution code:
N = int(input())

data = []

max_x = 0
max_y = 0
for i in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        continue
    max_x = max(x, max_x)
    max_y = max(y, max_y)
    data.append([x, y, h])


for cx in range(101):
    for cy in range(101):
        hoge = 0
        valid_data = 0
        tmp = 0
        for i in range(len(data)):
            if len(data) == 1:
                print(cx, cy, data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy))
                exit()
            if i == 0:
                tmp = data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
            else:
                if tmp == data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy):
                    hoge += 1
                    if hoge == len(data)-1:
                        print(cx, cy, data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy))

Submission status: Wrong Answer

Solution code:
N = int(input())

data = []

max_x = 0
max_y = 0
for i in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        continue
    max_x = max(x, max_x)
    max_y = max(y, max_y)
    data.append([x, y, h])


for cx in range(101):
    for cy in range(101):
        hoge = 0
        valid_data = 0
        tmp = 0
        for i in range(len(data)):
            if i == 0:
                tmp = data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
            else:
                if tmp == data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy):
                    hoge += 1
                    if hoge == len(data)-1:
                        print(cx, cy, data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy))

Submission status: Wrong Answer

Solution code:
N = int(input())

data = []

max_x = 0
max_y = 0
for i in range(N):
    x, y, h = map(int, input().split())
    max_x = max(x, max_x)
    max_y = max(y, max_y)
    data.append([x, y, h])


for cx in range(101):
    for cy in range(101):
        hoge = 0
        valid_data = 0
        for i in range(N):
            if i == 0:
                tmp = data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
            else:
                if data[i][2] > 0:
                    valid_data += 1

                if tmp == data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy):
                    hoge += 1
                    if hoge == valid_data and i == (N-1):
                        print(cx, cy, data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy))
                        exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

data = []

max_x = 0
max_y = 0
for i in range(N):
    x, y, h = map(int, input().split())
    max_x = max(x, max_x)
    max_y = max(y, max_y)
    data.append([x, y, h])


for cx in range(101):
    for cy in range(101):
        hoge = 0
        for i in range(N):
            if i == 0:
                tmp = data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
            else:
                if tmp == data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy):
                    hoge += 1
                    if hoge == N-1:
                        print(cx, cy, data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy))
                        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
  if step == n:
    print('TLE')
print(' '.join(list(map(str,can[0]))))

Submission status: Wrong Answer

Solution code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del now
      else:
        cnt += 1
  step += 1
  if step == n:
    print('TLE')
print(' '.join(list(map(str,can[0]))))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			needH = -1
			for i in range(n):
				if h[i] > 0:
					tmp = h[i] + abs(x[i]-s) + abs(y[i]-t)
					if needH == -1:
						needH = tmp
					elif needH != tmp:
						needH = -2
						break
			if needH == -2:
				continue
			for i in range(n):
				if h[i] == 0 and needH > abs(x[i]-s) + abs(y[i]-t):
					needH == -2
					break
			if needH == -2:
				continue
			else:
				print("{} {} {}".format(s, t, needH))

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				if h[i] != 0:
					H = h[i] + abs(x[i]-s) + abs(y[i]-t)
					gr.add(H)
			for i in range(n):
				if h[i] == 0:
					gr = {k for k in gr if k <= abs(x[i]-s) + abs(y[i]-t)}

			if len(gr) == 1:
				u = gr.pop()
				print(s, t, u)
				return

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				if h[i] != 0:
					H = h[i] + abs(x[i]-s) + abs(y[i]-t)
					gr.add(H)
				else:
					gr = {k for k in gr if k <= abs(x[i]-s) + abs(y[i]-t)}

			if len(gr) == 1:
				h = gr.pop()
				if h >= 0:
					print(s, t, h)
					return

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				if h[i] != 0:
					H = h[i] + abs(x[i]-s) + abs(y[i]-t)
					gr.add(H)

			if len(gr) == 1:
				h = gr.pop()
				if h >= 0:
					print(s, t, h)
					return

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				H = h[i] + abs(x[i]-s) + abs(y[i]-t)
				gr.add(H)

			if len(gr) == 1:
				h = gr.pop()
				if h >= 0:
					print(s, t, h)
					return

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())

pos = [[int(x) for x in input().split(' ')] for _ in range(n)]

for cx, cy in product(range(101), range(101)):
    H = max(max([abs(p[0]-cx)+abs(p[1]-cy)+p[2] for p in pos if p[2] != 0]), 1)
    if all(max(H-abs(p[0]-cx)-abs(p[1]-cy), 0) == p[2] for p in pos if p[2] != 0):
        print(cx, cy, H)
        exit()

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())

pos = [[int(x) for x in input().split(' ')] for _ in range(n)]

for cx, cy in product(range(101), range(101)):
    ans = set(abs(p[0]-cx)+abs(p[1]-cy)+p[2] for p in pos)
    if len(ans) == 1:
        print(cx, cy, ans.pop())
        exit()

Submission status: Wrong Answer

Solution code:
from itertools import product
n = int(input())

pos = [[int(x) for x in input().split(' ')] for _ in range(n)]
highest = max([x[2] for x in pos])

while highest < 10**9:
    for cx, cy in product(range(101), range(101)):
        ans = [[cx, cy, highest] for x, y, h in pos if highest-abs(x-cx)-abs(y-cy) == h]
        if len(ans) == len(pos):
            ans = ans[0]
            print('{} {} {}'.format(ans[0], ans[1], ans[2]))
            exit()
    highest += 1

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        once = True
        for i in range(n):
            d = abs(l[i][0]-x) + abs(l[i][1]-y)
            now = l[i][2] + d
            
            if l[i][2] == 0:
                if once:
                    break
                if mae <= now:
                    continue
                else:
                    break
            
            if once:
                mae = now
                once = False
                continue
                    
            if mae != now:
                break
            mae = now
        else:
            ans = list(map(str, [x, y, now]))
            print(" ".join(ans))
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        once = True
        for i in range(n):
            if l[i][2] == 0:
                continue
            d = abs(l[i][0]-x) + abs(l[i][1]-y)
            now = l[i][2] + d
            if once:
                mae = now
                once = False
            elif mae != now:
                break
            mae = now
        else:
            ans = list(map(str, [x, y, now]))
            print(" ".join(ans))
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        for i in range(n):
            d = abs(l[i][0]-x) + abs(l[i][1]-y)
            now = l[i][2] + d
            if i == 0:
                mae = now
            elif mae != now:
                break
            mae = now
        else:
            ans = list(map(str, [x, y, now]))
            print(" ".join(ans))
            exit()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	xyh = [list(map(int,input().split())) for _ in range(n)]
	possible = []
	for x in range(101):
		for y in range(101):
			flag = True
			h = abs(xyh[0][0]-x) + abs(xyh[0][1]-y) + xyh[0][2]
			for i in range(1,n):
				if(h != abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]):
					flag = False
			if flag:
				print('{} {} {}'.format(x,y,h))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	xyh = [list(map(int,input().split())) for _ in range(n)]
	possible = []
	for x in range(101):
		for y in range(101):
			flag = True
			h = abs(xyh[0][0]-x) + abs(xyh[0][1]-y) + xyh[0][2]
			for i in range(1,n):
				if(h != abs(xyh[i][0]-x) + abs(xyh[i][1]-y) + xyh[i][2]):
					flag = False
			if flag:
				print('{} {} {}'.format(x,y,h))
				exit()

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = p[0]
        h = abs(x0 - cx) + abs(y0 - cy) + h0
        if all(max(h - abs(xi - cx) - abs(yi - cy), 0) == hi for xi, yi, hi in p):
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        x0, y0, h0 = p[0]
        h = abs(x0 - cx) + abs(y0 - cy) + h0
        if all(h - abs(xi - cx) - abs(yi - cy) == hi for xi, yi, hi in p):
            print(cx, cy, h)
            exit()