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())
 
XYHA = []
 
for i in range(N):

    BBBB = input().split(" ")

    if BBBB[2] == '0':
        continue

    XYHA.append(BBBB)

for i in range(101):
    for j in range(101):
        OKFLG = True
        HC = int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j)
        for k in range(1, len(XYHA)):

            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):

    BBBB = input().split(" ")

    if BBBB[2] == '0':
        continue

    XYHA.append(BBBB)

HC = 0

for i in range(101):
    for j in range(101):
        OKFLG = True
        HC = 0
        for k in range(len(XYHA)):

            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):

    BBBB = input().split(" ")

    if BBBB[2] == '0':
        continue

    XYHA.append(BBBB)

HC = 0

for i in range(101):
    for j in range(101):
        OKFLG = True
        
        for k in range(len(XYHA)):

            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):

    BBBB = input().split(" ")

    if BBBB[2] == '0':
        continue

    XYHA.append(BBBB)

HC = 0

for i in range(101):
    for j in range(101):
        OKFLG = True
        HC = 0
        for k in range(len(XYHA)):

            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    XYHA.append(input().split(" "))
 
HC = 0
CX = 0
CY = 0
OKFLG = True
 
for i in range(101):
    for j in range(101):
        OKFLG = True
        HC = 0
        for k in range(N):

            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)

            if int(XYHA[k][2]) == 0:
                continue

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    XYHA.append(input().split(" "))
 
HC = 0
CX = 0
CY = 0
OKFLG = True
 
for i in range(101):
    for j in range(101):
        OKFLG = True
        HC = 0
        for k in range(N):

            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)

            if int(XYHA[k][2]) == 0:
                continue

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
 
        if OKFLG:
            CX = i
            CY = j
            break
    if OKFLG:
        break
 
print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    XYHA.append(input().split(" "))
 
HC = 0
CX = 0
CY = 0
OKFLG = True
 
for i in range(101):
    for j in range(101):
        HC = max(int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j), 0)
        OKFLG = True

        if int(XYHA[0][2]) == 0:
            OKFLG = False
            break

        for k in range(1, N):
            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)
 
            if int(XYHA[k][2]) == 0:
                OKFLG = False
                break

            if HC != H:
                OKFLG = False
                break
 
        if OKFLG:
            CX = i
            CY = j
            break
    if OKFLG:
        break
 
print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    XYHA.append(input().split(" "))
 
HC = 0
CX = 0
CY = 0
OKFLG = True
 
for i in range(101):
    for j in range(101):
        HC = max(int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j), 0)
        OKFLG = True

        if int(XYHA[0][2]) == 0:
            OKFLG = False
            break

        for k in range(1, N):
            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)
 
            if HC != H:
                OKFLG = False
                break
 
        if OKFLG:
            CX = i
            CY = j
            break
    if OKFLG:
        break
 
print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    XYHA.append(input().split(" "))
 
HC = 0
CX = 0
CY = 0
OKFLG = True
 
for i in range(101):
    for j in range(101):
        HC = max(int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j), 0)
        OKFLG = True

        if HC == 0:
            break

        for k in range(1, N):
            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)
 
            if HC != H:
                OKFLG = False
                break
 
        if OKFLG:
            CX = i
            CY = j
            break
    if OKFLG:
        break
 
print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    XYHA.append(input().split(" "))
 
HC = 0
CX = 0
CY = 0
OKFLG = True
 
for i in range(101):
    for j in range(101):
        HC = max(int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j), 0)
        OKFLG = True

        if HC == 0:
            continue

        for k in range(1, N):
            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)
 
            if HC != H:
                OKFLG = False
                break
 
        if OKFLG:
            CX = i
            CY = j
            break
    if OKFLG:
        break
 
print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())
 
XYHA = []
 
for i in range(N):
    XYHA.append(input().split(" "))
 
HC = 0
CX = 0
CY = 0
OKFLG = True
 
for i in range(101):
    for j in range(101):
        HC = max(int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j), 0)
        OKFLG = True
        for k in range(1, N):
            H = max(int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)
 
            if HC != H:
                OKFLG = False
                break
 
        if OKFLG:
            CX = i
            CY = j
            break
    if OKFLG:
        break
 
print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())

info = []

for i in range(N):
    x,y,h = map(int,input().split())
#    if h == 0:
#        N -= 1
#        continue
    info.append([x,y,h])

for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        
        for k in range(1, N):
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            
            if H_0 != H:
                break
            elif k == N - 1:
                print(i,j,H_0)
                exit()

print(info[0][0],info[0][1],info[0][2])

Submission status: Wrong Answer

Solution code:
N = int(input())

XYHA = []

for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    XYHA.append([x,y,h])

for i in range(101):
    for j in range(101):
        HC = XYHA[0][2] + abs(XYHA[0][0] - i) + abs(XYHA[0][1] - j)

        for k in range(1, N):
            H = XYHA[k][2] + (XYHA[k][0] - i) + abs(XYHA[k][1] - j)

            if HC != H:
                break

            if k == N - 1:
                print(i,j,HC)
                exit()
print(0,0,0)

Submission status: Wrong Answer

Solution code:
N = int(input())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

for i in range(101):
    for j in range(101):
        HC = int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j)

        for k in range(1, N):
            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC != H:
                break

            if k == N - 1:
                print(i,j,HC)
                exit()
print(0,0,0)

Submission status: Wrong Answer

Solution code:
N = int(input())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

HC = 0
CX = 0
CY = 0
OKFLG = True

for i in range(101):
    for j in range(101):
        HC = int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j)
        OKFLG = True
        for k in range(1, N):
            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC != H:
                OKFLG = False
                break

        if OKFLG:
            CX = i
            CY = j
            break
    if OKFLG:
        break

print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

HC = 0
CX = 0
CY = 0
OKFLG = True

for i in range(101):
    for j in range(101):
        HC = int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j)
        OKFLG = True
        for k in range(1, N):
            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC != H:
                OKFLG = False
                break

        if OKFLG:
            CX = i
            XY = j
            break
    if OKFLG:
        break

print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

HC = 0
CX = 0
CY = 0
OKFLG = True

for i in range(101):
    for j in range(101):
        HC = 0
        OKFLG = True
        for k in range(N):
            XYH = XYHA[k]
            H = int(XYH[2]) + abs(int(XYH[0]) - i) + abs(int(XYH[1]) - j)
            if HC == 0:
                HC = H
                CX = i
                CY = j
                continue
            
            if HC == H:
                continue
            else:
                OKFLG = False
                break

        if OKFLG:
            break
    if OKFLG:
        break


print(CX,CY,HC)

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            if info[k][2] == 0:
                continue
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                print(i,j,H_0)
                exit()
for e in info:
    if 0 <= e[0] <= 100 and 0 <= e[1] <= 100 and e[2] > 0:
        print(e[0],e[1],e[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            if info[k][2] == 0:
                continue
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                print(i,j,H_0)
                exit()
for e in info:
    if e[2] > 0:
        print(e[0],e[1],e[2])

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            if info[k][2] == 0:
                continue
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                ans = [i,j,H_0]
                print(" ".join([str(e) for e in ans]))
                exit()
print(info[0][0],info[0][1],info[0][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
info = []
for i in range(N):
    x,y,h = map(int,input().split())
    info.append([x,y,h])
for i in range(101):
    for j in range(101):
        H_0 = info[0][2] + abs(info[0][0] - i) + abs(info[0][1] - j)
        for k in range(1,N):
            if info[k][2] == 0:
                continue
            H = info[k][2] + abs(info[k][0] - i) + abs(info[k][1] - j)
            if H_0 != H:
                break
            elif k == N-1:
                ans = [i,j,H_0]
                print(" ".join([str(e) for e in ans]))
                exit()
print("error")

Submission status: Wrong Answer

Solution code:
n = (int)(input())

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

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]

        if len(set(i for i in tmp if i >= 0)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()

Submission status: Wrong Answer

Solution code:
n = (int)(input())

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

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, (lambda x: x if x >= 0 else 0)(tmp[0]))
            exit()

Submission status: Wrong Answer

Solution code:
n = (int)(input())

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

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        if tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, tmp[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = (int)(input())

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

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        if tmp[0] >= 0 and tmp.count(tmp[0]) == len(tmp) and len(set(tmp)) == 1:
            print(i, j, tmp[0])

Submission status: Wrong Answer

Solution code:
n = (int)(input())

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

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-i) + abs(y[k]-j) for k in range(n)]
        if tmp[0] >= 0 and tmp.count(tmp[0]) == len(tmp):
            print(i, j, tmp[0])

Submission status: Wrong Answer

Solution code:
n = (int)(input())

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

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-j) + abs(y[k]-i) for k in range(n)]
        if tmp[0] >= 0 and tmp.count(tmp[0]) == len(tmp):
            print(i, j, tmp[0])

Submission status: Wrong Answer

Solution code:
n = (int)(input())

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

for _ in range(n):
    a, b, c = map(int, input().split())
    x.append(a)
    y.append(b)
    h.append(c)

for i in range(0, 100+1):
    for j in range(0, 100+1):
        tmp = [h[k] + abs(x[k]-j) + abs(y[k]-i) for k in range(n)]
        if tmp.count(tmp[0]) == len(tmp):
            print(i, j, tmp[0])

Submission status: Wrong Answer

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
for m in range(n):
  if x[m][2]>0:
    ii=m

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(n):
      if hight(k,l,x[ii][0],x[ii][1],x[ii][2])!=hight(k,l,x[i][0],x[i][1],x[i][2]) and x[i][2]>0:
        flag=1 
    if flag==0:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[ii][0],x[ii][1],x[ii][2])

print(ans1,ans2,ans3)

Submission status: Wrong Answer

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
for m in range(n):
  if x[m][2]>0:
    ii=m

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(0,n):
      if hight(k,l,x[ii][0],x[ii][1],x[ii][2])!=hight(k,l,x[i][0],x[i][1],x[i][2]) and x[i][2]>0:
        flag=1 
    if flag==0:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[ii][0],x[ii][1],x[ii][2])

print(ans1,ans2,ans3)

Submission status: Wrong Answer

Solution code:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
for m in range(n):
  if x[m][2]>0:
    ii=m

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[ii][0],x[ii][1],x[ii][2])!=hight(k,l,x[i][0],x[i][1],x[i][2]) and x[i][2]>0:
        flag=1 
    if flag==0:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[ii][0],x[ii][1],x[ii][2])

print(ans1,ans2,ans3)

Submission status: Wrong Answer

Solution code:


def check(x, y, data, num):
    high = 0
    for i in range(num):
       if data[i][2] == 0:
           continue
       if high == 0:
           high = abs(x - data[i][0]) + abs(y - data[i][1]) + data[i][2]
       else:
           if high != abs(x - data[i][0]) + abs(y - data[i][1]) + data[i][2]:
               return 0
    return high



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

    for i in range(101):
        for j in range(101):
            flg = check(i, j, data, num)
            if flg:
                print(i, j, flg)
                break

Submission status: Wrong Answer

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

for x in range(0, 101):
    for y in range(0, 101):
        flag = True
        H = xyh[0][2] + abs(xyh[0][0] - x) + abs(xyh[0][1] - y)
        for xx, yy, hh in xyh:
            h = max(H - abs(xx - x) - abs(yy - y), 0)
            if hh != h:
                flag = False
                break
        if flag:
            print(x, y, H)
            exit()

Submission status: Wrong Answer

Solution code:


def check(x, y, data, num):
    high = 'dammy'
    for i in range(num):
       if data[i][2] == 0:
           continue
       if high == 'dammy':
           high = abs(x - data[i][0]) + abs(y - data[i][1]) + data[i][2]
       else:
           if high != abs(x - data[i][0]) + abs(y - data[i][1]) + data[i][2]:
               return 0
    return high



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

    for i in range(101):
        for j in range(101):
            flg = check(i, j, data, num)
            if flg:
                print(i, j, flg)
                break

Submission status: Wrong Answer

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

for x in range(0, 1001):
    for y in range(0, 1001):
        flag = True
        H = xyh[0][2] + abs(xyh[0][0] - x) + abs(xyh[0][1] - y)
        for xx, yy, hh in xyh:
            h = max(H - abs(xx - x) - abs(yy - y), 0)
            if hh != h:
                flag = False
                break
        if flag:
            print(x, y, H)
            exit()

Submission status: Wrong Answer

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


n = int(input())

X = []
Y = []
Z = []

for i in range(n):
    new_x, new_y, new_z = map(int, input().split())
    X.append(new_x)
    Y.append(new_y)
    Z.append(new_z)
if n == 1:
    print(X[0], Y[0], Z[0])
elif n == 2:
    top_h = 0
    for i,height in enumerate(Z):
        if height> top_h:
            top_x, top_y, top_h = X[i], Y[i], height
    print(top_x, top_y, top_h)

else:
    c_xs = [x for x in range(min(X), max(X)+1)]
    c_ys = [y for y in range(min(Y), max(Y) + 1)]
    for x in c_xs:
        for y in c_ys:
            temp = Z[0] + abs(X[0]-x) + abs(Y[0] - y)
            for index in range(1, n):

                if temp != Z[index] + abs(X[index]-x) + abs(Y[index] - y):
                    break
                if index == n-1:
                    print(x, y, temp)

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
import sys

N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
sorce = np.array(range(101))
xyh.sort(reverse=True)

for ar in itertools.product(sorce,repeat=2):
    H = 0
    cnt = 0
    f = 0
    for i in xyh:
        X,Y = abs(np.subtract( [ar[0],ar[1]] , [i[0],i[1]] ))
        if f == 0:
            H = X+Y+i[2]
            f = 1
        if i[2] == max((H-X-Y),0):
            cnt += 1
        else:
            break
        if cnt == N:
            print(ar[0],ar[1],H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
import itertools
import sys

N = int(input())
xyh = [list(map(int,input().split())) for i in range(N)]
sorce = np.array(range(101))
xyh.sort(reverse=True)

for ar in itertools.product(sorce,repeat=2):
    H = 0
    cnt = 0
    f = 0
    for i in xyh:
        X,Y = abs(np.subtract( [ar[0],ar[1]] , [i[0],i[1]] ))
        if f == 0:
            H = X+Y+i[2]
            f = 1
        if H == X+Y+i[2]:
            cnt += 1
        else:
            break
        if cnt == N:
            print(ar[0],ar[1],H)
            sys.exit()

Submission status: Wrong Answer

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

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 distance(a,b):
    a_x = a[0]
    a_y = a[1]
    b_x = b[0]
    b_y = b[1]

    return abs(a_x - b_x) + abs(a_y - b_y)


for cx in range(101):
    for cy in range(101):
        ans = True
        c = [cx, cy]
        for i in range(N):
            if h[i] != 0:
                ch = distance(c, [x[i], y[i]]) + h[i]
                break
        # ch = distance(c, [x[0], y[0]]) + h[0]  # cx, cyを仮定するとchが定まる
        for i in range(1, N):
            if max([ch - distance(c, [x[i], y[i]]), 0]) != h[i]:
                ans = False
                break
        if ans:
            break
    if ans:
        break

print(" ".join(list(map(str, [cx, cy, ch]))))

Submission status: Wrong Answer

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

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 distance(a,b):
    a_x = a[0]
    a_y = a[1]
    b_x = b[0]
    b_y = b[1]

    return abs(a_x - b_x) + abs(a_y - b_y)


for cx in range(101):
    for cy in range(101):
        ans = True
        c = [cx, cy]
        for i in range(N):
            if h[i] != 0:
                ch = distance(c, [x[i], y[i]]) + h[i]
                break
        # ch = distance(c, [x[0], y[0]]) + h[0]  # cx, cyを仮定するとchが定まる
        for i in range(1, N):
            if ch - distance(c, [x[i], y[i]]) != h[i]:
                ans = False
                break
        if ans:
            break
    if ans:
        break

print(" ".join(list(map(str, [cx, cy, ch]))))

Submission status: Wrong Answer

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

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 distance(a,b):
    a_x = a[0]
    a_y = a[1]
    b_x = b[0]
    b_y = b[1]

    return abs(a_x - b_x) + abs(a_y - b_y)


for cx in range(101):
    for cy in range(101):
        ans = True
        c = [cx, cy]
        ch = max([distance(c, [x[0], y[0]]), 0]) + h[0]  # cx, cyを仮定するとchが定まる
        for i in range(1, N):
            if ch - max([distance(c, [x[i], y[i]]), 0]) != h[i]:
                ans = False
                break
        if ans:
            break
    if ans:
        break

print(" ".join(list(map(str, [cx, cy, ch]))))

Submission status: Wrong Answer

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

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 distance(a,b):
    a_x = a[0]
    a_y = a[1]
    b_x = b[0]
    b_y = b[1]

    return abs(a_x - b_x) + abs(a_y - b_y)


for cx in range(101):
    for cy in range(101):
        ans = True
        c = [cx, cy]
        ch = distance(c, [x[0], y[0]]) + h[0]  # cx, cyを仮定するとchが定まる
        for i in range(1, N):
            if ch - distance(c, [x[i], y[i]]) != h[i]:
                ans = False
                break
        if ans:
            break
    if ans:
        break

print(" ".join(list(map(str, [cx, cy, ch]))))

Submission status: Wrong Answer

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

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

xyh.sort(reverse=True)
    
for i in range(101):
    for j in range(101):
        x, y, h = xyh[0]
        H = h + abs(x - i) + abs(y - j)
        if all(h == max(H - abs(x - i) - abs(y - j), 0) for x, y, h in xyh):
            print(i, j, H)

Submission status: Wrong Answer

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

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

xyh.sort(reverse=True)
    
for i in range(0, 101):
    for j in range(0, 101):
        H = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if all(h == max(H - abs(x - i) - abs(y - j), 0) for x, y, h in xyh):
            print(i, j, H)

Submission status: Wrong Answer

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

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

for i in range(0, 101):
    for j in range(0, 101):
        H = xyh[0][2] + abs(xyh[0][0] - i) + abs(xyh[0][1] - j)
        if all(h == max(H - abs(x - i) - abs(y - j), 0) for x, y, h in xyh):
            print(i, j, H)

Submission status: Wrong Answer

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


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

for i in range(0, 101):
        # print("i = " + str(i))
     for j in range(0, 101):
                # print("j = " + str(j))
        state = 1
        H_before = None
        for s in alist:
            if s[2] == 0:
                continue
            else:
                # print("s = " + str(s))
                H = int(s[2]) + abs(int(s[0])-j) + abs(int(s[1])-i)
                # print("H = " + str(H))
                if H < 1:
                    continue
                
                elif  H_before == None or H == H_before:
                    state = 0
                    H_before = H
                
                else:
                    state = 1
                    break
        
        if state == 0:
            print("{} {} {}".format(j, i, H_before))

Submission status: Wrong Answer

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


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

for i in range(0, 101):
        # print("i = " + str(i))
     for j in range(0, 101):
                # print("j = " + str(j))
        state = 1
        H_before = None
        for s in alist:
            if s[2] == 0:
                continue
                # print("s = " + str(s))
                H = int(s[2]) + abs(int(s[0])-j) + abs(int(s[1])-i)
                # print("H = " + str(H))
                if H < 1:
                    continue
                
                elif  H_before == None or H == H_before:
                    state = 0
                    H_before = H
                
                else:
                    state = 1
                    break
        
        if state == 0:
            print("{} {} {}".format(j, i, H_before))

Submission status: Wrong Answer

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


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

for i in range(0, 101):
        # print("i = " + str(i))
     for j in range(0, 101):
                # print("j = " + str(j))
        state = 1
        H_before = None
        for s in alist:
            # print("s = " + str(s))
            H = int(s[2]) + abs(int(s[0])-j) + abs(int(s[1])-i)
            # print("H = " + str(H))
            if H < 1:
                continue
            
            elif  H_before == None or H == H_before:
                state = 0
                H_before = H
            
            else:
                state = 1
                break
        
        if state == 0:
            print("{} {} {}".format(j, i, H_before))