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())

a = [list(map(int, input().split())) for i in range(N)]

for X in range(0, 100):
    for Y in range(0, 100):
# ある(X, Y)に対して

        first_time = True
        status = False
        for xyh in a:
            x = xyh[0]
            y = xyh[1]
            h = xyh[2]

            if first_time is True or ((Hnew - abs(X - x) - abs(Y - y)) < 0):
                Hnew = abs(X - x) + abs(Y - y) + h

                if first_time == True:
                    Hold = Hnew
                    first_time = False
                elif Hnew == Hold:
                    status = True
                    continue
                else:
                    status = False
                    break
        if status == True:
            print(X, Y, Hnew)

Submission status: Wrong Answer

Solution code:
import sys
Input = sys.stdin.readline

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = float("inf")
H_temp = None
 
x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H_temp < H:
                    Cx = c_x
                    Cy = c_y
                    print("{0} {1} {2}".format(Cx, Cy, H))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyhs = [tuple(map(int, input().split())) for _ in range(N)]
xyhs.sort(key=lambda x: x[2])

if N == 1:
    print(*xyhs[0])
    exit()

# 中心座標(Cx,Cy)を全通り試す
for Cx in range(101):
    for Cy in range(101):
        x, y, h = xyhs[-1]
        H = h + abs(Cx - x) + abs(Cy - y)
        for x, y, h in reversed(xyhs[:-1]):
            H2 = h + abs(Cx - x) + abs(Cy - y)
            if H != H2:
                break
            elif h == 0 and H2 < H:
                break
        else:
            print(Cx, Cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]
H_pre = 0
flag = 0
for cx in range(101):
    for cy in range(101):
        for x, y, h in xyh:
            if h:
                if H_pre:
                    if H_pre != h + abs(x-cx) + abs(y-cy):
                        H_pre = 0
                        break
                else:
                    H_pre = h + abs(x-cx) + abs(y-cy)
                    flag = 1
        else:
            if N == 1:
                print(xyh[0][0],xyh[0][1],xyh[0][2])
            else:
                if flag:
                    print(cx, cy, H_pre)
                else:
                    print(cx, cy, h + abs(x-cx) + abs(y-cy))
            exit()

Submission status: Wrong Answer

Solution code:
pattern = int(input())

xs = []
ys = []
hs = []


for _ in range(pattern):
    x, y , h = map(int,input().split(' '))
    xs.append(x)
    ys.append(y)
    hs.append(h)

correct = 0

max_h = max(hs) + 101

for Cx in range(101):
    for Cy in range(101):
        for H in range(max(hs), max_h):
            for x, y, h in zip(xs, ys, hs):
                if abs(x-Cx) + abs(y-Cy) == abs(h-H):
                    correct += 1
                    if correct == len(xs) and max(hs) <= H:
                        print(Cx, Cy, H)
                        break
                else:
                    correct = 0
                    continue

Submission status: Wrong Answer

Solution code:
N = int(input())
infos = [[int(v) for v in input().split()] for _ in range(N)]

LEN = 200

field = [[0 for _ in range(LEN)] for __ in range(LEN)]

def predict_h(info,xy):
    return info[2] + abs(info[0] - xy[0]) + abs(info[1] - xy[1])

def distance(xy,info):
    return abs(xy[0] - info[0]) + abs(xy[1] - info[1])

ans = [0,0,0]

for i in range(LEN):
    for j in range(LEN):

        flag = True
        height = predict_h(infos[0],[i,j])
        for info in infos:
            if height - distance(info,(i,j)) == info[2] :
                continue
            else:
                flag = False
                break
            
        
        
        if flag:
            if height >= ans[2]:
                ans = [i,j,height]

        

            
print(*ans)

Submission status: Wrong Answer

Solution code:
def cal(X,Y,H):
    flag=0
    if(H[0]==0):    flag=1
    if(H[0]==0 and H[1]==0):    flag=2
    
    if(flag==0):
        for i in range(0,101):
            for j in range(0,101):
                temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
                for l in range(1,N):
                    if(H[l]!=0):
                        s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                        if(temp==s):
                            temp=s
                        else:
                            break
                    else:
                        if(temp-abs(X[l]-i)-abs(Y[l]-j)>0):
                            break
                else:
                    return print("{} {} {}".format(i,j,temp))
            
    elif(flag==1):
        p=[]
        for i in range(2,N):
            p.append(i)
        for i in range(0,101):
            for j in range(0,101):
                temp=H[1]+abs(X[1]-i)+abs(Y[1]-j)
                for l in p:
                    if(H[l]!=0 and l!=0):
                        s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                        if(temp==s):
                            temp=s
                        else:
                            break
                    else:
                        if(temp-abs(X[l]-i)-abs(Y[l]-j)>0):
                            break
                else:
                    if(temp-abs(X[0]-i)-abs(Y[0]-j)<0):
                        return print("{} {} {}".format(i,j,temp))          
    

N=int(input())
X=[]
Y=[]
H=[]
for i in range(N):
    x,y,h=list(map(int,input().split()))
    X.append(x)
    Y.append(y)
    H.append(h)
cal(X,Y,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

x, y, h = P[-1]
max_h = h + 100
max_h = min(max_h, 10**9)

P2 = set()
for i in range(101):
    for j in range(101):
        P2.add((i, j))
for hh in range(max_h, P[-1][2]-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P3.copy():
            dx = abs(xx - x)
            dy = abs(yy - y)
            if hh - dx - dy != h:
                P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))

Submission status: Wrong Answer

Solution code:
N = int(input())
x = []
y = []
h = []
for i in range(N):
    a,b,c = [int(hoge) for hoge in input().split()]
    x.append(a)
    y.append(b)
    h.append(c)
    
cand_h = []
cx = 0
cy = 0
H = 0
done_flag = False

for i in range(101):
    for j in range(101):
        # (x, y) = (i, j)
        for k in range(N):
            if h[k] != 0:
                cand_h.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
        
        if len(set(cand_h)) == 1:
            print("{} {} {}".format(i, j, cand_h[0]))
            done_flag = True
            break
    if done_flag:
        break

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import numpy as np
import collections
N = int(input())
arr = []
for n in range(N):
    arr.append(list(map(int,input().split())))
arr = np.array(arr)
#
# N = 2
# arr = np.array([[100 ,100 ,100]])
print (arr[:,1:].min(),arr[:,1:].max()+200)
for i in range(101):
    for j in range(101):
        for k in range(arr[:,1:].min(),arr[:,1:].max()+200):
            flag = True
            for ls in arr:
                flag*=flag*(k-abs(i-ls[0])-abs(j-ls[1])==ls[2])
            if flag:
                print (i,j,k)
                exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
for CX in range(101):
    for CY in range(101):
        ans = 1
        H = 0
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = max(H, abs(x - CX) + abs(y - CY) + h)
            if H < 1:
                ans = -1
                break
            #print(CX, CY)
            
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if h != max(H - abs(x - CX) - abs(y - CY), 0):
                ans = -1
                break
        if H < 1:
            ans = -1
            
        if ans == 1:
            print(CX, CY, H)
            break
    if ans == 1:
        break

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>50:
    k = 9999
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

Solution code:
N = input().strip()
import copy

import sys
cc = set()
first = True
for line in sys.stdin:
    x, y, h = [int(x) for x in line.strip().split(' ')]

    if first:
        for cx in range(101):
            for cy in range(101):
                H = h + abs(x-cx) + abs(y-cy)
                if h != 0:
                    cc.add((cx,cy,H))
                else:
                    if H <= 100:
                        for i in range(100-H):
                            cc.add((cx, cy, H+i+1))
        first = False
    else:
        ncc = set()
        for cx in range(101):
            for cy in range(101):
                H = h + abs(x-cx) + abs(y-cy)
                if h != 0:
                    if (cx,cy,H) in cc:
                        ncc.add((cx,cy,H))
                else:
                    if H <= 100:
                        for i in range(100-H):
                            if (cx, cy, H+i+1) in cc:
                                ncc.add((cx, cy, H+i+1))
        cc = copy.deepcopy(ncc)

for i in cc:
    print(i[0], i[1], i[2])

Submission status: Wrong Answer

Solution code:
import sys
Input = sys.stdin.readline

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = 0
H_temp = None
 
x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H_temp < H:
                    Cx = c_x
                    Cy = c_y
                    print("{0} {1} {2}".format(Cx, Cy, H))
                    sys.exit()

Submission status: Wrong Answer

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

flag = False
flag2 = True
check = []
count = 0
for i in range(N):
    if INFO[i][2] == 0:
        flag = True
        check.append(i)
#if N-count <= 3:
#    flag = True

for x in range(0,101):
    for y in range(0,101):
        flag2 = True
        for i in range(N):
            if INFO[i][2]!=0:
                p = i
                elseH = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
                break
        for i in range(N):
            H = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            if H != elseH and INFO[i][2]!=0:
                flag2 = False
                break
        if flag:
            for i in range(1,N):
               if max(elseH - abs(x-INFO[i][0]) - abs(y-INFO[i][1]),0) != INFO[i][2]:
                   flag2 = False
        if flag2:
            break
    if flag2:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n = int(input())

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

ans = []
for cx in range(101): #Cx 0~100
    for cy in range(101): #Cy 0~100
        h_list = []
        for i in range(n):
            #x[i], y[i], h[i]のときの高さHを求める
            #H = |x[i] - Cx| + |y[i] - Cy| + h[i]
            h = abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy) + xyh[i][2]
            if h >= 0:
                h_list.append(h)

        # Hがすべて一致するときのCx, Cyが答えである
        if len(set(h_list)) == 1:
            ans.append(cx)
            ans.append(cy)
            ans.append(h_list[0])
            print(ans[0], ans[1], ans[2])

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
    for y in range(101):
      a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
      c=0
      for z in range(1,n):
        if abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]!=a:
          break
        else:c+=1
        if c==n-1:print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
for CX in range(101):
    for CY in range(101):
        ans = 1
        H = 1
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = max(H, abs(x - CX) + abs(y - CY) + h)
            if H < 1 and H - abs(x - CX) - abs(y - CY) >= 0:
                ans = -1
                break
            #print(CX, CY)
            
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if h != max(H - abs(x - CX) - abs(y - CY), 0):
                ans = -1
                break
        if H < 1:
            ans = -1
            
        if ans == 1:
            print(CX, CY, H)
            break
    if ans == 1:
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
left = 0
right = 100
up = 100
down = 0
lis = []
x = []
y = []
m = []
for i in range(n):
  a = list(map(int,input().split()))
  lis.append(a)
  x.append([a[0],a[1],a[2]])
  y.append([a[1],a[0],a[2]])
  m.append([a[2],a[0],a[1]])
x.sort()
y.sort()
m.sort(reverse = True)
key = 0
for i in range(n-3):
  if m[i][0] == m[i+1][0] == m[i+2][0] == m[i+3][0]:
    ansx = (m[i][1]+m[i+1][1]+m[i+2][1]+m[i+3][1])//4
    ansy = (m[i][2]+m[i+1][2]+m[i+2][2]+m[i+3][2])//4
    key = 1
if key != 1:
  for i in range(n-1):
    if x[i][0] == x[i+1][0]:
      if x[i][2] > x[i+1][2]:
        up = min(up,x[i][1])
      elif x[i][2] < x[i+1][2]:
        down = max(down,x[i+1][1])
      else:
        up = min(up,x[i+1][1])
        down = max(down,x[i][1])
      
    if y[i][0] == y[i+1][0]:
      if y[i][2] > y[i+1][2]:
        right = min(right,y[i][1])
      elif y[i][2] < y[i+1][2]:
        left = max(left,y[i+1][1])
      else:
        right = min(right,y[i+1][1])
        left = max(left,y[i][1])
  if up == 100 and down == 0 and right == 100 and left == 0:
    print(m[0][1],m[0][2],m[0][0])
    exit()
  ansx = (right+left)//2
  ansy = (up+down) // 2
print(ansx,ansy,abs(ansx-x[0][0])+abs(ansy-x[0][1])+x[0][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    tmp_list = [int(i) for i in input().split()]
    x.append(tmp_list[0])
    y.append(tmp_list[1])
    h.append(tmp_list[2])

print(x, y, h)
H = -1
cx = -1
cy = -1

for x_i in x:
    if x_i is 0:
        cx = 0

for y_i in y:
    if y_i is 0:
        cy = 0

for i in range(0, 100):
    for j in range(0, 100):
        h_tmp = h[0] + (x[0] - i) + (y[0] - j)
        if h_tmp is h[1] + (x[1] - i) + (y[1] - j) and h_tmp > 0:
            cx, cy = i, j
            H = h_tmp

print('{} {} {}'.format(cx, cy, H))

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = sorted([list(map(int,input().split())) for _ in range(N)], key=lambda x:x[2], reverse=True)
xyh = [(x,y,h) for x,y,h in xyh if h != 0]
N = len(xyh)

XY = [[True] * 101 for _ in range(101)]

for i in range(N-1):
    tmp = xyh[i][2] - xyh[i+1][2]
    for x in range(101):
        for y in range(101):
            if not XY[y][x]: 
                continue
            if abs(x-xyh[i][0]) + abs(y-xyh[i][1]) != abs(x-xyh[i+1][0]) + abs(y-xyh[i+1][1]) - tmp:
                XY[y][x] = False

for x in range(101):
    for y in range(101):
        if XY[y][x]:
            print(x,y,abs(x-xyh[0][0]) + abs(y-xyh[0][1]) + xyh[0][2])
            break

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Wrong Answer

Solution code:
import statistics

def main():
    n = int(input())

    lst = [0 for i in range(n)]
    for i in range(n):
        lst[i] = list(map(int,input().split()))

    zero = False
    for i in range(n):
        if lst[i][2] != 0:
            break
        if i == n-1:
            zero = True

    if zero == True:
        for i in range(101):
            for j in range(101):
                h = []
                h_ij =[]
                for k in range(n):
                    tmp = lst[k][2] + abs(lst[k][0] - i) + abs(lst[k][1] - j)
                    h.append(tmp)
                    h_ij.append([i,j])

                    if k == n-1:
                        high = statistics.mode(h)
                        print(str(h_ij[h.index(h)][0])+ " " + str(h_ij[h.index(h)][1]) + " " + str(high))


    for i in range(101):
        for j in range(101):
            remain = []
            remain_flag = False
            for k in range(n):
                if k == 0 or remain_flag:
                    if lst[k][2] == 0:
                        remain.append(lst[k])
                        remain_flag = True
                        continue

                    h = lst[k][2] + abs(lst[k][0] - i) + abs(lst[k][1] - j)
                    remain_flag = False
                    continue

                if max(h - abs(lst[k][0] - i) - abs(lst[k][1] - j),0) == lst[k][2]:
                    if k == n-1:
                        for remain in remain:
                            if max(h - abs(remain[0] - i) - abs(remain[1] - j),0) != remain[2]:
                                break

                        print(str(i)+ " " + str(j) + " " + str(h))
                        exit()
                    continue
                else:
                    break


if __name__ == "__main__":
        main()

Submission status: Wrong Answer

Solution code:
def cal(X,Y,H):
    flag=0
    if(H[0]==0):    flag=1
    
    if(flag==0):
        for i in range(0,101):
            for j in range(0,101):
                temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
                for l in range(1,N):
                    if(H[l]!=0):
                        s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                        if(temp==s):
                            temp=s
                        else:
                            break
                    else:
                        if(temp-abs(X[l]-i)-abs(Y[l]-j)>0):
                            break
                else:
                    return print("{} {} {}".format(i,j,temp))
            
    elif(flag==1):
        p=[]
        for i in range(2,N):
            p.append(i)
        for i in range(0,101):
            for j in range(0,101):
                temp=H[1]+abs(X[1]-i)+abs(Y[1]-j)
                for l in p:
                    if(H[l]!=0 and l!=0):
                        s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                        if(temp==s):
                            temp=s
                        else:
                            break
                    else:
                        if(temp-abs(X[l]-i)-abs(Y[l]-j)>0):
                            break
                else:
                    return print("{} {} {}".format(i,j,temp))          
    

N=int(input())
X=[]
Y=[]
H=[]
for i in range(N):
    x,y,h=list(map(int,input().split()))
    X.append(x)
    Y.append(y)
    H.append(h)
cal(X,Y,H)

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>50:
    k = 110
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

Solution code:
n = int(input())
tmp = [int(i) for _ in range(n) for i in input().split()]

xs = tmp[0::3]
ys = tmp[1::3]
hs = tmp[2::3]
stopflag = False

if sum(hs) == 0:
    H = 1
    for cx in range(101):
        if cx not in xs:
            x_ans = cx
    for cy in range(101):
        if cy not in ys:
            y_ans = cy
    print('{} {} {}'.format(x_ans,y_ans,H))

else:
    for H in range(max(hs)-100, 10**9+1):
        for cx in range(101):
            for cy in range(101):
                for x,y,h in zip(xs,ys,hs):
                    if h != max(H-abs(x-cx)-abs(y-cy),0):
                        break
                else:
                    print('{} {} {}'.format(cx,cy,H))
                    stopflag = True
                    break
            if stopflag:
                break
        if stopflag:
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
for CX in range(101):
    for CY in range(101):
        ans = 1
        H = 1
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = abs(x - CX) + abs(y - CY) + h
            if H < 1 and H - abs(x - CX) - abs(y - CY) >= 0:
                ans = -1
                break
            #print(CX, CY)
            
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if h != max(H - abs(x - CX) - abs(y - CY), 0):
                ans = -1
                break
        if H < 1:
            ans = -1
            
        if ans == 1:
            print(CX, CY, H)
            break
    if ans == 1:
        break

Submission status: Wrong Answer

Solution code:
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
c=0
f=[]
k=[]
s=[]
def k(t,x,y):
  return abs(e[t+1][0]-x)+abs(e[t+1][1]-y)-abs(e[t][0]-x)-abs(e[t][1]-y)
for i in range(0,len(e)):
       if e[i][2]==0:
            c+=0
if c==0:
    for x in range(0,101):
        for y in range(0,101):
            for i in range(0,len(e)-1):
                if e[i][2]!=0 or e[i+1][2]!=0:
                    if k(i,x,y)!=e[i][2]-e[i+1][2]:
                        break 
            else:
                print(str(x)+" "+str(y)+" "+str(e[0][2]+abs(e[0][0]-x)+abs(e[0][1]-y)))
else:
    for x in range(0,101):
        for y in range(0,101):
            for i in range(0,len(e)-1):
                if e[i][2]!=0 or e[i+1][2]!=0:
                    if k(i,x,y)!=e[i][2]-e[i+1][2]:
                        break 
            else:
                f.append(x)
                k.append(y)
    else:
        for p in range(0,len(k)):
            for i in range(0,len(e)):
                if e[i][2]==0:
                    s.append(abs(e[i][0]-f[p])+abs(e[i][1]-k[p]))
            else:
                if e[0][2]+abs(e[0][0]-f[p])+abs(e[0][1]-k[p])>=max(s):
                    print(str(f[0])+" "+str(k[0])+" "+str(e[0][2]+abs(e[0][0]-f[0])+abs(e[0][1]-k[0])))

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

from itertools import product
cand = []
for cx, cy in product(range(101), range(101)):
    temp1 = abs(cx - x) + abs(cy - y)
    temp2 = temp1 + h
    if len(temp2[h>0]) < 2:
        continue
    else:
        if np.max(temp2[h > 0]) == np.min(temp2[h>0]):
            cand.append((cx,cy,np.max(temp2[h > 0])))
if len(cand) == 1:
    print(cand[0][0],cand[0][1],cand[0][2])
elif len(cand)>50:
    k = 55
    print(cand[-k][0],cand[-k][1],cand[-k][2])

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(101):
    for Cy in range(101):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and H[i] == max(h - abs(X[i]-Cx) - abs(Y[i]-Cy), 0):
            i += 1
        if i == N:
            print(Cx, Cy, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
if n>=4:
  for x in range(101):
    for y in range(101):
      a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
      c=0
      for z in range(1,n):
        if abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]!=a:
          break
        else:c+=1
        if c==n-1:print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
elif n>=3:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]==abs(l[2][0]-x)+abs(l[2][1]-y)+l[2][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
else:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])

Submission status: Wrong Answer

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

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

def check(cx,cy):
    Hs = []
    
    for i in range(n):
        x,y,h = card[i]
        z = abs(x-cx)+abs(y-cy)+h
        Hs.append(z)
    
    H = max(Hs)
        
    for i in range(n):
        x,y,h = card[i]
        if h == 100:
            print("{} {} {}".format(x,y,h))
            exit()

        if h == max((H-abs(x-cx)-abs(y-cy)),0):
            continue
        else:
            return False
    else:
        return True
    
for i in range(101):
    for j in range(101):
        if check(i,j):
            ax = i
            ay = j
            
            x1,y1,h1 = card[0]
            ah = abs(x1-i)+abs(y1-j)+h1

            print("{} {} {}".format(ax,ay,ah))
            exit()

Submission status: Wrong Answer

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

H = -1
C_x = 0
C_y = 0

def height(C_x,C_y,x,y,h):
  H = h + abs(x-C_x) + abs(y-C_y)
  return H

def koud(C_x,C_y,H,x,y):
  h = H - abs(x-C_x) - abs(y-C_y)
#  return max(h,0)
  return h

flag = False
for i in range(0,101):
  C_x = i
  for j in range(0,101):
    C_y = j
    H = -1
    for k in range(N):
      if zahyou[k][2] == 0:#高度が0のとき
        continue
      if H < 0:
        H = height(C_x,C_y,zahyou[k][0],zahyou[k][1],zahyou[k][2])
      else:
        if zahyou[k][2] != koud(C_x,C_y,H,zahyou[k][0],zahyou[k][1]):
          break
        else:
          continue        
    else:
      flag = True
      break
    if flag:
      break
  if flag:
    break

print(C_x,C_y,H)

Submission status: Wrong Answer

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


def H(cx, cy, x, y, h):
    return h + abs(x - cx) + abs(y - cy)

if not any(h for x, y, h in xyh if h > 0):
    for cx in range(0, 101):
        for cy in range(0, 101):
            TH = set(H(cx, cy, x, y, h) for x, y, h in xyh)
            if len(TH) == 1:
                a = TH.pop()
                if a == 1:
                    print(cx, cy, a)

else:
    for cx in range(0, 101):
        for cy in range(0, 101):
            TH = set(H(cx, cy, x, y, h) for x, y, h in xyh if h > 0)
            if len(TH) == 1:
                print(cx, cy, TH.pop())

Submission status: Wrong Answer

Solution code:
def check():
    for k in range(0,n):
        if h[k]==1000000000:
            print(x[k],y[k],h[k])
            return
    for i in range(0,101):
        for j in range(0,101):
            test=True
            h1=abs(i-x[0])+abs(j-y[0])+h[0]
            for k in range(1,n):
                if h1!=abs(i-x[k])+abs(j-y[k])+h[k]:
                    test=False
                    break;
            if test==True:
                print(i,j,h1)
                return
            
n=int(input())
x=[0 for i in range(0,n)]
y=[0 for i in range(0,n)]
h=[0 for i in range(0,n)]
for i in range(0,n):
    x[i],y[i],h[i]=map(int,input().split())
check()