Problem:


Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).  

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:  

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.  

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."  

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.  

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:  

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.  

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.  

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.  



Sample input:
4
2 3 5
2 1 5
1 2 5
3 2 5


Sample output:
2 2 6

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
for i in range(101):
    for j in range(101):
        check = []
        check2 = True
        for k in range(n):
            H = h[k] + abs(x[k] - i) + abs(y[k] - j)
            if h[k] > 0:
                check.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            if h[k] == 0:
                if H >= abs(x[k] - i) + abs(y[k] - j):
                    check2 = False
        if len(set(check)) == 1 & check2:
            print(i, j, check[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    
for i in range(101):
    for j in range(101):
        check = []
        check2 = True
        for k in range(n):
            H = h[k] + abs(x[k] - i) + abs(y[k] - j)
            if h[k] > 0:
                check.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    check2 = False
        if len(set(check)) == 1 & check2:
            print(i, j, check[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    a,b,c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    
for i in range(101):
    for j in range(101):
        check = []
        check2 = True
        for k in range(n):
            H = h[k] + abs(x[k] - i) + abs(y[k] - j)
            if h[k] > 0:
                check.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            if h[k] == 0:
                if H > abs(x[k] - i) + abs(y[k] - j):
                    check2 = False
        if len(set(check)) == 1 & check2:
            print(i, j, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = [0] * 2

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
    if len(list(set(List))) == 1:
      answer = List[0]
      center[0] = i
      center[1] = j

print(center[0], center[1], answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
    if len(list(set(List))) == 1:
      if List[0] == 0:
        continue
      answer = List[0]
      center.append(i)
      center.append(j)
      break
  if answer != 0:
    break

print(center[0], center[1], answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
    if len(list(set(List))) == 1:
      answer = List[0]
      center.append(i)
      center.append(j)
      break
  if answer != 0:
    break

print(center[0], center[1], answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
    if len(list(set(List))) == 1 or all(List) == False:
      answer = List[0]
      center.append(i)
      center.append(j)

print(center[0], center[1], answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
      #else:
        #List.append(0)
    if len(list(set(List))) == 1:
      answer = List[0]
      center.append(i)
      center.append(j)

print(center[0], center[1], answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [input().split() for i in range(N)]
answer = 0
center = []

for i in range(101):
  for j in range(101):
    List = []
    for l in L:
      if int(l[2]) != 0:
        List.append(int(l[2]) + abs(int(l[0]) - i) + abs(int(l[1]) - j))
    if len(list(set(List))) == 1:
      answer = List[0]
      center.append(i)
      center.append(j)

print(center[0], center[1], answer)

Submission status: Wrong Answer

Solution code:
def manhattan(i, j, x, y):
    # (i, j)中央点の座標，(x, y)既知の座標
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    for i in range(101):
        for j in range(101):
            # 既知座標１点を得て，中心座標の高さを決定する
            for k in range(N):
                if H[k] != 0:
                    x, y, h = X[k], Y[k], H[k]
                    hmax = h + manhattan(i, j, x, y)
                    break
            # 残り既知座標N-1点について，矛盾がないか確かめる
            for k in range(N):
                x, y, h = X[k], Y[k], H[k]
                if hmax - h > manhattan(i, j, x, y):
                    break
            else:
                return i, j, hmax

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

Submission status: Wrong Answer

Solution code:
n = int(input())
pyramid = [[int(x) for x in input().split()] for y in range(n)]
tmp_pyramid = [[{} for x in range(101)] for y in range(101)]

tmp_candidate = []
for i in range(101):
    for j in range(101):
        tmp_candidate = [max(0, h + abs(x-i) + abs(y-j)) for x, y, h in pyramid]
        set_candidate = set(tmp_candidate)
        if len(set_candidate) == 1:
            print(i, j, tmp_candidate[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
pyramid = [[int(x) for x in input().split()] for y in range(n)]
tmp_pyramid = [[{} for x in range(101)] for y in range(101)]

tmp_candidate = []
for i in range(101):
    for j in range(101):
        tmp_candidate = [max(0, h + abs(x-i) + abs(y-j)) for x, y, h in pyramid]
        set_candidate = set(tmp_candidate)
        if len(set_candidate) == 1:
            print(i, j, tmp_candidate[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
pyramid = [[int(x) for x in input().split()] for y in range(n)]
tmp_pyramid = [[{} for x in range(101)] for y in range(101)]

tmp_candidate = []
for i in range(101):
    for j in range(101):
        tmp_candidate = [max(0, h + abs(x-i) + abs(y-j)) for x, y, h in pyramid]
        set_candidate = set(tmp_candidate)
        if len(set_candidate) == 1:
            print(tmp_candidate)
            print(i, j, tmp_candidate[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
# A.sort(reverse = True, key = lambda x: x[2])

for i in range(101):
    for j in range(101):
        px, py, ph = A[0] # 高さ最大
        H = ph + abs(px - i) + abs(py - j)
        if all(h == max(H - abs(x - i) - abs(y - j) , 0) for x, y, h in A):
            print(i, j, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
pyramid = [[int(x) for x in input().split()] for y in range(n)]
tmp_pyramid = [[{} for x in range(101)] for y in range(101)]

tmp_candidate = []
for i in range(101):
    for j in range(101):
        tmp_candidate = [h + abs(x-i) + abs(y-j) for x, y, h in pyramid]
        set_candidate = set(tmp_candidate)
        if len(set_candidate) == 1:
            print(i, j, tmp_candidate[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def possible_height(cx, cy, infos):
    maxmin = 1
    minmax = 99999999999
    for i in infos:
        hmin, hmax = get_height(cx, cy, *i)
        maxmin = max(maxmin, hmin)
        minmax = min(minmax, hmax)
    if maxmin == minmax:
        return hmin
    elif maxmin < minmax:  # Undetermined
        raise Exception
    else:  # Impossible
        return None

def get_height(cx, cy, xi, yi, hi):
    hmax = abs(cx - xi) + abs(cy - yi) + hi
    hmin = 1 if hi == 0 else hmax
    return hmin, hmax

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

    for cx in range(101):
        for cy in range(101):
            h = possible_height(cx, cy, infos)
            if h is not None:
                print(cx, cy, h)
                return
    raise Exception

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def possible_height(cx, cy, infos):
    maxmin = 1
    minmax = 99999999999
    for i in infos:
        hmin, hmax = get_height(cx, cy, *i)
        maxmin = max(maxmin, hmin)
        minmax = min(minmax, hmax)
    if maxmin == minmax:
        return hmin
    else:  # Undetermined or impossible
        return None

def get_height(cx, cy, xi, yi, hi):
    hmax = abs(cx - xi) + abs(cy - yi) + hi
    hmin = 1 if hi == 0 else hmax
    return hmin, hmax

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

    for cx in range(101):
        for cy in range(101):
            h = possible_height(cx, cy, infos)
            if h is not None:
                print(cx, cy, h)
                return
    raise Exception

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def possible_height(cx, cy, infos):
    maxmin = 1
    minmax = 9999999999
    for i in infos:
        hmin, hmax = get_height(cx, cy, *i)
        maxmin = max(maxmin, hmin)
        minmax = min(minmax, hmax)
    if maxmin == minmax:
        return hmin
    else:  # Undetermined or impossible
        return None

def get_height(cx, cy, xi, yi, hi):
    hmax = abs(cx - xi) + abs(cy - yi) + hi
    hmin = 1 if hi == 0 else hmax
    return hmin, hmax

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

    for cx in range(101):
        for cy in range(101):
            h = possible_height(cx, cy, infos)
            if h is not None:
                print(cx, cy, h)
                return
    raise Exception

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

def possible_height(cx, cy, infos):
    maxmin = -9999999999
    minmax = 9999999999
    for i in infos:
        hmin, hmax = get_height(cx, cy, *i)
        maxmin = max(maxmin, hmin)
        minmax = min(minmax, hmax)
    if maxmin == minmax:
        return hmin
    else:  # Undetermined or impossible
        return None

def get_height(cx, cy, xi, yi, hi):
    hmax = abs(cx - xi) + abs(cy - yi) + hi
    hmin = 1 if hi == 0 else hmax
    return hmin, hmax

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

    for cx in range(101):
        for cy in range(101):
            h = possible_height(cx, cy, infos)
            if h is not None:
                print(cx, cy, h)
                return
    raise Exception

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [[int(i) for i in input().split()] for i in range(n)]
A.sort(reverse = True, key = lambda x: x[2])

for i in range(n):
    for j in range(n):
        px, py, ph = A[0]
        H = ph + abs(px - i) +abs(py - j)
        if all(h == max(H - abs(x - i) - abs(y - j) , 0) for x, y, h in A):
            print(i, j, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
            f = 1
            for x in H:
                h = x
            for k in range(len(l)):
                x = l[k]
                f += x[2] == max(0,h - abs(i - x[0]) - abs(j - x[1]))
            if f == N + 1:
                print(i,j,h)
                quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
            f = 1
            for x in H:
                h = x
            for k in range(len(l)):
                x = l[k]
                f *= x[2] == max(0,h - abs(i - x[0]) - abs(j - x[1]))
            if f == 1:
                print(i,j,h)
                quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
          for x in H:
            h = x
          for k in range(len(l)):
            x = l[k]
            f = 1
            f *= x[2] == max(0,h - abs(i - x[0]) - abs(j - x[1]))
            if f == 1:
                print(i,j,h)
                quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            h = abs(i - x[0]) + abs(j - x[1]) + x[2]
            if h >= 1:
              H.add(h)
       
        if len(H) == 1:
            for x in H:
                print(i, j, x)
                quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = [list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        H = set()
        for k in range(len(l)):
            x = l[k]
            H.add ( abs(i - x[0]) + abs( j - x[1])  + x[2] )
        if len(H) == 1:
            for x in H:
                print(i, j, x)
                quit()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    x = []
    y = []
    h = []
    for i in range(n):
        xx, yy, zz = map(int, input().split())
        x.append(xx)
        y.append(yy)
        h.append(zz)
    for i in range(n):
        if h[i] != 0:
            idx = i
    for xx in range(101):
        for yy in range(101):
            H = h[idx] + abs(xx - x[idx]) + abs(yy - y[idx])
            if xx == 2 and yy == 2:
                print(H)
            flag = True
            for i in range(n):
                if h[i] != max(H - abs(xx - x[i]) - abs(yy - y[i]), 0):
                    flag = False
                    break
            if flag:
                print(xx, yy, H)
                return

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    x = []
    y = []
    h = []
    for i in range(n):
        xx, yy, zz = map(int, input().split())
        x.append(xx)
        y.append(yy)
        h.append(zz)
    min_h = min(h)
    for i in range(n):
        if h[i] != 0:
            idx = i
        h[i] -= min_h
    for xx in range(101):
        for yy in range(101):
            H = h[idx] + abs(xx - x[idx]) + abs(yy - y[idx])
            flag = True
            for i in range(n):
                if (min_h == 0 and h[i] != min(H - abs(xx - x[i]) - abs(yy - y[i]), 0)) or (min_h != 0 and h[i] != H - abs(xx - x[i]) - abs(yy - y[i])):
                    flag = False
                    break
            if flag:
                print(xx, yy, H + min_h)
                return

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
 
#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 
 
for cx in range(101):
  for cy in range(101):
    flag =0
    for i in range(n):
      if zahyo[i][2]>0:
        H0 = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]
        break
    for i in range(n):
      if zahyo[i][2] != max(0, H0-abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])):  
        flag=1
        break
    if flag==0:
      print(cx,cy,H0)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
 
#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 

for cx in range(101):
  for cy in range(101):
    for i in range(n):
      if zahyo[i][2]>0:
        H0 = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]
        break
    for i in range(n):
      H = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]  
      if H != H0:
        break
    if H == H0:
      print(cx,cy,H0)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
 
#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 
flag = 0
for cx in range(101):
  for cy in range(101):
    if flag == 0:
      for i in range(0,n):
        if zahyo[i][2]>0:
          H0 = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]
          break
      for i in range(1,n):
        H = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]  
        if H != H0:
          break
      if H == H0 and H != 0:
        print(cx,cy,H0)
        flag = 1
    else:
      break

Submission status: Wrong Answer

Solution code:
n = int(input())

#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 
flag = 0
for cx in range(101):
  for cy in range(101):
    if flag == 0:
      H0 = abs(cx-zahyo[0][0])+abs(cy-zahyo[0][1])+zahyo[0][2]  
      for i in range(1,n):
        H = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]  
        if H !=H0:
          break
      if H == H0 and H != 0:
        print(cx,cy,H0)
        flag = 1
    else:
      break

Submission status: Wrong Answer

Solution code:
n = int(input())

#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 
flag = 0
for cx in range(101):
  for cy in range(101):
    if flag == 0:
      H0 = abs(cx-zahyo[0][0])+abs(cy-zahyo[0][1])+zahyo[0][2]  
      for i in range(1,n):
        H = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]  
        if H !=H0:
          break
      if H == H0:
        print(cx,cy,H0)
        flag = 1
    else:
      break

Submission status: Wrong Answer

Solution code:
n = int(input())

#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 

for cx in range(101):
  for cy in range(101):
      H0 = abs(cx-zahyo[0][0])+abs(cy-zahyo[0][1])+zahyo[0][2]  
      for i in range(1,n):
        H = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]  
        if H !=H0:
          break
      if H == H0:
        print(cx,cy,H0)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if h[k] != 0:
                H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
            else:
                H.append(1)
        if len(set(H)) == 1:
            print(i,j,H[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if h[k] != 0:
                H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))      
            else:
                H.append(1)
        if len(set(H)) == 1:
            print(i,j,H[0])
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
check = True
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if h[k] != 0:
                H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
                
        if len(set(H)) == 1:
            check = False
            print(i,j,H[0])
            break
if check:
    print(0,0,1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
check = True
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if h[k] != 0:
                H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
                
        if len(set(H)) == 1:
            check = False
            print(i,j,H[0])
            break
if check:
    print(0,0,1000000000)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
        if len(set(H)) == 1:
            check = False
            print(i,j,H[0])
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)

import sys
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if h[k] != 0:
                H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
        if len(set(H)) == 1:
            print(i,j,H[0])
            sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
check = True
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if h[k] != 0:
                H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
        if len(set(H)) == 1:
            check = False
            print(i,j,H[0])
if check:
    print(0,0,0)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if h[k] != 0:
                H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
        if len(set(H)) == 1:
            print(i,j,H[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h=[],[],[]
for i in range(N):
    tmpx, tmpy, tmph = (int(i) for i in input().split())
    x.append(tmpx)
    y.append(tmpy)
    h.append(tmph)

truecx=0
truecy=0
trueh=0

for tmpcx in range(101):
    for tmpcy in range(101):
        tmph=[]
        for i in range(N):
            if h[i]!=0:
                tmph.append(h[i]+abs(x[i]-tmpcx)+abs(y[i]-tmpcy))
        if all([tmph[0]==i for i in tmph]):
            truecx,truecy,trueh=tmpcx,tmpcy,tmph[0]
print(truecx, truecy, trueh)

Submission status: Wrong Answer

Solution code:
N = int(input())
x,y,h=[],[],[]
for i in range(N):
    tmpx, tmpy, tmph = (int(i) for i in input().split())
    x.append(tmpx)
    y.append(tmpy)
    h.append(tmph)

def solve(N,x,y,h):
    for cx in range(101):
        for cy in range(101):
            H=[]
            for i in range(N):
                if h[i]!=0:
                    H.append(h[i]+abs(x[i]-cx)+abs(y[i]-cy)) 
            if all([i==H[0] for i in H]):
                return [cx,cy,H[0]]
ans = solve(N,x,y,h)
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xx,yy,hh = map(int, input().split())
    x.append(xx)
    y.append(yy)
    h.append(hh)
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            H.append(h[k] + abs(x[k] - i) + abs(y[k] -j))
        if len(set(H)) == 1:
            print(i,j,H[0])

Submission status: Wrong Answer

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


def m():
    for cx in range(0, 101):
        for cy in range(0, 101):
            hs = []
            h = 0
            for x, y, r in xyr:
                h = max(0, r + abs(x - cx) + abs(y - cy))
                hs.append(h)
            s = set(hs)
            if len(s) == 1:
                return "{} {} {}".format(cx, cy, s.pop())


print(m())

Submission status: Wrong Answer

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


def m():
    for cx in range(0, 101):
        for cy in range(0, 101):
            hs = []
            h = 0
            for x, y, r in xyr:
                h = max(0, r + abs(x - cx) + abs(y - cy))
                hs.append(h)
            if len(set(hs)) == 1:
                return "{} {} {}".format(cx, cy, h)


print(m())

Submission status: Wrong Answer

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


def m():
    for cx in range(0, 101):
        for cy in range(0, 101):
            tmpx, tmpy, tmpr = xyr[0]
            h = max(0, tmpr +abs(tmpx-cx) + abs(tmpy-cy))
            f = 0
            for x, y, r in xyr:
                if not (r == max(h-abs(x-cx)-abs(y-cy), 0)):
                    f = 1
                    break
            if f == 0:
                return "{} {} {}".format(cx, cy, h)


print(m())

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
x = []
y = []
h = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                Hi = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)
                if H == -1 and h[i] != 0:
                    H = Hi

                if h[i] == 0:
                    if H > Hi:
                        break
                elif H != Hi:
                    break

                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
x = []
y = []
h = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                if h[i] == 0:
                    if i == N-1 and Hi != 0:
                        return Cx, Cy, H
                    else:
                        continue
                Hi = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)
                if H == -1:
                    H = Hi
                if H != Hi:
                    break
                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
x = []
y = []
h = []
for i in range(0, N):
    xi, yi, hi= [int(a) for a in input().strip().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)

def calc_H():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H = -1
            for i in range(0, N):
                if h[i] == 0:
                    if i == N-1:
                        return Cx, Cy, H
                    else:
                        continue
                Hi = h[i] + abs(x[i]-Cx) + abs(y[i]-Cy)
                if H == -1:
                    H = Hi
                if H != Hi:
                    break
                if i == N-1:
                    return Cx, Cy, H

print(*calc_H())

Submission status: Wrong Answer

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

cands = []
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        for x,y,h in src:
            if h == 0: continue
            ch = h + abs(x-cx) + abs(y-cy)
            if ch < 0: break
            if tmph is None:
                tmph = ch
            elif tmph != ch:
                break
        else:
            print(cx,cy,tmph)
            exit()
            # WA ?