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())
H = [[0] * 101 for i in range(101)]
ans = 0
X = 0
Y = 0
for i in range(n):
    x,y,h = map(int, input().split())
    for j in range(101):
        for k in range(101):
            if i == 0:
                H[j][k] = h + abs(x-j) + abs(y-k)
            else:
                if H[j][k] < 0:
                    continue
                else:
                    if H[j][k] != h + abs(x-j) + abs(y-k):
                        H[j][k] = -1
            
for i, tmp in enumerate(H):
    for j, xy in enumerate(tmp):
        if ans < xy:
            ans = xy
            X = i
            Y = j

print(X,Y,ans)

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

n = int(input())
xyh = sorted([list(map(int, input().split())) for i in range(n)], key = itemgetter(2))
X,Y,H = xyh[0][0],xyh[0][1],xyh[0][2]
if n == 1:
  print(X,Y,H)
  exit()
for cx in range(101):
  for cy in range(101):
    height = abs(cx-X) + abs(cy-Y) + H
    for x,y,h in xyh:
      if height != abs(cx-x) + abs(cy-y) + h:
        break
    else:
      print(cx,cy,height)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
for X in range(0,101):
    for Y in range(0,101):
        H=xyh[0][2]+abs(xyh[0][0]-X)+abs(xyh[0][1]-Y)
        for i in range(1,n):
            x,y,h=xyh[i]
            if h!=max(H-abs(x-X)-abs(y-Y),0):
                break
        else:
            print(X,Y,H)
            break

Submission status: Wrong Answer

Solution code:

def solve():

    N = int(input())
    xs = []
    ys = []
    hs = []

    for i in range(N):
        x, y, h = map(int, input().split())
        if h != 0:
            xs.append(x)
            ys.append(y)
            hs.append(h)

    for centerx in range(101):
        for centery in range(101):
            # 0の場合で仮置
            H = hs[0]+abs(centerx - xs[0]) + abs(centery - ys[0])
            flag = True
            for i in range(len(xs)):
                if hs[i] != max(0, H-abs(centerx - xs[i]) - abs(centery - ys[i])):
                    flag = False
                    break
            if flag:
                print(centerx, centery, H)
                exit()


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:


def solve():

    N = int(input())
    xs = [-1] * N
    ys = [-1] * N
    hs = [-1] * N

    for i in range(N):
        xs[i], ys[i], hs[i] = map(int, input().split())

    for centerx in range(101):
        for centery in range(101):
            # 0の場合で仮置
            H = abs(centerx - xs[0]) + abs(centery - ys[0]) + hs[0]
            flag = True
            for i in range(N):
                if hs[i] != max(0, H-abs(centerx - xs[i]) - abs(centery - ys[i])):
                    flag = False
                    break
            if flag:
                print(centerx, centery, H)
                exit()


if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
# Cx, Cyは0〜100の整数なので、101 * 101パターンを全探索

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

for Cx in range(101):
  for Cy in range(101):
    H = -1
    for i in range(len(data)):
      if data[i][2]<1:
        continue
      H = data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy)
      break
    for i in range(len(data)):
      if H != data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Submission status: Wrong Answer

Solution code:
# Cx, Cyは0〜100の整数なので、101 * 101パターンを全探索

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

for Cx in range(101):
  for Cy in range(101):
    H = data[0][2] + abs(data[0][0] - Cx) + abs(data[0][1] - Cy)
    if H - abs(data[0][0] - Cx) - abs(data[0][1] -Cy) <= 0:
      continue
    if H <= 0:
      continue
    for i in range(1,len(data)):
      if H != data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Submission status: Wrong Answer

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            flg = False
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    pass
                else:
                    ht = m + h
                    if ht < 1:
                        break
                    if flg:
                        if ht != ha:
                            flg = False
                            break
                    else:
                        flg = True
                        ha = ht
            
            if flg:
                if ha:
                    print(cx, cy, ha)
                    exit()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmin, hmax = 0, 10**10
            flg = False
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        break
                    if flg:
                        if ht != ha:
                            flg = False
                            break
                    else:
                        flg = True
                        ha = ht
            
            if flg:
                if ha:
                    print(cx, cy, ha)
                    exit()
            """if hmax == hmin:
                print(cx, cy, hmax)
                exit()"""


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmin, hmax = 0, 10**10
            flg = False
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        break
                    if flg:
                        if ht != ha:
                            flg = False
                            break
                    else:
                        flg = True
                        ha = ht
            
            if flg:
                if ha:
                    print(cx, cy, ha)
                    exit()
            if hmax == hmin:
                print(cx, cy, hmax)
                exit()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    for cx in range(0, 101):
        for cy in range(0, 101):
            hmin, hmax = 0, 10**10
            flg = False
            ha = 0
            for x, y, h in inp:
                m = abs(x-cx) + abs(y-cy)
                if h == 0:
                    hmax = min(hmax, m)
                else:
                    ht = m + h
                    if ht < 1:
                        break
                    if flg:
                        if ht != ha:
                            flg = False
                            break
                    else:
                        flg = True
                        ha = ht
            
            if flg:
                if ha:
                    print(cx, cy, ha)
                    exit()
            if hmax == hmin:
                print(hmax)
                exit()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# Cx, Cyは0〜100の整数なので、101 * 101パターンを全探索

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

for Cx in range(101):
  for Cy in range(101):
    H = data[0][2] + abs(data[0][0] - Cx) + abs(data[0][1] - Cy)
    if H - abs(data[0][0] - Cx) + abs(data[0][1] -Cy) < 0:
      continue
    for i in range(1,len(data)):
      if H != data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Submission status: Wrong Answer

Solution code:
# Cx, Cyは0〜100の整数なので、101 * 101パターンを全探索

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

for Cx in range(0,101):
  for Cy in range(0,101):
    H = data[0][2] + abs(data[0][0] - Cx) + abs(data[0][1] - Cy)
    if H < 1:
      continue
    for i in range(1,len(data)):
      if H != data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Submission status: Wrong Answer

Solution code:
# Cx, Cyは0〜100の整数なので、101 * 101パターンを全探索

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

for Cx in range(0,101):
  for Cy in range(0,101):
    H = max(data[0][2] + abs(data[0][0] - Cx) + abs(data[0][1] - Cy),0)
    if H < 1:
      continue
    for i in range(1,len(data)):
      if H != max(data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy),0):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        l = 0
        while h[l] == 0:
            l += 1
        #print(l)
        val = h[l] + abs(i-x[l]) + abs(j-y[l])
        flg = True
        for k in range(n):
            if val != h[k] + abs(i-x[k]) + abs(j-y[k]) and h[k] != 0:
                flg = False
            if val != h[k] + abs(i-x[k]) + abs(j-y[k]) and val - (abs(i-x[k]) + abs(j-y[k])) == 0 and h[k] == 0:
                flg = False
        if flg == True:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        l = 0
        while h[l] == 0:
            l += 1
        #print(l)
        val = h[l] + abs(i-x[l]) + abs(j-y[l])
        cnt = 0
        for k in range(n):
            if val == h[k] + abs(i-x[k]) + abs(j-y[k]) or h[k] == 0:
                cnt += 1
        if cnt == n and val > ans[2]:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        val = h[0] + abs(i-x[0]) + abs(j-y[0])
        cnt = 0
        for k in range(n):
            if val == h[k] + abs(i-x[k]) + abs(j-y[k]) or h[k] == 0:
                cnt += 1
        if cnt == n and val > ans[2]:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        val = h[0] + abs(i-x[0]) + abs(j-y[0])
        cnt = 0
        for k in range(n):
            if val == h[k] + abs(i-x[k]) + abs(j-y[k]):
                cnt += 1
        if cnt == n and val > ans[2]:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
# Cx, Cyは0〜100の整数なので、101 * 101パターンを全探索

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

for Cx in range(0,101):
  for Cy in range(0,101):
    H = max(data[0][2] + abs(data[0][0] - Cx) + abs(data[0][1] - Cy),0)
    for i in range(1,len(data)):
      if H != max(data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy),0):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [0] * n
y = [0] * n
h = [0] * n
for i in range(n):
    x2, y2, h2 = map(int, input().split())
    x[i] = x2
    y[i] = y2
    h[i] = h2
ans = [0,0,0]
for i in range(101):
    for j in range(101):
        val = h[0] + abs(i-x[0]) + abs(j-y[0])
        cnt = 0
        for k in range(n):
            if val == h[k] + abs(i-x[k]) + abs(j-y[k]):
                cnt += 1
        if cnt == n:
            ans = [i,j,val]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
# Cx, Cyは0〜100の整数なので、101 * 101パターンを全探索

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

for Cx in range(0,101):
  for Cy in range(0,101):
    H = data[0][2] + abs(data[0][0] - Cx) + abs(data[0][1] - Cy)
    for i in range(1,len(data)):
      if H != data[i][2] + abs(data[i][0] - Cx) + abs(data[i][1] - Cy):
        break
    else:
      print(Cx,Cy,H)
      exit(0)

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    info = []
    for _ in range(N):
        tmp = tuple(map(int,input().split()))
        info.append(tmp)
    
    for cx in range(101):
        for cy in range(101):
            isOk = True
            prevH = 0
            H = 0
            for i in range(N):
                x,y,h = info[i]
                H = h + abs(x-cx) + abs(y-cy)
                if i != 0 and prevH != H:
                    isOk = False
                    break
                prevH = H
            
            if isOk:
                print(cx,cy,H)
                
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
N = int(input())

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(1, N):
            h = A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
            if A[i][2] != 0:
                    if H != h:
                        Flag = False
                        break
            else:
                if H > abs(A[i][0]-x)+abs(A[i][1]-y):
                    Flag = False
                    break
        if Flag == True:
            print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(1, N):
            h = A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
            if A[1][2] != 0:
                    if H != h:
                        Flag = False
                        break
            else:
                if H > abs(A[i][0]-x)+abs(A[i][1]-y):
                    Flag = False
                    break
        if Flag == True:
            print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(N):
            h = A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
            if A[1][2] != 0:
                    if H != h:
                        Flag = False
                        break
            else:
                if H > abs(A[i][0]-x)+abs(A[i][1]-y):
                    Flag = False
                    break
        if Flag == True:
            print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(N):
            h = A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
            if A[1][2] != 0:
                    if H != h:
                        Flag = False
                        break
                    else:
                        continue
            else:
                if H <= abs(A[i][0]-x)+abs(A[i][1]-y):
                    continue
                else:
                    Flag = False
                    break
        if Flag == True:
            print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

A=[]
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(N):
            h = A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
            if H != h or h < 1:
                Flag = False
                break
            else:
                continue
        if Flag == True:
            print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

A=[]
h_low = 1
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])
    h_low = max(h_low, c)

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(N):
            h = A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
            if H != h:
                Flag = False
                break
            else:
                continue
        if Flag == True:
            print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

A=[]
h_low = 1
for i in range(N):
    a, b, c = map(int, input().split())
    A.append([a, b, c])
    h_low = max(h_low, c)

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

for x in range(0, 101):
    for y in range(0, 101):
        H = A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        Flag = True
        for i in range(N):
            h = A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
            if  A[i][2] > h:
                Flag = False
                break
            elif H != h:
                Flag = False
                break 
            else:
                continue
        if Flag == True:
            print(x, y, H)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
xyh = []
for _ in range(n):
    xyh.append(LIST())
for x in range(0, 101):
    for y in range(0, 101):
        h = -1
        flag = True
        for i in range(n):
            clc = abs(x - xyh[i][0]) + abs(y - xyh[i][1])
            if xyh[i][2] == 0:
                continue
            if xyh[i][2] + clc == h or h == -1:
                h = xyh[i][2] + clc
            else:
                flag = False
                break
        if flag and h > 0:
            print(x, y, h)
            exit()

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
xyh = []
for _ in range(n):
    xyh.append(LIST())
for x in range(0, 101):
    for y in range(0, 101):
        h = -1
        flag = True
        for i in range(n):
            clc = abs(x - xyh[i][0]) + abs(y - xyh[i][1])
            if xyh[i][2] + clc == h or h == -1:
                h = xyh[i][2] + clc
            else:
                flag = False
                break
        if flag:
            print(x, y, h)
            exit()

Submission status: Wrong Answer

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

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

def height(i, j, xn, yn, hn):
    return abs(j - xn) + abs(i - yn) + hn

def check(i, j, x, y, h):
    N = len(x)
    a = []
    for t in range(N):
        if h[t] != 0:
            a.append(height(i, j, x[t], y[t] , h[t]))
    a = list(a)
    return max(a) if max(a) == min(a) else -1

for i in range(101):
    for j in range(101):
        p = check(i, j, x, y, h)
        if p >= 1:
            break
    if p >= 1:
        break

print(j, i, p)

Submission status: Wrong Answer

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

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

def height(i, j, xn, yn, hn):
    return max(abs(j - xn) + abs(i - yn) + hn, 0);

def check(i, j, x, y, h):
    N = len(x)
    a = [height(i, j, x[t], y[t] , h[t]) for t in range(N)]
    return max(a) if max(a) == min(a) else -1

for i in range(101):
    for j in range(101):
        p = check(i, j, x, y, h)
        if p >= 1:
            break
    if p >= 1:
        break

print(j, i, p)

Submission status: Wrong Answer

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

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

def height(i, j, xn, yn, hn):
    return abs(j - xn) + abs(i - yn) + hn;

def check(i, j, x, y, h):
    N = len(x)
    a = [height(i, j, x[t], y[t] , h[t]) for t in range(N)]
    return max(a) if max(a) == min(a) else -1

for i in range(101):
    for j in range(101):
        p = check(i, j, x, y, h)
        if p >= 1:
            break
    if p >= 1:
        break

print(j, i, p)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

for cx in range(101):
    for cy in range(101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1, N):
            x, y, h = xyh[i]
            if h > 0:
                if H != h + abs(x - cx) + abs(y - cy):
                    flag = False
                    break
            else:
                if H > abs(x - cx) + abs(y - cy):
                    flag = False
                    break
        if flag:
            ans = [cx, cy, H]
            print(*ans)
            exit()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

for cx in range(101):
    for cy in range(101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1, N):
            if H != xyh[i][2] + abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy):
                flag = False
                break
        if flag:
            ans = [cx, cy, H]
            print(*ans)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l = [list(map(int,input().split())) for i in range(n)]
preH=0
cnt=0
for i in range(101):
    for j in range(101):
        for x,y,h in l:
            ls=[]
            H=h + abs(x-i) + abs(y-j)
            if preH==0:
                preH = H
                cnt+=1
            elif preH!=H:
                preH=0
                cnt=0
                break
            elif preH == H:
                preH = H
                cnt+=1
                if cnt==n:
                    print(i,j,H)
                    exit()

Submission status: Wrong Answer

Solution code:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        if preH!=0 and preH>abs(x-cx)+abs(y-cy):
          isans=False
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    if isans:
      print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#h=H-|X-Cx|-|Y-Cy|    h=0
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        if preH!=0 and preH<=abs(x-cx)+abs(y-cy):
          isans=False
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    if isans:
      print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    for i in range(N):
      x,y,h=S[i]
      if h<0:
        continue
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    if isans:
      print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
N=int(input())

#h=max(H-|X-Cx|-|Y-Cy|,0)
#H=h+|X-Cx|+|Y-Cy|
S=[]
for i in range(N):
  x,y,h=map(int, input().split())
  S.append((x,y,h))

for cx in range(100+1):
  for cy in range(100+1):
    isans=True
    preH=0
    for i in range(N):
      x,y,h=S[i]
      if h==0:
        continue
      else:
        H=h+abs(x-cx)+abs(y-cy)
        #print(H)
        if preH==0:
          preH=H
        elif preH!=H:
          isans=False
        preH=H
    if isans:
      print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = int(input().strip())
xyh = [[int(str) for str in input().strip().split()] for _ in range(N)]

H = 0
for cx in range(101):
    for cy in range(101):
        hs = [h + abs(x - cx) + abs(y - cy) for x, y, h in xyh if h != 0]
        if len(set(hs)) == 1:
            print(cx, cy, hs[0])

Submission status: Wrong Answer

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

"""
方針：0<=cx,cy<=100なのでcx,cyの特定は全数探索で間に合う
(cx,cy)があっていればh+(abs(cx-x)+abs(cy-y))=const
"""

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

for cx in range(101):
	for cy in range(101):
		const = xyh[0][2] + (abs(cx-xyh[0][0]) + abs(cy-xyh[0][1]))
		correct_center = True
		for i in range(N):
			if const != xyh[i][2] + (abs(cx-xyh[i][0]) + abs(cy-xyh[i][1])) \
			and xyh[i][2] > 0:
				correct_center = False
				break
		if correct_center:
			break
	if correct_center:
		break

H = xyh[0][2] + abs(cx-xyh[0][0]) + abs(cy-xyh[0][1])
print(cx,cy,H)

Submission status: Wrong Answer

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

"""
方針：0<=cx,cy<=100なのでcx,cyの特定は全数探索で間に合う
(cx,cy)があっていればh+(abs(cx-x)+abs(cy-y))=const
"""
for cx in range(101):
	for cy in range(101):
		const = xyh[0][2] + (abs(cx-xyh[0][0]) + abs(cy-xyh[0][1]))
		correct_center = True
		for i in range(N):
			if const != xyh[i][2] + (abs(cx-xyh[i][0]) + abs(cy-xyh[i][1])) \
			and xyh[i][2] > 0:
				correct_center = False
				break
		if correct_center:
			break
	if correct_center:
		break

H = xyh[0][2] + abs(cx-xyh[0][0]) + abs(cy-xyh[0][1])
print(cx,cy,H)