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())
cordinate = [list(map(int, input().split())) for i in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for k in zero_height:
                if not max(H - abs(k[0] - i) - abs(k[1] - j), 0):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for k in zero_height:
                if max(k[2] + abs(k[0] - i) + abs(k[1] - j), 0):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for k in zero_height:
                if not max(k[2] + abs(k[0] - i) + abs(k[1] - j), 0):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for k in zero_height:
                if not max(k[2] + abs(k[0] - i) + abs(k[1] - j), 0):
                    break
                else:
                    print(i, j , H)
                    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_, y_, h_ = map(int, input().split())
    x.append(x_)
    y.append(y_)
    h.append(h_)

tmpli = [[-1] * 101 for i in range(101)]

first = True
for n in range(N):
    for i in range(0,101):
        for j in range(0,101):
            tmp = max(h[n] + abs(i-x[n]) + abs(j-y[n]), 0)
            if first:
                tmpli[i][j] = tmp
            else:
                if tmpli[i][j] != tmp:
                    tmpli[i][j] = -1
    first = False

for i in range(0,101):
    for j in range(0,101):
        if tmpli[i][j] != -1:
            print(str(i) + ' ' + str(j) + ' ' + str(tmpli[i][j]))
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            print(i, j , H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_, y_, h_ = map(int, input().split())
    x.append(x_)
    y.append(y_)
    h.append(h_)

tmpli = [[-1] * 101 for i in range(101)]

first = True
for n in range(N):
    for i in range(0,101):
        for j in range(0,101):
            if h[n] > 0:
                tmp = h[n] + abs(i-x[n]) + abs(j-y[n])
            else:
                tmp = 0
            if first:
                tmpli[i][j] = tmp
            else:
                if tmpli[i][j] != tmp:
                    tmpli[i][j] = -1
    first = False

for i in range(0,101):
    for j in range(0,101):
        if tmpli[i][j] != -1:
            print(str(i) + ' ' + str(j) + ' ' + str(tmpli[i][j]))
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        for k in cordinate:
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1 and H > 0:
            print(i, j , H)
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        for k in cordinate:
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                print(i, j, H, tmp)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1 and H > 0:
            print(i, j , H)
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        for k in cordinate:
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            print(i, j , H)
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = 0
        check = 0
        for k in cordinate:
            if H == 0:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            print(i, j , H)
            exit()

Submission status: Wrong Answer

Solution code:
#c 

N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_, y_, h_ = map(int, input().split())
    x.append(x_)
    y.append(y_)
    h.append(h_)

tmpli = [[-1] * 101 for i in range(101)]

first = True
for k in range(N):
    for i in range(0,101):
        for j in range(0,101):
            tmp = h[k] + abs(i-x[k]) + abs(j-y[k])
            if first:
                tmpli[i][j] = tmp
            else:
                if tmpli[i][j] != tmp:
                    tmpli[i][j] = -1
    first = False

for i in range(0,101):
    for j in range(0,101):
        if tmpli[i][j] != -1:
            print(str(i) + ' ' + str(j) + ' ' + str(tmpli[i][j]))
            exit()

Submission status: Wrong Answer

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

for i in range(N):
    _x, _y, _h = map(int, input().split())
    x.append(_x)
    y.append(_y)
    h.append(_h)

for c_x in range(101):
    for c_y in range(101):
        H = [h[i] + abs(x[i] - c_x) + abs(y[i] - c_y) for i in range(N) if h[i] > 0]

        if len(set(H)) == 1 and H[0] > 0:
            print(str(c_x) + " " + str(c_y) + " " + str(H[0]))

Submission status: Wrong Answer

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

for i in range(N):
    _x, _y, _h = map(int, input().split())
    x.append(_x)
    y.append(_y)
    h.append(_h)

for c_x in range(101):
    for c_y in range(101):
        H = [h[i] + abs(x[i] - c_x) + abs(y[i] - c_y) for i in range(N)]

        if len(set(H)) == 1:
            print(str(c_x) + " " + str(c_y) + " " + str(H[0]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
C - Pyramid
https://atcoder.jp/contests/abc112/tasks/abc112_c

"""
import sys


def solve(N, positions):
    if N == 1:
        return positions[0]
    for cy in range(101):
        for cx in range(101):
            is_valid = True
            x, y, h = positions[0]
            ph = h + abs(cy-y) + abs(cx-x)
            for x, y, h in positions[1:]:
                hh = h + abs(cy-y) + abs(cx-x)
                if hh != ph:
                    is_valid = False
                    break
            if is_valid:
                return (cx, cy, ph)
    return (0, 0, 0)

def main(args):
    N = int(input())
    positions = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, positions)
    print(*ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Wrong Answer

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


def GI():
    return int(input())


def GIS():
    return tuple(map(int, input().split()))


def main():
    n = GI()
    sols = list(filter(lambda x: x[2] > 0, [GIS() for _ in range(n)]))

    for cx in range(0, 101):
        for cy in range(0, 101):

            def estimate_height(xyh):
                return abs(xyh[0] - cx) + abs(xyh[1] - cy) + xyh[2]

            hs = set(map(estimate_height, sols))
            if len(hs) == 1:
                print(cx, cy, hs.pop())
                return


main()

Submission status: Wrong Answer

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


def GI():
    return int(input())


def GIS():
    return tuple(map(int, input().split()))


def main():
    n = GI()
    sols = [GIS() for _ in range(n)]

    for cx in range(0, 101):
        for cy in range(0, 101):

            def estimate_height(xyh):
                return abs(xyh[0] - cx) + abs(xyh[1] - cy) + xyh[2]

            hs = set(map(estimate_height, sols))
            if len(hs) == 1:
                print(cx, cy, hs.pop())
                return


main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
#l:調査情報のリスト
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
M=max(item[2] for item in l)#高さの最大値(暫定)
s=list(itertools.product(range(0,101),repeat=2))
#s:中心座標の候補リスト
for A,B in itertools.combinations(range(N),2):
  #調査情報の全ての2つ組を用いて絞り込む
  if len(s)==1:
    break
  t=[]
  #t:新たな中心座標の候補リスト
  if l[A][2]<l[B][2]:
    A,B=B,A
  AH = l[A][2]
  BH = l[B][2]
  for X,Y in s:
    AX = abs(X-l[A][0])
    AY = abs(Y-l[A][1])
    BX = abs(X-l[B][0])
    BY = abs(Y-l[B][1])
    gap = AH-BH
    if gap>0:
      #2地点の高さが異なる場合
      if BH==0:
        if AX+AY+gap<=BX+BY:
          t.append((X,Y))
      else:
        if AX+AY+gap==BX+BY:
          t.append((X,Y))
    elif AH!=0:
      #2地点の高さが等しく0ではない場合
      MM=max(1,M-AH)
      if AX+AY==BX+BY and AX+AY>=MM and BX+BY>=MM:
        t.append((X,Y))
    else:
      #2地点の高さが等しく0の場合
      #2地点からM以上離れた地点のみ残す
      if AX+AY>=M and BX+BY>=M:
        t.append((X,Y))
  s=t[:]
#sの要素は唯一だと思いたい
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:
N = int(input())
X = []
Y = []
H = []
for i in range(N):
  x, y, h = map(int, input().split())
  X.append(x)
  Y.append(y)
  H.append(h)
tmp = max(H)
for cx in range(101):
  for cy in range(101):
    ch = abs(cx - X[0]) + abs(cy - Y[0]) + H[0]
    for i in range(N):
      if H[i] != max(ch - abs(cx - X[i]) - abs(cy - Y[i]), 0):
        break
    else:
      print(cx, cy, ch)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    N = int(input())
    xyh_list = [list(map(int, input().split())) for i in range(N)]

    for c_y in range(0, 101):
        for c_x in range(0, 101):
            lastH = None
            for xyh_i in xyh_list:
                y_i = xyh_i[1]
                x_i = xyh_i[0]
                h_i = xyh_i[2]
                H = h_i + abs(c_y - y_i) + abs(c_x - x_i)
                # if H < 1:
                #     continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    N = int(input())
    xyh_list = [list(map(int, input().split())) for i in range(N)]

    for c_y in range(0, 101):
        for c_x in range(0, 101):
            lastH = None
            for xyh_i in xyh_list:
                y_i = xyh_i[1]
                x_i = xyh_i[0]
                h_i = xyh_i[2]
                H = h_i + abs(c_y - y_i) + abs(c_x - x_i)
                # if H < 1:
                #     continue
                if lastH is not None:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    N = int(input())
    xyh_list = [list(map(int, input().split())) for i in range(N)]

    for c_y in range(0, 101):
        for c_x in range(0, 101):
            lastH = None
            for xyh_i in xyh_list:
                y_i = xyh_i[1]
                x_i = xyh_i[0]
                h_i = xyh_i[2]
                H = h_i + abs(c_y - y_i) + abs(c_x - x_i)
                if H < 1:
                    continue
                if lastH is not None:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    N = int(input())
    xyh_list = [list(map(int, input().split())) for i in range(N)]

    for c_y in range(1, 101):
        for c_x in range(1, 101):
            lastH = None
            for xyh_i in xyh_list:
                y_i = xyh_i[1]
                x_i = xyh_i[0]
                h_i = xyh_i[2]
                H = h_i + abs(c_y - y_i) + abs(c_x - x_i)
                if H < 1:
                    continue
                if lastH is not None:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
#l:調査情報のリスト
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
M=max(item[2] for item in l)#高さの最大値(暫定)
s=list(itertools.product(range(0,101),repeat=2))
#s:中心座標の候補リスト
for A,B in itertools.combinations(range(N),2):
  #調査情報の全ての2つ組を用いて絞り込む
  if len(s)==1:
    break
  t=[]
  #t:新たな中心座標の候補リスト
  if l[A][2]<l[B][2]:
    A,B=B,A
  if l[A][2]>l[B][2]:
    #2地点の高さが異なる場合
    if l[B][2]==0:
      #B地点の高さが0ならB地点は中心から[Aの高さ]以上離れている
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap<=abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
    else:
      #B地点の高さが0でなければA地点は中心から[Aの高さ-Bの高さ]だけ離れている
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap==abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
  
  elif l[A][2]!=0:
    #2地点の高さが等しく0ではない場合
    #2地点からM-[Aの高さ]以上離れた地点のみ残す
    for X,Y in s:
      MM=max(1,M-l[A][2])
      if abs(X-l[A][0])+abs(Y-l[A][1])==abs(X-l[B][0])+abs(Y-l[B][1]) and abs(X-l[A][0])+abs(Y-l[A][1])>=MM and abs(X-l[B][0])+abs(Y-l[B][1])>=MM:
        t.append((X,Y))
  else:
    #2地点の高さが等しく0の場合
    #2地点からM以上離れた地点のみ残す
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>=M and abs(X-l[B][0])+abs(Y-l[B][1])>=M:
        t.append((X,Y))
  s=t[:]
#sの要素は唯一だと思いたい
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:
N = int(input())
x = []
y = []
h = []
Cx = 0
Cy = 0
H = 0

for i in range(N):
  temp_x,temp_y,temp_h = (int(x) for x in input().split())
  x.append(temp_x)
  y.append(temp_y)
  h.append(temp_h)
  
f = 0
if not H == 100:
  for i in range(101):
    if f == 1:
      break
    Cx = i
    for j in range(101):
      if f == 1:
        break
      Cy = j
      H = h[0] + abs(Cx-x[0]) + abs(Cy-y[0])
#      print("Cx:{} Cy:{} H:{}".format(Cx,Cy,H))
      f = 1
      for k in range(1,N):
        if not (H == h[k] + abs(Cx-x[k]) + abs(Cy-y[k])):
          f = 0
          break
print("{} {} {}".format(Cx,Cy,H))

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[list(map(int,input().split())) for x in range(n)]
l=[i for i in range(1,201)]
for i in range(101):
  for j in range(101):
    tmp1=set()
    tmp2=set()
    for k in range(n):
      if arr[k][2]!=0:
        tmp1.add(arr[k][2]+abs(arr[k][0]-i)+abs(arr[k][1]-j))
      else:
        tmp3=set(l[:abs(arr[k][0]-i)+abs(arr[k][1]-j)])
        if len(list(tmp2))==0:
          tmp2=tmp3
        else:
          tmp2=tmp2&tmp3
    if len(list(tmp2))==0:
      if len(list(tmp1))==1:
        print(i,j,list(tmp1)[0])
    else:
      if len(list(tmp1))==1 and len(list(tmp1&tmp2))==1:
        print(i,j,list(tmp1)[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=[list(map(int,input().split())) for x in range(n)]
for i in range(101):
  for j in range(101):
    tmp1=set()
    tmp2=set()
    for k in range(n):
      if arr[k][2]!=0:
        tmp1.add(arr[k][2]+abs(arr[k][0]-i)+abs(arr[k][1]-j))
      else:
        tmp3=set([i for i in range(1,abs(arr[k][0]-i)+abs(arr[k][1]-j)+1)])
        if len(list(tmp2))==0:
          tmp2=tmp3
        else:
          tmp2=tmp2&tmp3
    if len(list(tmp2))==0:
      if len(list(tmp1))==1:
        print(i,j,list(tmp1)[0])
    else:
      if len(list(tmp1))==1 and len(list(tmp1&tmp2))==1:
        print(i,j,list(tmp1)[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h = [],[],[]
for i in range(N):
    i1,i2,i3 = map(int,input().split())
    if h != 0:
        x.append(i1)
        y.append(i2)
        h.append(i3)
l = len(x)
Cx,Cy,Ch = -1,-1,-1
for i in range(101):
    for j in range(101):
        H = h[0]+abs(i-x[0])+abs(j-y[0])
        for k in range(l):
            if H != h[k]+abs(i-x[k])+abs(j-y[k]):
                break
            elif k == l-1:
                Cx,Cy,Ch = i,j,H
print(Cx,Cy,Ch)

Submission status: Wrong Answer

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

X,Y=-1,-1
for x in range(101):
  for y in range(101):
    flag = True
    _h = -1
    for i,j,h in li:
      kyo = abs(i-x)+abs(j-y)
      if (h>0):
        if (_h==-1):
          _h = kyo + h
        else:
          if (_h!=kyo+h):
            flag=False
            break
      else: #h==0
        if (_h>kyo):
          flag=True
          break
    for i,j,h in li:
      kyo = abs(i-x)+abs(j-y)
      if (h>0):
        if (_h==-1):
          _h = kyo + h
        else:
          if (_h!=kyo+h):
            flag=False
            break
      else: #h==0
        if (_h>kyo):
          flag=True
          break
    if (flag):
      X = x
      break
  if (flag):
    Y = y
    break
print (X,Y,_h)

Submission status: Wrong Answer

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

X,Y=-1,-1
for x in range(101):
  for y in range(101):
    flag = True
    _h = -1
    for i,j,h in li:
      kyo = abs(i-x)+abs(j-y)
      if (h>0):
        if (_h==-1):
          _h = kyo + h
        else:
          if (_h!=kyo+h):
            flag=False
            break
    for i,j,h in li:
      kyo = abs(i-x)+abs(j-y)
      if (h>0):
        if (_h==-1):
          _h = kyo + h
        else:
          if (_h!=kyo+h):
            flag=False
            break
    if (flag):
      X = x
      break
  if (flag):
    Y = y
    break
print (X,Y,_h)

Submission status: Wrong Answer

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

X,Y=-1,-1
for x in range(101):
  for y in range(101):
    flag = True
    _h = -1
    for i,j,h in li:
      kyo = abs(i-x)+abs(j-y)
      if (h>0):
        if (_h==-1):
          _h = kyo + h
        else:
          if (_h!=kyo+h):
            flag=False
            break
    if (flag):
      X = x
      break
  if (flag):
    Y = y
    break
print (X,Y,_h)

Submission status: Wrong Answer

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

ans_x = -1
ans_y = -1
ans_h = -1
for x in range(101):
    for y in range(101):
        flag = 0
        H = xyh[0][2] + abs(xyh[0][0]-x) + abs(xyh[0][1]-y)
        for k in xyh[1:]:
            if k[2] != max(H - abs(k[0]-x) - abs(k[1]-y),0):
                flag = 1
        if flag == 0 and H != 0:
            ans_x,ans_y,ans_h = x,y,H
print(ans_x,ans_y,ans_h)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        count = 0
        H = xyh[0][2] + abs(xyh[0][0]-x) + abs(xyh[0][1]-y)
        for k in xyh[1:]:
            if k[2] == max(H - abs(k[0]-x) - abs(k[1]-y),0):
                count += 1
        if count == n-1 and H != 0:
            print(x,y,H)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        count = 0
        H = xyh[0][2] + abs(xyh[0][0]-x) + abs(xyh[0][1]-y)
        for k in xyh[1:]:
            if k[2] == max(H - abs(k[0]-x) - abs(k[1]-y),0):
                count += 1
        if count == n-1:
            print(x,y,H)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        count = 0
        H = xyh[0][2] + abs(xyh[0][0]-x) + abs(xyh[0][1]-y)
        for k in xyh[1:]:
            if k[2] == H - abs(k[0]-x) - abs(k[1]-y):
                count += 1
        if count == n-1:
            print(x,y,H)

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
l=[]
#l:調査情報のリスト
for i in range(N):
  x,y,h=map(int,input().split())
  l.append([x,y,h])
M=max(item[2] for item in l)
s=list(itertools.product(range(0,101),repeat=2))
#s:中心座標の候補リスト
for A,B in itertools.combinations(range(N),2):
  #調査情報の全ての2つ組を用いて絞り込む
  if len(s)==1:
    break
  t=[]
  #t:新たな中心座標の候補リスト
  if l[A][2]<l[B][2]:
    A,B=B,A
  if l[A][2]>l[B][2]:
    #2地点の高さが異なる場合
    if l[B][2]==0:
      #B地点の高さが0ならB地点は中心から[Aの高さ]以上離れている
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap<=abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
    else:
      #B地点の高さが0でなければA地点は中心から[Aの高さ-Bの高さ]だけ離れている
      gap=l[A][2]-l[B][2]
      for X,Y in s:
        if abs(X-l[A][0])+abs(Y-l[A][1])+gap==abs(X-l[B][0])+abs(Y-l[B][1]):
          t.append((X,Y))
  
  elif l[A][2]!=0:
    #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:
    #2地点の高さが等しく0の場合
    #2地点が中心ではない
    for X,Y in s:
      if abs(X-l[A][0])+abs(Y-l[A][1])>=M and abs(X-l[B][0])+abs(Y-l[B][1])>=M:
        t.append((X,Y))
  s=t[:]
#sの要素は唯一だと思いたい
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:
n = int(input())
s = []
for i in range(n):
    a = list(map(int, input().split()))
    s.append(a)
for cx in range(101):
    for cy in range(101):
        cnt = 0
        for i in range(n):
            x, y, h = s[i]
            if cnt == 0:
                H = h + abs(cx-x) + abs(cy-y)
                cnt += 1
            elif cnt == n-1:
                if H == h + abs(cx-x) + abs(cy-y):
                    print(str(cx) + " " + str(cy) + " " + str(H))
            else:
                if H != h + abs(cx-x) + abs(cy-y):
                    break
                else:
                    cnt += 1

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        ll=[]
        flag=True
        for i in range(n):
            H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
            ll.append(H)
            if i!=0 and any(ll[j]!=ll[j-1] for j in range(1,i+1)):
                flag=False
                break
        if flag:
            print(cx,cy,H)
            break

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        ll=[]
        flag=True
        for i in range(n):
            H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
            ll.append(H)
            if i!=0 and all(ll[j]!=ll[j-1] for j in range(1,i+1)):
                flag=False
                break
        if flag:
            print(cx,cy,H)
            break

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
for cx in range(101):
    for cy in range(101):
        ll=[]
        flag=True
        for i in range(n):
            H=l[i][2]+abs(l[i][0]-cx)+abs(l[i][1]-cy)
            ll.append(H)
            if i!=0 and ll[i]!=ll[i-1]:
                flag=False
                break
        if flag:
            print(cx,cy,H)
            break

Submission status: Wrong Answer

Solution code:
from sys import stdin
N=int(stdin.readline().rstrip())
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

cnt=0
for X in range(0,101):
    for Y in range(0,101):
        for ind,data_ in enumerate(data):
            if ind == 0:
                h_log = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            H = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            if H == h_log:
                cnt+=1
            h_log = H
        if cnt == N:
            break
        cnt=0
    else:
        continue
    break
print(X,Y,H)

Submission status: Wrong Answer

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

xyhs = sorted(xyhs, key=lambda v: v[2], reverse=True)

ha = [[-1 for _ in range(101)] for _ in range(101)]
for xyh in xyhs:
    xi, yi, hi = xyh
    if hi == 0:
        continue

    for y in range(101):
        for x in range(101):
            if not ha[y][x]:
                continue

            h = hi + abs(xi - x) + abs(yi - y)
            if ha[y][x] == -1:
                ha[y][x] = h
            elif ha[y][x] != h:
                ha[y][x] = False

for y in range(101):
    for x in range(101):
        if ha[y][x]:
            print(x, y, ha[y][x])

Submission status: Wrong Answer

Solution code:
n = int(input())
ha = [[-1 for _ in range(101)] for _ in range(101)]
xyhs = []
for _ in range(n):
    xi, yi, hi = map(int, input().split())
    xyhs.append((xi, yi, hi))

for y in range(101):
    for x in range(101):
        ht = -1
        for xyh in xyhs:
            if xyh[2] != 0:
                xi, yi, hi = xyh
                ht = hi + abs(x - xi) + abs(y - yi)
                break

        flag = True
        for xyh in xyhs:
            xi, yi, hi = xyh
            hh = hi + abs(x - xi) + abs(y - yi)
            if hh != ht:
                flag = False
                break

        if flag:
            print(x, y, ht)