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

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

H={}
ans_x=ans_y=ans_h=0

for cx in range(101):
    for cy in range(101):
        H=set()
        for x, y, h in D:
            if h >=1:
                H.add(abs(x-cx)+abs(y-cy)+h)
        if len(H)==1:
            print(cx, cy, list(H)[0])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(x[2]!=0):
                    if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
        if(flag):
            if(h>ans[2] and h <= 10**9):
                ans=[i,j,h]

print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(x[2]!=0):
                    if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
        if(flag):
            if(h>ans[2]):
                ans=[i,j,h]

print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                    flag = False
        if(flag):
            if(h>ans[2]):
                ans=[i,j,h]
                
print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = ['0']*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                    flag = False
        if(flag):
            ans=[str(i),str(j),str(h)]
            break
print(ans[0]+' '+ans[1]+' '+ans[2])

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
l = []
for i in range(N):
    a = list(map(int, input().split()))
    if a[-1] > 0:
        l.append(a)

for i in range(len(l)):
    Hn = []
    for cx in range(101):
        for cy in range(101):
            H_tmp = [cx, cy, l[i][2] + abs(l[i][0] - cx) + abs(l[i][1] - cy)]
            if i == 0:
                Hn.append(H_tmp)
            else:
                if H_tmp in H:
                    Hn.append(H_tmp)
    H = Hn[:]
print(H[0][0], H[0][1], H[0][2])

Submission status: Wrong Answer

Solution code:
#sys.stdin.readline()
import sys
input = sys.stdin.readline

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

Cx,Cy = [],[]
for i in range(101):
  for j in range(101):
    Cx.append(i),Cy.append(j)

if(N == 1):
  print(x,y,h)
else:
 # H = hi+|Xi-Cx|+|Yi-Cy|
 ans_cx,ans_cy,ans_h = 0,0,0
 for i in range(101*101): 
  judge = 1 #1:全ての点が条件を満たす,0:NG
  for j in range(len(X)):
   if(j == 0): 
     ans_H = H[j] + abs(X[j]-Cx[i]) + abs(Y[j]-Cy[i])
   else:
     tmp_H = H[j] + abs(X[j]-Cx[i]) + abs(Y[j]-Cy[i])
     if(ans_H != tmp_H):
       judge = 0
       break
  if(judge == 1):
    ans_cx,ans_cy = Cx[i],Cy[i]
    break

 print(ans_cx,ans_cy,ans_H)

Submission status: Wrong Answer

Solution code:
#sys.stdin.readline()
import sys
input = sys.stdin.readline

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)

Cx,Cy = [],[]
for i in range(101):
  for j in range(101):
    Cx.append(i),Cy.append(j)

if(N == 1):
  print(x,y,h)
else:
 # H = hi+|Xi-Cx|+|Yi-Cy|
 ans_cx,ans_cy,ans_h = 0,0,0
 for i in range(101*101): 
  judge = 1 #1:全ての点が条件を満たす,0:NG
  for j in range(N):
   if(j == 0): 
     ans_H = H[j] + abs(X[j]-Cx[i]) + abs(Y[j]-Cy[i])
   else:
     tmp_H = H[j] + abs(X[j]-Cx[i]) + abs(Y[j]-Cy[i])
     if(ans_H != tmp_H):
       judge = 0
       break
  if(judge == 1):
    ans_cx,ans_cy = Cx[i],Cy[i]
    break

 print(ans_cx,ans_cy,ans_H)

Submission status: Wrong Answer

Solution code:
#sys.stdin.readline()
import sys
input = sys.stdin.readline

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)

Cx,Cy = [],[]
for i in range(101):
  for j in range(101):
    Cx.append(i),Cy.append(j)

# H = hi+|Xi-Cx|+|Yi-Cy|
ans_cx,ans_cy,ans_h = 0,0,0
for i in range(101*101): 
 judge = 1 #1:全ての点が条件を満たす,0:NG
 for j in range(N):
  if(j == 0): 
    ans_H = H[j] + abs(X[j]-Cx[i]) + abs(Y[j]-Cy[i])
  else:
    tmp_H = H[j] + abs(X[j]-Cx[i]) + abs(Y[j]-Cy[i])
    if(ans_H != tmp_H):
      judge = 0
      break
 if(judge == 1):
   ans_cx,ans_cy = Cx[i],Cy[i]
   break

print(ans_cx,ans_cy,ans_H)

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
info = np.array([input().split() for _ in range(0, N)], dtype='int')
info = info[np.argsort(info[:,2])]
start_x = info[0,:][0]
start_y = info[0,:][1]
start_h = info[0,:][2]

for Cx in range(101):
    for Cy in range(101):
        H = start_h+abs(start_x-Cx)+abs(start_y-Cy)
        if all(max(0,H-abs(x-Cx)-abs(y-Cy))==h for x,y,h in info):
            print(Cx,Cy,H)
            break
        else:
            continue
        break

Submission status: Wrong Answer

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

def get_H(data,Cx,Cy):
    x,y,h = data
    return h+abs(x-Cx)+abs(y-Cy) , h==0
def estimate_H(data,Cx,Cy):
    H,_ = get_H(data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp,isZero = get_H(cur_data,Cx,Cy)
        if isZero and H >= tmp:
            continue
        if H != tmp:
            break
    else:
        return H
    return None

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break

Submission status: Wrong Answer

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

def get_H(data,Cx,Cy):
    x,y,h = data
    return h+abs(x-Cx)+abs(y-Cy) , h==0
def estimate_H(data,Cx,Cy):
    H,_ = get_H(data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp,isZero = get_H(cur_data,Cx,Cy)
        if isZero and H >= tmp:
            continue
        if H != tmp:
            break
    else:
        return H
    return None

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            #break

Submission status: Wrong Answer

Solution code:
N = int(input())
data = [list(map(int,input().split())) for _ in range(N)]
sorted_data = sorted(data,key=lambda x: x[2])

def get_H(data,Cx,Cy):
    x,y,h = data
    return max(0,h+abs(x-Cx)+abs(y-Cy))
def estimate_H(data,Cx,Cy):
    H = get_H(data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp = get_H(cur_data,Cx,Cy)
        if H != tmp:
            break
    else:
        return H
    return None

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(sorted_data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    a = LIR(n)
    if n == 1:
        print(*a[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                x,y,h = a[i]
                H = abs(x-cx)+abs(y-cy)+h
                if H > 0:break
            f = True
            for i in range(n):
                x,y,h = a[i]
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    f = False
                    break
            if f:
                print(cx,cy,H)
                quit()
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = I()
    a = LIR(n)
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                x,y,h = a[i]
                H = abs(x-cx)+abs(y-cy)+h
                if H > 0:break
            f = True
            for i in range(n):
                x,y,h = a[i]
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    f = False
                    break
            if f:
                print(cx,cy,H)
                quit()
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())

mappings = []

for i in range(n):
    mapping = [int(i) for i in input().split()]
    mappings.append(mapping)

for cx in range(101):
    for cy in range(101):
        H = -1
        for i in range(n):
            x,y,h = mappings[i]
            if h == 0:
                pass
            else:
                if H == -1:
                    H = h+abs(x-cx)+abs(y-cy)
                elif H!=h+abs(x-cx)+abs(y-cy):
                    break

            if i == len(mappings)-1:
                    ans = (cx,cy,H)

cx,cy,H = ans
print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())

mappings = []

for i in range(n):
    mapping = [int(i) for i in input().split()]
    mappings.append(mapping)

for cx in range(101):
    for cy in range(101):
        H = -1
        for i in range(n):
            x,y,h = mappings[i]
            if h != 0 and H == -1:
                H = h+abs(x-cx)+abs(y-cy)
            elif h != 0 and H!=h+abs(x-cx)+abs(y-cy):
                break

            if i == len(mappings)-1:
                ans = (cx,cy,H)

cx,cy,H = ans
print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import numpy as np
import random

n = int(input())

mappings = []

for i in range(n):
    mapping = [int(i) for i in input().split()]
    mappings.append(mapping)

for cx in range(101):
    for cy in range(101):
        H = -1
        for i in range(n):
            x,y,h = mappings[i]
            if h != 0 and H == -1:
                H = h+abs(x-cx)+abs(y-cy)
            elif h != 0 and H!=h+abs(x-cx)+abs(y-cy):
                break

            if i == len(mappings)-1:
                ans = (cx,cy,H)


print(ans)

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
if n == 1:
    print(a_list[0])
else:
    for k in range(n):
        if a_list[k][2] == 100:
            print(a_list[k])
            break
    x_range = range(101)
    y_range = range(101)
    for i in x_range:
        for j in y_range:
            lastH = None
            for x, y, h in a_list:
                H = abs(x-i) + abs(y-j) + h
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(i, j, H)
                break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
if n == 1:
    print(a_list[0])
else:
    for k in range(n):
        if a_list[k][2] == 100:
            print(a_list[k])
            break
    x_range = range(101)
    y_range = range(101)
    for i in x_range:
        for j in y_range:
            h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
            if (len(set(h_list)) == 1) & (sum(h_list) > 0):
                for tx, ty, th in a_list:
                    div = abs(tx - i) + abs(ty - j)
                    if div > h_list[0]:
                        if th == 0:
                            continue
                    else:
                        print(i, j, h_list[0])
                        break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
if n == 1:
    print(a_list[0])
else:
    for k in range(n):
        if a_list[k][2] == 100:
            print(a_list[k])
            break
    x_range = range(101)
    y_range = range(101)
    for i in x_range:
        for j in y_range:
            h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
            if (len(set(h_list)) == 1) & (sum(h_list) > 0):
                print(i, j, h_list[0])
                break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
if n == 1:
    print(a_list[0])
else:
    x_range = range(101)
    y_range = range(101)
    for i in x_range:
        for j in y_range:
            h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
            if (len(set(h_list)) == 1) & (sum(h_list) > 0):
                print(i, j, h_list[0])
                break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
if n == 1:
    print(a_list[0])
else:
    x_range = range(101)
    y_range = range(101)
    for i in x_range:
        for j in y_range:
            h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
            if (len(set(h_list)) == 1) & (h_list[0] > 0):
                print(i, j, h_list[0])
                break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
x_range = range(101)
y_range = range(101)
for i in x_range:
    for j in y_range:
        h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
        if (len(set(h_list)) == 1) & (h_list[0] > 0):
            print(i, j, h_list[0])
            break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
x_range = range(101)
y_range = range(101)
for i in x_range:
    for j in y_range:
        h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
        if len(set(h_list)) == 1:
            print(i, j, h_list[0])
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
XYH = [list(map(int,input().split())) for _ in range(n)]
flag = False
ans = XYH[0]
for i in range(101):
    for j in range(101):
        tempH = abs(XYH[0][0] - i) + abs(XYH[0][1] - j) + XYH[0][2]
        for x,y,h in XYH[1:]:
            if abs(x - i) + abs(y - j) + h != tempH:
                flag = False
                break
            else:
                flag = True
        if flag:
            ans = [i,j,tempH]
            break
    if flag:
        break

print(*ans,sep = " ")

Submission status: Wrong Answer

Solution code:
A=abs
n=int(input())
p=eval('list(map(int,input().split())),'*n)
x,y,h=[x for x in p if x[2]][0]
for I in range(10201):
  j,i=I//101,I%101
  H=h+A(x-j)+A(y-i)
  print(*(j,i,H)*all(u==H-A(s-j)-A(t-i)for s,t,u in p))

Submission status: Wrong Answer

Solution code:

n=int(input());p=eval('list(map(int,input().split())),'*n);x,y,h=[x for x in p if x[2]][0]
for I in range(10201):j,i=I//101,I%101;H=h+abs(x-j)+abs(y-i);print(*(j,i,H)*all(max(u==H-abs(s-j)-abs(t-i),0)for s,t,u in p))

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
n=int(input())
l=[tuple(map(int,input().split()))for i in range(n)]
l=[i for i in l if i[2]!=0]
s=l[0]
l2=[[x,y,s[2]+abs(x-s[0])+abs(y-s[1])]for y in range(101)for x in range(101)]
l3=deepcopy(l2)
for s in l3:
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
print(*l2[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[tuple(map(int,input().split()))for i in range(n)]
s=l[0]
l2=[[x,y,s[2]+abs(x-s[0])+abs(y-s[1])]for y in range(101)for x in range(101)]
for s in l2:
    for t in l:
        if s[2]!=t[2]+abs(s[0]-t[0])+abs(s[1]-t[1]):
            try:
                l2.remove(s)
            except:
                continue
print(*l2[0])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    NLIST = []
    for i in range(N):
        x,y,h = map(int, lines.pop(0).split(' '))
        NLIST.append((x,y,h))
    if len(NLIST) == 1:
        i,j,k = NLIST[0]
        print(i,j,k)
        sys.exit(0)
    for i in range(0,101):
        for j in range(0,101):
            top = 0
            flag = True
            for k in NLIST:
                if k[2] == 0:
                    continue
                ch = abs(i-k[0]) + abs(j-k[1]) + k[2]
                if top != 0 and top != ch:
                    flag = False
                    break
                else:
                    top = ch
            if flag and top > 0:
                print(i,j,top)
                sys.exit(0)

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    NLIST = []
    for i in range(N):
        x,y,h = map(int, lines.pop(0).split(' '))
        NLIST.append((x,y,h))
    for i in range(0,101):
        for j in range(0,101):
            top = 0
            flag = True
            for k in NLIST:
                if k[2] == 0:
                    continue
                ch = abs(i-k[0]) + abs(j-k[1]) + k[2]
                if top != 0 and top != ch:
                    flag = False
                    break
                else:
                    top = ch
            if flag and top > 0:
                print(i,j,top)
                sys.exit

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    NLIST = []
    for i in range(N):
        x,y,h = map(int, lines.pop(0).split(' '))
        NLIST.append((x,y,h))
    for i in range(0,101):
        for j in range(0,101):
            top = 0
            flag = True
            for k in NLIST:
                if k[2] == 0:
                    continue
                ch = abs(i-k[0]) + abs(j-k[1]) + k[2]
                if top != 0 and top != ch:
                    flag = False
                    break
                else:
                    top = ch
            if flag:
                print(i,j,top)
                sys.exit

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    NLIST = []
    for i in range(N):
        x,y,h = map(int, lines.pop(0).split(' '))
        NLIST.append((x,y,h))
    for i in range(0,101):
        for j in range(0,101):
            top = 0
            flag = True
            for k in NLIST:
                ch = abs(i-k[0]) + abs(j-k[1]) + k[2]
                if top != 0 and top != ch:
                    flag = False
                    break
                else:
                    top = ch
            if flag:
                print(i,j,top)
                sys.exit

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Wrong Answer

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


for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for n in range(N):
            xn, yn, hn = XYH[n]
            Hn = int(hn + abs(xn - cx) + abs(yn - cy))
            H_list.append(Hn)
        if len(set(H_list)) == 1 and H_list[0] >= 1:
            print(cx, cy, int(H_list[0]))
            quit()

Submission status: Wrong Answer

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


for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for n in range(N):
            xn, yn, hn = XYH[n]
            Hn = hn + int(abs(xn - cx)) + int(abs(yn - cy))
            H_list.append(Hn)
        if len(set(H_list)) == 1 and H_list[0] >= 1:
            print(cx, cy, int(H_list[0]))
            quit()

Submission status: Wrong Answer

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


for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for n in range(N):
            xn, yn, hn = XYH[n]
            Hn = hn + abs(xn - cx) + abs(yn - cy)
            H_list.append(Hn)
        if len(set(H_list)) == 1 and H_list[0] >= 1:
            print(cx, cy, H_list[0])
            quit()

Submission status: Wrong Answer

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


for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for n in range(N):
            xn, yn, hn = XYH[n]
            Hn = hn + abs(xn - cx) + abs(yn - cy)
            H_list.append(Hn)
        if len(set(H_list)) == 1:
            print(cx, cy, H_list[0])
            quit()

Submission status: Wrong Answer

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

for xyh in XYH:
    if xyh[2] > 0:
        XYH_.append(xyh)

# まず中心を求める。
H_ = int(0)
Cx, Cy = None, None
for i in range(101):
    cx = i
    for j in range(101):
        cy=j
        test = [H_-abs(x-cx)-abs(y-cy) - h for x, y, h in XYH]
        if all([test[0]==h for h in test]):
            Cx=cx
            Cy=cy
            H =[ xyh[2] + abs(xyh[0]-Cx) + abs(xyh[1]-Cy) for xyh in XYH]
            if all([H[0]==h for h in H]):
                H_ = H[0]
print(Cx, Cy, H_)

Submission status: Wrong Answer

Solution code:
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[j]


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

Submission status: Wrong Answer

Solution code:
N = int( input())
X = [ list( map( int, input().split())) for _ in range(N)]
for j in range(N):
    if X[j][2] != 0:
        k = j
        break
A = X[k]


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

Submission status: Wrong Answer

Solution code:
import sys
 
N = int(input())
infos = [list(map(int, input().rstrip().split(' '))) + [i] for i in range(N)]
infos = sorted(infos, key=lambda x: x[1])[::-1]

if N == 1:
    print(infos[0][0], infos[0][1], infos[0][2])
    sys.exit()

for cy in range(100 + 1):
    for cx in range(100 + 1):
        pseudo_h1 = abs(infos[0][0] - cx) + abs(infos[0][1] - cy) + infos[0][2]
 
        flag_assumpt = True
        for info in infos[1:]:
            pseudo_h2 = abs(info[0] - cx) + abs(info[1] - cy) + info[2]
            
            if info[2] == 0:
                if abs(info[0] - cx) + abs(info[1] - cy) < pseudo_h1:
                    flag_assumpt = False
                    break
                
            elif pseudo_h1 != pseudo_h2:
                flag_assumpt = False
                break
        
        if flag_assumpt:
            print(cx, cy, pseudo_h1)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
 
N = int(input())
infos = [list(map(int, input().rstrip().split(' '))) + [i] for i in range(N)]

if N == 1:
    print(infos[0][0], infos[0][1], infos[0][2])
    sys.exit()


if sum([x[2] for x in infos]) == 0:
    field = [[False] * (100 + 1) for _ in range(100 + 1)]
    for info in infos:
        field[info[1]][info[0]] = True
    
    for y in range(100 + 1):
        for x in range(100 + 1):
            if field[y][x] == False:
                print(x, y, 1)
                sys.exit()

 
for cy in range(100 + 1):
    for cx in range(100 + 1):
        pseudo_h1 = abs(infos[0][0] - cx) + abs(infos[0][1] - cy) + infos[0][2]
 
        flag_assumpt = True
        for info in infos[1:]:
            pseudo_h2 = abs(info[0] - cx) + abs(info[1] - cy) + info[2]
            
            if info[2] == 0:
                if abs(info[0] - cx) + abs(info[1] - cy) < pseudo_h1:
                    flag_assumpt = False
                    break
                
            elif pseudo_h1 != pseudo_h2:
                flag_assumpt = False
                break
        
        if flag_assumpt:
            print(cx, cy, pseudo_h1)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
 
N = int(input())
infos = [list(map(int, input().rstrip().split(' '))) + [i] for i in range(N)]

if N == 1:
    print(infos[0][0], infos[0][1], infos[0][2])
    sys.exit()


if sum([x[2] for x in infos]) == 0:
    field = [[False] * (100 + 1) for _ in range(100 + 1)]
    for info in infos:
        field[info[1]][info[0]] = True
    
    for y in range(100 + 1):
        for x in range(100 + 1):
            if field[y][x] == False:
                print(x, y, 1)
                sys.exit()

 
for cy in range(100 + 1):
    for cx in range(100 + 1):
        pseudo_h1 = abs(infos[0][0] - cx) + abs(infos[0][1] - cy) + infos[0][2]
 
        flag_assumpt = True
        for info in infos[1:]:
            if info[2] != 0:
                pseudo_h2 = abs(info[0] - cx) + abs(info[1] - cy) + info[2]
     
                if pseudo_h1 != pseudo_h2:
                    flag_assumpt = False
                    break
        
        if flag_assumpt:
            print(cx, cy, pseudo_h1)
            sys.exit()