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:
import sys
input = sys.stdin.readline
N = int(input())
B = [[int(x) for x in input().split()] for _ in range(N)]
def heighti(Cx,Cy,x,y,h):
    return abs(x-Cx) + abs(y-Cy) + h
ans = []
h0 = []
A = []
for l in B:
    if l[2] == 0:
        h0.append([l[0],l[1]])
    else:
        A.append(l)
for i in range(101):
    for j in range(101):
        tempH = heighti(i,j,A[0][0],A[0][1],A[0][2])
        if tempH < 0:
            break
        else:
            flag = 1
            for k in range(1,len(A)):
                if A[k][2] != 0 and heighti(i,j,A[k][0],A[k][1],A[k][2]) != tempH:
                    flag = 0
                    break
            if flag:
                ans.append([i,j,tempH])
if len(ans) == 1:
    print(*ans[0])
elif len(ans) == 0:
    for i in range(101):
        for j in range(101):
            for k in range(N):
                if heighti(i,j,A[k][0],A[k][1],A[k][2]) > 0:
                    print(*[i,j,heighti(i,j,A[k][0],A[k][1],A[k][2])])
                    sys.exit()
else:
    for m in ans:
        for n in h0:
            if heighti(n[0],n[1],m[0],m[1],m[2]) > 0:
                break
        print(*m)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
B = [[int(x) for x in input().split()] for _ in range(N)]
def heighti(Cx,Cy,x,y,h):
    return abs(x-Cx) + abs(y-Cy) + h
ans = []
h0 = []
A = []
for l in B:
    if l[2] == 0:
        h0.append([l[0],l[1]])
    else:
        A.append(l)
for i in range(101):
    for j in range(101):
        tempH = heighti(i,j,A[0][0],A[0][1],A[0][2])
        if tempH < 0:
            break
        else:
            flag = 1
            for k in range(1,len(A)):
                if A[k][2] != 0 and heighti(i,j,A[k][0],A[k][1],A[k][2]) != tempH:
                    flag = 0
                    break
            if flag:
                ans.append([i,j,tempH])
if len(ans) == 1:
    print(*ans[0])
else:
    for m in ans:
        for n in h0:
            if heighti(n[0],n[1],m[0],m[1],m[2]) > 0:
                break
        print(*m)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]
def heighti(Cx,Cy,x,y,h):
    return abs(x-Cx) + abs(y-Cy) + h
ans = []
h0 = []
for l in A:
    if l[2] == 0:
        h0.append([l[0],l[1]])
for i in range(101):
    for j in range(101):
        tempH = heighti(i,j,A[0][0],A[0][1],A[0][2])
        if tempH < 0:
            break
        else:
            flag = 1
            for k in range(1,N):
                if A[k][2] != 0 and heighti(i,j,A[k][0],A[k][1],A[k][2]) != tempH:
                    flag = 0
                    break
            if flag:
                ans.append([i,j,tempH])
if len(ans) == 1:
    print(*ans[0])
else:
    for m in ans:
        for n in h0:
            if heighti(n[0],n[1],m[0],m[1],m[2]) > 0:
                break
        print(*m)
        sys.exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
pyr=[[-1]*101 for i in range(101)]

N=int(input())

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

ans=0
num=300
temp=[]
for y in range(101):
    for x in range(101):
        for item in l:
            if item[2]==0:
                num=min(num,max(item[0],100-item[0])+max(item[1],100-item[1]))
                if num==max(item[0],100-item[0])+max(item[1],100-item[1]):
                    s=100 if item[0]<=50 else 0
                    t=100 if item[1]<=50 else 0
                pass
            elif pyr[y][x]==-1:
                pyr[y][x]=item[2]+abs(item[0]-x)+abs(item[1]-y)
            elif pyr[y][x]!=item[2]+abs(item[0]-x)+abs(item[1]-y):
                pyr[y][x]=-100
            else:
                pass
        ans=max(ans,pyr[y][x])
        if ans==pyr[y][x]:
            temp=[x,y,ans]
if temp:
    print(*temp)
else:
    print(s,t,num)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
pyr=[[-1]*101 for i in range(101)]

N=int(input())

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

ans=0
num=300
temp=[]
for y in range(101):
    for x in range(101):
        for item in l:
            if item[2]==0:
                num=min(num,max(item[0],100-item[0])+max(item[1],100-item[1]))
                pass
            elif pyr[y][x]==-1:
                pyr[y][x]=item[2]+abs(item[0]-x)+abs(item[1]-y)
            elif pyr[y][x]!=item[2]+abs(item[0]-x)+abs(item[1]-y):
                pyr[y][x]=-100
            else:
                pass
        ans=max(ans,pyr[y][x])
        if ans==pyr[y][x]:
            temp=[x,y,ans]
if temp:
    print(*temp)
else:
    print(num)

Submission status: Wrong Answer

Solution code:
N  = int(input())
XYH=[list(map(int,input().split())) for i in range(N)]
cch=[[0 for j in range(101) ] for i in range(101)]
  
for xyh in XYH:
  x=xyh[0]
  y=xyh[1]
  h=xyh[2]
  flag=0
  if h != 0:
    for cx in range(101):
      for cy in range(101):   
        H = h+abs(x-cx)+abs(y-cy)
        cch[cx][cy]=H
        flag=1
    break

for xyh in XYH:
  x=xyh[0]
  y=xyh[1]
  h=xyh[2]
  for cx in range(101):
    for cy in range(101): 
      if cch[cx][cy] != max(h+abs(x-cx)+abs(y-cy),0):
        cch[cx][cy]=0
            
for cx in range(101):
  for cy in range(101):
    if cch[cx][cy]!=0:
      print(cx,cy,cch[cx][cy]);exit()

Submission status: Wrong Answer

Solution code:
N  = int(input())
XYH=[list(map(int,input().split())) for i in range(N)]
cch=[[0 for j in range(101) ] for i in range(101)]
flag=[[0 for j in range(101) ] for i in range(101)]
  
for xyh in XYH:
  x=xyh[0]
  y=xyh[1]
  h=xyh[2]
        
  for cx in range(101):
    for cy in range(101): 
      if cch[cx][cy]!=-1:
        if h!=0:
          H = h+abs(x-cx)+abs(y-cy)
          if flag[cx][cy]==0:
              cch[cx][cy] =H
              flag[cx][cy]=2
          elif flag[cx][cy]==1:
            if cch[cx][cy]>=H:
              cch[cx][cy]=H
              flag[cx][cy]=2
            else:
              cch[cx][cy]=-1
              flag[cx][cy]=2
          elif flag[cx][cy]==2:
            if cch[cx][cy]!=H:
              cch[cx][cy]=-1
              flag[cx][cy]=2
        
        else:
          H = abs(x-cx)+abs(y-cy)
          if flag[cx][cy]==0:
              cch[cx][cy] =H
              flag[cx][cy]=1
          elif flag[cx][cy]==1:
            if cch[cx][cy]>=H:
              cch[cx][cy]=H
              flag[cx][cy]=1
          elif flag[cx][cy]==2:
            if cch[cx][cy]>=H:
              cch[cx][cy]=-1
              flag[cx][cy]=2
            
for cx in range(101):
  for cy in range(101):
    if cch[cx][cy]!=-1 and cch[cx][cy]!=0:
      print(cx,cy,cch[cx][cy]);exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
pyr=[[-1]*101 for i in range(101)]

N=int(input())

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

ans=0
for y in range(101):
    for x in range(101):
        for item in l:
            if item[2]==0:
                pass
            elif pyr[y][x]==-1:
                pyr[y][x]=item[2]+abs(item[0]-x)+abs(item[1]-y)
            elif pyr[y][x]!=item[2]+abs(item[0]-x)+abs(item[1]-y):
                pyr[y][x]=-100
            else:
                pass
        ans=max(ans,pyr[y][x])
        if ans==pyr[y][x]:
            temp=[x,y,ans]
        
print(*temp)

Submission status: Wrong Answer

Solution code:
N  = int(input())
XYH=[list(map(int,input().split())) for i in range(N)]
cch=[[0 for j in range(101) ] for i in range(101)]
flag=[[0 for j in range(101) ] for i in range(101)]
  
for xyh in XYH:
  x=xyh[0]
  y=xyh[1]
  h=xyh[2]
        
  for cx in range(101):
    for cy in range(101):     
      if h!=0:
        H = h+abs(x-cx)+abs(y-cy)
        if cch[cx][cy]!=-1:
          if flag[cx][cy]==0:
            if cch[cx][cy]>=H or cch[cx][cy]==0:
              cch[cx][cy]=H
              flag[cx][cy]=1
            else:
              cch[cx][cy]=-1
              flag[cx][cy]=1
          else:
            if cch[cx][cy]!=H:
              cch[cx][cy]=-1
              flag[cx][cy]=1          
        
      else:
        H = abs(x-cx)+abs(y-cy)
        if cch[cx][cy]!=-1:
          if flag[cx][cy]==0:
            if cch[cx][cy]>=H:
              cch[cx][cy]=H
              flag[cx][cy]=0
          else:
            if cch[cx][cy]>H:
              cch[cx][cy]=-1
              flag[cx][cy]=1
            
for cx in range(101):
  for cy in range(101):
    if cch[cx][cy]!=-1 and cch[cx][cy]!=0:
      print(cx,cy,cch[cx][cy]);exit()

Submission status: Wrong Answer

Solution code:
N  = int(input())
XYH=[list(map(int,input().split())) for i in range(N)]
cch=[[0 for j in range(101) ] for i in range(101)]
flag=[[0 for j in range(101) ] for i in range(101)]
  
for xyh in XYH:
  x=xyh[0]
  y=xyh[1]
  h=xyh[2]
        
  for cx in range(101):
    for cy in range(101):     
      if h!=0:
        H = h+abs(x-cx)+abs(y-cy)
        if flag[cx][cy]==0:
          if cch[cx][cy]==0:
            cch[cx][cy] =H
            flag[cx][cy]=1
          elif cch[cx][cy]>=H:
            cch[cx][cy]=-1
            flag[cx][cy]=1
        elif cch[cx][cy]!=H:
          cch[cx][cy]=-1
          flag[cx][cy]=1          
        
      else:
        H = abs(x-cx)+abs(y-cy)
        if flag[cx][cy]==0:
          if cch[cx][cy]==0:
            cch[cx][cy] =H
            flag[cx][cy]=0
          elif cch[cx][cy]>=H:
            cch[cx][cy]=H
            flag[cx][cy]=0
        elif cch[cx][cy]>H:
          cch[cx][cy]=-1
          flag[cx][cy]=1
                     
            
for cx in range(101):
  for cy in range(101):
    if cch[cx][cy]!=-1 and cch[cx][cy]!=0:
      print(cx,cy,cch[cx][cy]);exit()

Submission status: Wrong Answer

Solution code:
from itertools import product


def find_center(n, xyh):
    for cx, cy in product(range(101), repeat=2):
        for i in range(n):
            x, y, h = xyh[i]
            if i == 0:
                H_ans = h + abs(x - cx) + abs(y - cy)
                continue

            dist = abs(x - cx) + abs(y - cy)
            H_estimate = h + dist

            if H_ans == H_estimate:
                continue

            if H_estimate < H_ans:
                break

            if dist < H_ans:
                break
        else:
            return cx, cy, H_ans


if __name__ == "__main__":
    n = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(n)]
    xyh.sort(reverse=True, key=lambda x: x[-1])
    ans = find_center(n, xyh)
    print(*ans)

Submission status: Wrong Answer

Solution code:
from itertools import product


def find_center(n, xyh):
    for cx, cy in product(range(101), repeat=2):
        for i in range(n):
            x, y, h = xyh[i]
            if i == 0:
                H_ans = h + abs(x - cx) + abs(y - cy)
                continue

            dist = abs(x - cx) + abs(y - cy)
            H_estimate = h + dist

            if H_ans == H_estimate:
                continue

            if H_estimate < H_ans:
                break

            if dist <= H_ans:
                break
        else:
            return cx, cy, H_ans


if __name__ == "__main__":
    n = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(n)]
    xyh.sort(reverse=True, key=lambda x: x[-1])
    ans = find_center(n, xyh)
    print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [ [ int(v) for v in input().split() ] for i in range(n) ]
basedata = data[0]
data = data[1:]
field_width = 101

for i in range(field_width):
    for j in range(field_width):
        x, y, h = basedata
        estimate_height = h + abs(x-i) +abs(y-j)
        counter = 0
        for x, y, h in data:
            if estimate_height == h + abs(x-i) +abs(y-j):
                counter += 1
        if counter == n-1:
            print(i, j, estimate_height)

Submission status: Wrong Answer

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

#高さは一意に求まるので、どれをとっても良い、
a,b,c = list1[0]

#highについてのループ
for y in range(101):
  for x in range(101):
    h = c + abs(a-x) + abs(b-y) #頂点の座標
    if all(h_ == max(h-abs(x-i)-abs(y-j),0) for i,j,h_ in list1):
      print(x,y,h)
      exit()

Submission status: Wrong Answer

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

#高さは一意に求まるので、どれをとっても良い、
a,b,c = list1[0]

#highについてのループ
for y in range(101):
  for x in range(101):
    h = c + abs(a-x) + abs(b-y) #頂点の座標
    if all(h_ == h-abs(x-i)-abs(y-j) for i,j,h_ in list1):
      print(x,y,h)
      exit()

Submission status: Wrong Answer

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

found_data = False
x = int(map_list[-1][0])
y = int(map_list[-1][1])
h = int(map_list[-1][2])

for i in range(101):
    for j in range(101):
        cont_check = True
        H = abs(i - x) + abs(j - y) + h
        
        for data in map_list:
            xx, yy, hh = map(int, data)
            if h != max(H - abs(i - x) - abs(j - y), 0):
                cont_check = False
                break
        if cont_check:
            break
    if cont_check:
        break

print(i, j, H)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
list1 = [list(map(int,input().split())) for i in range(n)]
array = [[-1 for j in range(101)] for i in range(101)]

#highについてのループ
for i in list1: #[x,y,h]
  for y in range(101):
    for x in range(101):
      h = i[2] + (abs(x-i[0]) + abs(y-i[1]))
      if array[y][x] == -1:
        array[y][x] = max(0,h)
      elif array[y][x] > 0:
        if not array[y][x] == h:
          array[y][x] = -2
#print(array_h)
for y in range(101):
    for x in range(101):
      if array[y][x] > 0:
        print(x,y,array[y][x])
        exit()

Submission status: Wrong Answer

Solution code:

n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
x = int(map_list[-1][0])
y = int(map_list[-1][1])
h = int(map_list[-1][2])

for i in range(101):
    for j in range(101):
        cont_check = True
        H = abs(i - x) + abs(j - y) + h
        
        for data in map_list:
            x, y, h = map(int, data)
            if h != max(H - abs(i - x) - abs(j - y), 0):
                cont_check = False
                break
        if cont_check:
            break
    if cont_check:
        break

print(i, j, H)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
list1 = [list(map(int,input().split())) for i in range(n)]
space = -1
for i in list1:
  space = max(space,i[2])
#x,y,h
array_h = [[0 for j in range(101)] for i in range(101)]
array_l = [[0 for j in range(101)] for i in range(101)]

#highについてのループ
for i in list1: #[x,y,h]
  for y in range(101):
    for x in range(101):
      h = i[2] + (abs(x-i[0]) + abs(y-i[1]))
      if array_h[y][x] == 0:
        array_h[y][x] = max(0,h)
      elif array_h[y][x] > 0:
        if not array_h[y][x] == h:
          array_h[y][x] = -1
#print(array_h)
for y in range(101):
    for x in range(101):
      if array_h[y][x] > 0:
        print(x,y,array_h[y][x])
        exit()

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
list1 = [list(map(int,input().split())) for i in range(n)]
space = -1
for i in list1:
  space = max(space,i[2])
#x,y,h
array_h = [[0 for j in range(101)] for i in range(101)]
array_l = [[0 for j in range(101)] for i in range(101)]

#highについてのループ
for i in list1: #[x,y,h]
  for y in range(101):
    for x in range(101):
      h = i[2] + (abs(x-i[0]) + abs(y-i[1]))
      if array_h[y][x] == 0:
        array_h[y][x] = max(0,h)
      elif array_h[y][x] > 0:
        if not array_h[y][x] == h:
          array_h[y][x] = -1
print(array_h)
for y in range(101):
    for x in range(101):
      if array_h[y][x] > 0:
        print(x,y,array_h[y][x])
        exit()

Submission status: Wrong Answer

Solution code:

n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
x = int(map_list[-1][0])
y = int(map_list[-1][1])
h = int(map_list[-1][2])

for i in range(101):
    for j in range(101):
        cont_check = True
        H = abs(i - x) + abs(j - y) + h
        
        for data in map_list:
            x, y, h = map(int, data)
            if h != max(H - abs(i - x) - abs(j - y), 0):
                cont_check = False
                break
        if cont_check:
            break
    if cont_check:
        break

H = abs(i - x) + abs(j - y) + h
print(i, j, H)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
list1 = [list(map(int,input().split())) for i in range(n)]
space = -1
for i in list1:
  space = max(space,i[2])
#x,y,h
array_h = [[0 for j in range(101)] for i in range(101)]
array_l = [[0 for j in range(101)] for i in range(101)]

#highについてのループ
for i in list1: #[x,y,h]
  for y in range(101):
    for x in range(101):
      h = i[2] + (abs(x-i[0]) + abs(y-i[1]))
      l = i[2] - (abs(x-i[0]) + abs(y-i[1]))
      if array_h[y][x] == 0:
        array_h[y][x] = max(0,h)
      elif array_h[y][x] > 0:
        if not array_h[y][x] in [h,l]:
          array_h[y][x] = -1

for y in range(101):
    for x in range(101):
      if array_h[y][x] >= space:
        print(x,y,array_h[y][x])
        exit()

Submission status: Wrong Answer

Solution code:


n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
for i in range(101):
    for j in range(101):
        c = 0
        x = int(map_list[0][0])
        y = int(map_list[0][1])
        h = int(map_list[0][2])
        H = abs(i - x) + abs(j - y) + h
        
        for data in map_list[:]:
            x, y, h = map(int, data)
            if h != max(H - abs(i - x) - abs(j - y), 0):
                break
            c += 1

        if c >= n - 1:
            found_data = True
            break
    if found_data:
        break

H = abs(i - x) + abs(j - y) + h
print(i, j, H)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
n = int(input())
list1 = [list(map(int,input().split())) for i in range(n)]
space = -1
for i in list1:
  space = max(space,i[2])
#x,y,h
array_h = np.zeros((101,101),dtype=int)
array_l = np.zeros((101,101),dtype=int)

#highについてのループ
for i in list1: #[x,y,h]
  for y in range(101):
    for x in range(101):
      h = i[2] + (abs(x-i[0]) + abs(y-i[1]))
      l = i[2] - (abs(x-i[0]) + abs(y-i[1]))
      if array_h[y][x] == 0:
        array_h[y][x] = max(0,h)
      elif array_h[y][x] > 0:
        if not array_h[y][x] in [h,l]:
          array_h[y][x] = -1
  print(array_h)

for y in range(101):
    for x in range(101):
      if array_h[y][x] >= space:
        print(x,y,max(array_h[y][x],array_l[y][x]))
        exit()

Submission status: Wrong Answer

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

found_data = False
for i in range(101):
    for j in range(101):
        c = 0
        x = map_list[0][0]
        y = map_list[0][1]
        h = map_list[0][2]
        h = max(int(h), 0)
        H = abs(i - int(x)) + abs(j - int(y)) + int(h)
        #print('base:',i, j, H)
        
        for data in map_list[1:]:
            x, y, h = data
            h = max(int(h), 0)
            #print('check:',i, j, H, abs(i - int(x)) + abs(j - int(y) + int(h)))
            if int(h) != max(H - abs(i - int(x)) - abs(j - int(y)), 0):
                break
            c += 1
        if c >= n - 1:
            found_data = True
            break
    if found_data:
        break

h = abs(i - int(x)) + abs(j - int(y)) + int(h)
print(i, j, h)

Submission status: Wrong Answer

Solution code:

n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
for i in range(101):
    for j in range(101):
        c = 0
        x = map_list[0][0]
        y = map_list[0][1]
        h = map_list[0][2]
        h = max(int(h), 0)
        val = abs(i - int(x)) + abs(j - int(y)) + int(h)
        #print('base:',i, j, val)
        
        for data in map_list[1:]:
            x, y, h = data
            h = max(int(h), 0)
            #print('check:',i, j, val, abs(i - int(x)) + abs(j - int(y) + int(h)))
            if val != abs(i - int(x)) + abs(j - int(y)) + int(h):
                break
            c += 1
        if c >= n - 1:
            found_data = True
            break
    if found_data:
        break

h = abs(i - int(x)) + abs(j - int(y)) + int(h)
print(i, j, h)

Submission status: Wrong Answer

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

found_data = False
for i in range(101):
    for j in range(101):
        c = 0
        x = map_list[0][0]
        y = map_list[0][1]
        h = map_list[0][2]
        val = abs(i - int(x)) + abs(j - int(y)) + int(h)
        #print('base:',i, j, val)
        
        for data in map_list[1:]:
            x, y, h = data
            #print('check:',i, j, val, abs(i - int(x)) + abs(j - int(y) + int(h)))
            if val != abs(i - int(x)) + abs(j - int(y)) + int(h):
                break
            c += 1
        if c >= n - 1:
            found_data = True
            break
    if found_data:
        break

h = abs(i - int(x)) + abs(j - int(y)) + int(h)
print(i, j, h)

Submission status: Wrong Answer

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

found_data = False
for i in range(101):
    for j in range(101):
        c = 0
        x = map_list[0][0]
        y = map_list[0][1]
        h = map_list[0][2]
        val = abs(i - int(x)) + abs(j - int(y)) + int(h)
        #print('base:',i, j, val)
        
        for data in map_list[1:]:
            x, y, h = data
            #print('check:',i, j, val, abs(i - int(x)) + abs(j - int(y) + int(h)))
            if val != abs(i - int(x)) + abs(j - int(y)) + int(h):
                break
            c += 1

        if c == n -1:
            found_data = True
            break
    if found_data:
        break

h = abs(i - int(x)) + abs(j - int(y)) + int(h)
print(i, j, h)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[0]*N
Y=[0]*N
H=[0]*N
import sys
for i in range(N):
    X[i],Y[i],H[i]=map(int,input().split())
for x in range(100+1):
    for y in range(100+1):
        for i in range(0,N):
            
            if H[i]>0:
                assume_h = H[i] + abs(x-X[i]) + abs(y-Y[i])
                target = i
                break
                
        for i in range(N):
            #print(x,y,i)
            #print(H[i] + abs(x-X[i]) + abs(y-Y[i]))
            if H[i]  != min(assume_h - abs(x-X[i]) - abs(y-Y[i]), 0):
                break
        else:
            print(x,y,assume_h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[0]*N
Y=[0]*N
H=[0]*N
import sys
for i in range(N):
    X[i],Y[i],H[i]=map(int,input().split())
for x in range(100+1):
    for y in range(100+1):
        for i in range(0,N):
            if H[i]>0:
                assume_h = H[i] + abs(x-X[i]) + abs(y-Y[i])
                target = i
                break
        for i in range(N):
            #print(x,y,i)
            #print(H[i] + abs(x-X[i]) + abs(y-Y[i]))
            if H[i] + abs(x-X[i]) + abs(y-Y[i]) != assume_h:
                break
        else:
            print(*[x,y,assume_h])
            sys.exit()

Submission status: Wrong Answer

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    idxes = []

    for i in range(N):
        X[i], Y[i], H[i] = MI()
        idxes.append((H[i], i))

    idxes.sort(reverse=True)

    for cx in range(101):
        for cy in range(101):
            ans = None
            zero_arr = []
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            else:
                tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                zero_arr.append(tmp)
            counter = 1
            for _, i in idxes:
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    zero_arr.append(tmp)
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                if ans is not None and len(zero_arr) == 0:
                    print(cx, cy, ans)
                    return
                elif ans is not None and len(zero_arr) != 0:
                    print(cx, cy, ans)
                    return
                elif ans is None and len(zero_arr) != 0:
                    a = X[0] + Y[0]
                    for i in range(1, N):
                        a = min(a, X[i] + Y[i])
                    print(cx, cy, a)
                    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    idxes = []

    for i in range(N):
        X[i], Y[i], H[i] = MI()
        idxes.append((H[i], i))

    idxes.sort(reverse=True)

    for cx in range(101):
        for cy in range(101):
            ans = None
            zero_arr = []
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            else:
                tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                zero_arr.append(tmp)
            counter = 1
            for _, i in idxes:
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    zero_arr.append(tmp)
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                if ans is None and ans == min(zero_arr):
                    print(zero_arr, ans)
                    a = X[0] + Y[0]
                    for i in range(1, N):
                        a = min(a, X[i] + Y[i])
                    print(cx, cy, a)
                    return
                elif len(zero_arr) == 0:
                    print(cx, cy, ans)
                    return
                elif ans == min(zero_arr):
                    print(cx, cy, ans)
                    return


if __name__ == '__main__':
    main()