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())
xyh = []
xyh1 = []
for _ in range(N):
	x0, y0, h0 = map(int, input().split())
	xyh.append([x0,y0,h0])
	if h0 >= 0:
		xyh1.append([x0,y0,h0])

def absum(x, y, h, Cx, Cy):
	return abs(x - Cx) + abs(y - Cy) + h


for Cx in range(101):
	for Cy in range(101):
		for i in range(len(xyh1)-1):
			if absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy) != absum(xyh1[i+1][0], xyh1[i+1][1], xyh1[i+1][2], Cx, Cy):
				break
		else:
			H = absum(xyh1[i][0], xyh1[i][1], xyh1[i][2], Cx, Cy)
			print(Cx, Cy, H)

Submission status: Wrong Answer

Solution code:
import itertools

n=int(input())
# x1,y1,h1
test_data = []
for _ in range(n):
     check=[int(i) for i in input().split()]
     if check[2]!=0:
         test_data.append(check)

for cx, cy in itertools.product(range(100 + 1), range(100+1)):
    blnCorrect=True
    H=test_data[0][2] + abs(test_data[0][0] - cx) + abs(test_data[0][1] - cy)
    for coord in test_data:
        if  coord[2]!=max(H-abs(coord[0] - cx) - abs(coord[1] - cy),0):
            blnCorrect = False
            break
    if blnCorrect:
        print(cx,cy,H)
        break

Submission status: Wrong Answer

Solution code:
import itertools

n=int(input())
# x1,y1,h1
test_data = [[int(i) for i in input().split()] for _ in range(n)] 

for cx, cy in itertools.product(range(100 + 1), range(100+1)):
    blnCorrect=True
    H=-1
    for coord in test_data:
        if coord[2]==0:
            continue
        H_new = coord[2] + abs(coord[0] - cx) + abs(coord[1] - cy)
        if  H > 0 and H != H_new:
            blnCorrect = False
            break
        H = H_new
    if blnCorrect:
        print(cx,cy,H)
        break

Submission status: Wrong Answer

Solution code:
import itertools

n=int(input())
# x1,y1,h1
test_data = [[int(i) for i in input().split()] for _ in range(n)] 

for cx, cy in itertools.product(range(100 + 1), range(100+1)):
    blnCorrect=True
    H=-1
    for coord in test_data:
        H_new = coord[2] + abs(coord[0] - cx) + abs(coord[1] - cy)
        if H_new < 1 and coord[2]==0:
            continue
        if  H > 0 and H != H_new:
            blnCorrect = False
            break
        H = H_new
    if blnCorrect:
        print(cx,cy,H)
        break

Submission status: Wrong Answer

Solution code:
import itertools

n=int(input())
# x1,y1,h1
test_data = [[int(i) for i in input().split()] for _ in range(n)] 

for cx, cy in itertools.product(range(100 + 1), range(100+1)):
    blnCorrect=True
    H=-1
    for coord in test_data:
        H_new = coord[2] + abs(coord[0] - cx) + abs(coord[1] - cy)
        if H_new < 1:
            blnCorrect = False
            break
        if  H > 0 and H != H_new:
            blnCorrect = False
            break
        H = H_new
    if blnCorrect:
        print(cx,cy,H)
        break

Submission status: Wrong Answer

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


#i,j = coordinate of x,y
for k in range(N):
    input_now = list(map(int, input().split()))
    input_list.append(input_now)

for i in range(101):
    Cx = i
    for j in range(101):
        Cy = j
        H_list = []
        for k in range(N):
            x,y,h = input_list[k][0],input_list[k][1],input_list[k][2]
            if h>0:
                H = h+abs(x-Cx)+abs(y-Cy)
                H_list.append(H)
        if max(H_list)==sum(H_list)/len(H_list):
            Ans_H = H
            Ans_x = Cx
            Ans_y = Cy
            if len(H_list)==1:
                continue
            else:
                break
            
    else:
        continue
    break
# The value of Cx,Cy,H is determined.
print(str(Ans_x)+" "+str(Ans_y)+" "+str(Ans_H))

Submission status: Wrong Answer

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


#i,j = coordinate of x,y
for k in range(N):
    input_now = list(map(int, input().split()))
    input_list.append(input_now)

for i in range(101):
    Cx = i
    for j in range(101):
        Cy = j
        H_list = []
        for k in range(N):
            x,y,h = input_list[k][0],input_list[k][1],input_list[k][2]
            if h>0:
                H = h+abs(x-Cx)+abs(y-Cy)
                H_list.append(H)
        if max(H_list)==sum(H_list)/len(H_list):
            Ans_H = H
            Ans_x = Cx
            Ans_y = Cy
            break
    else:
        continue
    break
# The value of Cx,Cy,H is determined.
print(str(Ans_x)+" "+str(Ans_y)+" "+str(Ans_H))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
ans = 0
for _ in range(n):
    s.append([int(i) for i in input().split()])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(n):
            x_, y_, h = s[i]
            t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            ttt = h + abs(x_ - x) + abs(y_ - y)
            ans = str(x) + " " + str(y) + " " + str(ttt)
            break
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
hogx=[]
hogy=[]
hogh=[]
for i in range(n):
  x,y,h=map(int,input().split())
  hogx.append(x)
  hogy.append(y)
  hogh.append(h)

for i in range(101):
  for j in range(101):
    flag=0
    huga=[]
    ans=hogh[-1]+max(abs(i-hogx[-1]),abs(j-hogy[-1]))
    for k in range(n-1):
      if(ans!=hogh[k]+max(abs(i-hogx[k]),abs(j-hogy[k]))):
        flag=1
    if(flag==0):
      print(i,j,ans)
      break

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []
for i in range(N):
    tmp = list(map(int, input().split()))
    if tmp[2] == 0:
        continue
    XYH.append(tmp)

def calc(XYH):
    xyh = XYH[0]
    for tarx in range(101):
        for tary in range(101):
            tarh = xyh[2] + abs(xyh[0] - tarx) + abs(xyh[1] - tary)
            if all(h==max(tarh - abs(tarx - x) - abs(tary - y), 0) for x, y, h in XYH):
                return list(map(str, [tarx, tary, tarh]))
    
print(" ".join(calc(XYH)))

Submission status: Wrong Answer

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

for cx in range(101):
  for cy in range(101):
    l = []
    for i in range(N):
      tmp = xyh[i][2] + abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy)
      l.append(tmp)
    if len(list(set(l))) == 1:
      #print("{0} {1} {2}".format(cx, cy, l[0]))
      f = True
      for i in range(N):
        if xyh[i][2] != max(l[0] - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0):
          f = False
      if f:
        print("{0} {1} {2}".format(cx, cy, l[0]))

Submission status: Wrong Answer

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

for cx in range(101):
  for cy in range(101):
    l = []
    for i in range(N):
      tmp = xyh[i][2] + abs(xyh[i][0] - cx) + abs(xyh[i][1] - cy)
      l.append(tmp)
    if len(list(set(l))) == 1:
      print("{0} {1} {2}".format(cx, cy, l[0]))

Submission status: Wrong Answer

Solution code:
def h_calc(cx, cy, xyh):
    return max(xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy), 0)

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

for cx in range(101):
    for cy in range(101):
        ch = -1
        set_h = set()

        for i in range(n):
            temp = h_calc(cx, cy, xyh[i])
            ch = temp if temp != 0 else ch
            set_h.add(ch)

        if len(set_h) == 1:
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

Solution code:
def h_calc(cx, cy, xyh):
    return max(xyh[2] + abs(xyh[0] - cx) + abs(xyh[1] - cy), 0)

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

for cx in range(101):
    for cy in range(101):
        ch = -1
        set_h = set()

        for i in range(n):
            ch = (h_calc(cx, cy, xyh[i]))
            set_h.add(ch)

        if len(set_h) == 1:
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

Solution code:
def h_calc(cx, cy, xyh):
    return xyh[2] + abs(xyh[0] - cx) + abs(xyh[1]- cy)

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

for cx in range(101):
    for cy in range(101):
        ch = -1
        set_h = set()

        for i in range(n):
            ch = (h_calc(cx, cy, xyh[i]))
            set_h.add(ch)

        if len(set_h) == 1:
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

Solution code:
def h_calc(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

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

for cx in range(101):
    for cy in range(101):
        ch = -1
        set_h = set()

        for i in range(n):
            ch = (h_calc(cx, cy, xyh[i]))
            set_h.add(ch)

        if len(set_h) == 1:
            print(cx, cy, ch)
            exit()

Submission status: Wrong Answer

Solution code:

N = int(input())

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

X.sort(key = lambda item: item[2] ,reverse = True)

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

        ok = True
        for k in range(N):
            if X[k][2] != h - abs(X[k][0] - i) - abs(X[k][1] - j):
                ok = False

        if ok:
            print(i, j, h)
            exit()

Submission status: Wrong Answer

Solution code:
import sys

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

for cx in range(101):
    for cy in range(101):
        cnt = 0
        for idx in range(0,N):
            if xyh[idx][2] == 0: continue
            if cnt == 0:
                H =xyh[idx][2] + abs(xyh[idx][0] - cx) + abs(xyh[idx][1] - cy)
                cnt += 1
                continue
            if H != xyh[idx][2] + abs(xyh[idx][0] - cx) + abs(xyh[idx][1] - cy):
                break
        else:
            print(cx,cy,H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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


for cx in range(101):
    for cy in range(101):
        H = max(0,xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy))
        for idx in range(1,N):
            if H != max(0,xyh[idx][2] + abs(xyh[idx][0] - cx) + abs(xyh[idx][1] - cy)):
                break
        else:
            print(cx,cy,H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 18 22:48:00 2019

@author: Yamazaki Kenichi
"""
import sys

N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
A.sort(key = lambda x:x[2], reverse = True)
ans = [-1,-1,1]
if A[0][2] == 10**9:
    print(' '.join(map(str,A[0])))
    sys.exit()
for i in range(101):
    for j in range(101):
        h = A[0][2] + abs(A[0][0]-i) + abs(A[0][1]-j)
        counta = 0
        for c in A:
#            print(i,j,h)
            if h == c[2] + abs(c[0]-i) + abs(c[1]-j) or c[2] == 0:
                counta += 1
            else:
                break
            if counta == N:
                if h > ans[2]:
                    ans = [i,j,h]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 18 22:48:00 2019

@author: Yamazaki Kenichi
"""

import sys

N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
A.sort(key = lambda x:x[2], reverse = True)
ans = [-1,-1,1]
for i in range(101):
    for j in range(101):
        h = A[0][2] + abs(A[0][0]-i) + abs(A[0][1]-j)
        counta = 0
        for c in A:
#            print(i,j,h)
            if h == c[2] + abs(c[0]-i) + abs(c[1]-j) or c[2] == 0:
                counta += 1
            else:
                break
            if counta == N:
                if h > ans[2]:
                    ans = [i,j,h]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 18 22:48:00 2019

@author: Yamazaki Kenichi
"""

import sys

N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
A.sort(key = lambda x:x[2], reverse = True)
ans = [-1,-1,1]
for i in range(101):
    for j in range(101):
        h = A[0][2] + abs(A[0][0]-i) + abs(A[0][1]-j)
        counta = 0
        for c in A:
#            print(i,j,h)
            if h != c[2] + abs(c[0]-i) + abs(c[1]-j):
                break
            else:
                counta += 1
            if counta == N:
                if h > ans[2]:
                    ans = [i,j,h]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 18 22:48:00 2019

@author: Yamazaki Kenichi
"""

import sys

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

ans = [-1,-1,1]
for i in range(101):
    for j in range(101):
        h = A[0][2] + abs(A[0][0]-i) + abs(A[0][1]-j)
        counta = 0
        for c in A:
#            print(i,j,h)
            if h != c[2] + abs(c[0]-i) + abs(c[1]-j):
                break
            else:
                counta += 1
            if counta == N:
                if h > ans[2]:
                    ans = [i,j,h]
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 18 22:48:00 2019

@author: Yamazaki Kenichi
"""

import sys

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

m = 1
for i in range(101):
    for j in range(101):
        h = A[0][2] + abs(A[0][0]-i) + abs(A[0][1]-j)
        counta = 0
        for c in A:
#            print(i,j,h)
            if h != c[2] + abs(c[0]-i) + abs(c[1]-j):
                break
            else:
                counta += 1
            if counta == N:
                m = max(m,h)
print(m)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 18 22:48:00 2019

@author: Yamazaki Kenichi
"""

import sys

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

m = 1
for i in range(101):
    for j in range(101):
        h = A[0][2] + abs(A[0][0]-i) + abs(A[0][1]-j)
        counta = 0
        for c in A:
#            print(i,j,h)
            if h != c[2] + abs(c[0]-i) + abs(c[1]-j):
                break
            else:
                counta += 1
            if counta == N:
                m = max(m,h)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 18 22:48:00 2019

@author: Yamazaki Kenichi
"""

import sys

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

for i in range(101):
    for j in range(101):
        h = A[0][2] + abs(A[0][0]-i) + abs(A[0][1]-j)
        counta = 0
        for c in A:
#            print(i,j,h)
            if h != c[2] + abs(c[0]-i) + abs(c[1]-j):
                break
            else:
                counta += 1
            if counta == N:
                print(i,j,h)
                sys.exit()

Submission status: Wrong Answer

Solution code:

def iabs(n):
    return n if n > 0 else -n

def main(ps):
    candidates = {}

    for x, y, h in ps:
        if h == 0:
            continue
        for Cx in range(0, 101):
            for Cy in range(0, 101):
                Hc =  h + iabs(x - Cx) + iabs(y - Cy)
                if Hc < h:
                    continue
                candidates[Cx, Cy] = Hc
        break
    for x, y, h in ps:
        cs = list(candidates.keys())
        for Cx, Cy in cs:
            Hc = max(h + iabs(x - Cx) + iabs(y - Cy), 0)
            if candidates[Cx, Cy] != Hc:
                del candidates[Cx, Cy]

    for (x, y), h in candidates.items():
        print(x, y, h)

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

main(ps)

Submission status: Wrong Answer

Solution code:

def iabs(n):
    return n if n > 0 else -n

def main(ps):
    candidates = {}

    x, y, h = ps[0]
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            Hc =  h + iabs(x - Cx) + iabs(y - Cy)
            if Hc < h:
                continue
            candidates[Cx, Cy] = Hc

    for x, y, h in ps[1:]:
        cs = list(candidates.keys())
        for Cx, Cy in cs:
            Hc = h + iabs(x - Cx) + iabs(y - Cy)
            if Hc < h:
                del candidates[Cx, Cy]
            elif candidates[Cx, Cy] != Hc:
                del candidates[Cx, Cy]
    for (x, y), h in candidates.items():
        print(x, y, h)

N = int(input())
ps = []
for _ in range(N):
    x, y, h = [int(x) for x in input().split()]
    if h > 0:
        ps.append((x, y, h))

main(ps)

Submission status: Wrong Answer

Solution code:
def iabs(n):
    return n if n > 0 else -n

def main(ps):
    candidates = {}

    x, y, h = ps[0]
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            Hc =  h + iabs(x - Cx) + iabs(y - Cy)
            if Hc < h:
                continue
            candidates[Cx, Cy] = Hc

    for x, y, h in ps[1:]:
        cs = list(candidates.keys())
        for Cx, Cy in cs:
            Hc = h + iabs(x - Cx) + iabs(y - Cy)
            if Hc < h:
                del candidates[Cx, Cy]
            elif candidates[Cx, Cy] != Hc:
                del candidates[Cx, Cy]
    for (x, y), h in candidates.items():
        print(x, y, h)

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

main(ps)

Submission status: Wrong Answer

Solution code:

def iabs(n):
    return n if n > 0 else -n

def main(ps):
    candidates = {}

    x, y, h = ps[0]
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            Hc =  h + iabs(x - Cx) + iabs(y - Cy)
            if Hc < h:
                continue
            candidates[Cx, Cy] = Hc

    for x, y, h in ps[1:]:
        cs = list(candidates.keys())
        for Cx, Cy in cs:
            Hc = h + iabs(x - Cx) + iabs(y - Cy)
            if Hc < h:
                del candidates[Cx, Cy]
            elif candidates[Cx, Cy] != Hc:
                del candidates[Cx, Cy]
        print(len(candidates))
    for (x, y), h in candidates.items():
        print(x, y, h)

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

main(ps)

Submission status: Wrong Answer

Solution code:

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

    for i in range(len(data_nokori)):
        high_nokori = high - abs(x - data_nokori[i][0]) - abs(y - data_nokori[i][1])
        if high_nokori < 0:
            return 0

    return high



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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
if n==1:
  print(p[0][0],p[0][1],p[0][2])
else:
  ans=[0,0,0]
  for i in range(0,101):
    for j in range(0,101):
      k=1
      l=p[0][2]+abs(i-p[0][0])+abs(j-p[0][1])
      for x,y,h in p:
        m=h+abs(i-x)+abs(j-y)
        if l!=m:
          k=0
      if k:
        ans=[i,j,l]
  print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

point = [[int(item) for item in input().split()] for _ in range(N)]
point.sort(key=lambda x:x[2], reverse=True)

ans = np.zeros((101,101))

for i,p in enumerate(point):
  if i == 0:
    for j in range(101):
      for k in range(101):
        H = p[2] + abs(j - p[0]) + abs(k - p[1])
        ans[j,k] = H
        print(ans[j,k])
  else:
    for j in range(101):
      for k in range(101):
        if not ans[j,k] == 0:
          if ans[j,k] != p[2] + abs(j - p[0]) + abs(k - p[1]):
            ans[j,k] = 0
  if len(ans[ans!=0]) <= 1:
    break
x,y = np.where(ans!=0)
print(x[0],y[0],int(ans[x[0],y[0]]))

Submission status: Wrong Answer

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

for i in p:
  if i[2] > 0:
    p1.append(i)    

for xi in range(101):
  for yi in range(101):
    judge = {i:False for i in range(len(p)-1)}
    for i in range(len(p1)-1):
      if p1[i][2] + abs(p1[i][0]-xi) + abs(p1[i][1]-yi) == p1[i+1][2] + abs(p1[i+1][0]-xi) + abs(p1[i+1][1]-yi):
        judge[i] = True
        if all(judge.values()):
          H = p1[i][2] + abs(p1[i][0]-xi) + abs(p1[i][1]-yi)
          print(xi,yi,H)
          exit()

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
data = []
for i in range(n):
    data.append([ int(i) for i in input().split() ])
for x in range(101):
    for y in range(101):
        h = set()
        for pt in data:
            xcx = abs(x-pt[0])
            ycy = abs(y-pt[1])
            if pt[2] > 0:
                h.add(pt[2] + xcx + ycy )
        if len(h) == 1:
            found = True
            print(x,y,end=" ")
            for i in h:
                print(i)
            sys.exit(0)
        elif len(h) == 0:
            print(x,y,1)
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
data = []
for i in range(n):
    data.append([ int(i) for i in input().split() ])
for x in range(101):
    for y in range(101):
        h = set()
        for pt in data:
            xcx = abs(x-pt[0])
            ycy = abs(y-pt[1])
            if pt[2] > 0:
                h.add(pt[2] + xcx + ycy )
        if len(h) == 1:
            found = True
            print(x,y,end=" ")
            for i in h:
                print(i)
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
N = int(input())
Z = [[int(i) for i in input().split()] for i in range(N)]

count = 0
xt = Z[0][0]
yt = Z[0][1]
ht = Z[0][2]

for px in range(101):
    for py in range(101):
        H = abs(px - xt) + abs(py - yt) + ht
        for z in Z[1:]:
            if max(H - abs(z[0]-px) - abs(z[1]-py), 0) == z[2]:
                count += 1
                if count == len(Z) - 1:
                    print(px, py, H)
        count = 0

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
N = int(input())
Z = [[int(i) for i in input().split()] for i in range(N)]
D = []
count = 0
xt = Z[0][0]
yt = Z[0][1]
ht = Z[0][2]
for px in range(101):
    for py in range(101):
        H = abs(px - xt) + abs(py - yt) + ht
        for z in Z[1:]:
            if (H - abs(z[0]-px) - abs(z[1]-py)) == z[2]:
                count += 1
                if count == len(Z) - 1:
                    print(px, py, H)
        count = 0

Submission status: Wrong Answer

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

for cx in range(100 + 1):
    for cy in range(100 + 1):
        # すべての中心候補に対して
        H = -1
        for x, y, h in xyh:
            if h > 0:
                # h > 0の場合は、中心からの距離と高さに関係がある
                t = h + abs(x - cx) + abs(y - cy)
                if H == -1:
                    H = t
                else:
                    if H != t:
                        # 適切な中心を選んでいるときは、すべてのHが一致する
                        break
        else:
            if H >= 1:
                print(cx, cy, H)
                exit()

Submission status: Wrong Answer

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

for cx in range(100 + 1):
    for cy in range(100 + 1):
        # すべての中心候補に対して
        H = -1
        for x, y, h in xyh:
            if h > 0:
                # h > 0の場合は、中心からの距離と高さに関係がある
                t = h + abs(x - cx) + abs(y - cy)
                if H == -1:
                    H = t
                else:
                    if H != t:
                        # 適切な中心を選んでいるときは、すべてのHが一致する
                        break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyhs = [list(map(int, input().split())) for _ in range(n)]
ans_cx = 0
ans_cy = 0
ans_h = 0

if n == 1:
    ans_cx, ans_cy, ans_h = xyhs[0]
elif all([xyh[2] == 0 for xyh in xyhs]):
    ans_cx = 0
    ans_cy = 0
    for x, y, h in xyhs:
        ans_cx += x
        ans_cy += y
    ans_cx //= n
    ans_cy //= n
    ans_h = abs(xyhs[0][0] - ans_cx) + abs(xyhs[0][1] - ans_cy)
else:
    for cx in range(101):
        for cy in range(101):
            h_set = set([h + abs(x - cx) + abs(y - cy) for x, y, h in xyhs if h != 0])
            if len(h_set) == 1:
                ans_cx = cx
                ans_cy = cy
                ans_h = list(h_set)[0]

print(ans_cx, ans_cy, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyhs = [list(map(int, input().split())) for _ in range(n)]
ans_cx = 0
ans_cy = 0
ans_h = 0

if all([xyh[2] == 0 for xyh in xyhs]):
    ans_cx = 0
    ans_cy = 0
    for x, y, h in xyhs:
        ans_cx += x
        ans_cy += y
    ans_cx //= n
    ans_cy //= n
    ans_h = abs(xyhs[0][0] - ans_cx) + abs(xyhs[0][1] - ans_cy)
else:
    for cx in range(101):
        for cy in range(101):
            h_set = set([h + abs(x - cx) + abs(y - cy) for x, y, h in xyhs if h != 0])
            if len(h_set) == 1:
                ans_cx = cx
                ans_cy = cy
                ans_h = list(h_set)[0]

print(ans_cx, ans_cy, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyhs = [list(map(int, input().split())) for _ in range(n)]
ans_cx = 0
ans_cy = 0
ans_h = 0

if all([xyh[2] == 0 for xyh in xyhs]):
    ans_cx = 0
    ans_cy = 0
    for x, y, h in xyhs:
        ans_cx += x
        ans_cy += y
    ans_cx //= n
    ans_cy //= n
    ans_h = abs(xyhs[0][0] - ans_cx) + abs(xyhs[0][1] - ans_cy)
else:
    for cx in range(101):
        for cy in range(101):
            ok = True
            expect_h = 0
            for x, y, h in xyhs:
                if h == 0:
                    continue
                else:
                    h_ = h + abs(x - cx) + abs(y - cy)
                    if expect_h == 0:
                        expect_h = h_
                    elif expect_h != h_:
                        ok = False
            if ok:
                ans_cx = cx
                ans_cy = cy
                ans_h = expect_h

print(ans_cx, ans_cy, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyhs = [list(map(int, input().split())) for _ in range(n)]
ans_cx = 0
ans_cy = 0
ans_h = 0
for cx in range(101):
    for cy in range(101):
        ok = True
        expect_h = 0
        for x, y, h in xyhs:
            if h == 0:
                continue
            else:
                h_ = h + abs(x - cx) + abs(y - cy)
                if expect_h == 0:
                    expect_h = h_
                elif expect_h != h_:
                    ok = False
        if ok:
            ans_cx = cx
            ans_cy = cy
            ans_h = expect_h

if ans_h == 0:
    ans_cx = 0
    ans_cy = 0
    for x, y, h in xyhs:
        ans_cx += x
        ans_cy += y
    ans_cx //= n
    ans_cy //= n
    ans_h = abs(xyhs[0][0] - ans_cx) + abs(xyhs[0][1] - ans_cy)

print(ans_cx, ans_cy, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyhs = [list(map(int, input().split())) for _ in range(n)]
ans_cx = 0
ans_cy = 0
ans_h = 0
for cx in range(101):
    for cy in range(101):
        ok = True
        expect_h = 0
        for x, y, h in xyhs:
            if h == 0:
                continue
            else:
                h_ = h + abs(x - cx) + abs(y - cy)
                if expect_h == -1:
                    expect_h = h_
                elif expect_h != h_:
                    ok = False
        if ok:
            ans_cx = cx
            ans_cy = cy
            ans_h = expect_h

if ans_h == 0:
    ans_cx = 0
    ans_cy = 0
    for x, y, h in xyhs:
        ans_cx += x
        ans_cy += y
    ans_cx //= n
    ans_cy //= n
    ans_h = abs(xyhs[0][0] - ans_cx) + abs(xyhs[0][1] - ans_cy)

print(ans_cx, ans_cy, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyhs = [list(map(int, input().split())) for _ in range(n)]
ans_cx = -1
ans_cy = -1
ans_h = -1
for cx in range(101):
    for cy in range(101):
        ok = True
        expect_h = -1
        for x, y, h in xyhs:
            if h == 0:
                continue
            else:
                h_ = h + abs(x - cx) + abs(y - cy)
                if expect_h == -1:
                    expect_h = h_
                elif expect_h != h_:
                    ok = False
        if ok:
            ans_cx = cx
            ans_cy = cy
            ans_h = expect_h
print(ans_cx, ans_cy, ans_h)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = []
ind = 0
for _ in range(N):
    x, y, h = map(int, input().split())
    xyh.append([x, y, h])
    if h > 0:
        ind = len(xyh) - 1

ansX = 0
ansY = 0
ansH = 0
for cx in range(0, 101):
    for cy in range(0, 101):
        H = xyh[ind][2] + abs(xyh[ind][0] - cx) + abs(xyh[ind][1] - cy)
        for x, y, h in xyh:
            if h == 0 and H > abs(x - cx) + abs(y - cy):
                H = -1
                break
            if H != h + abs(x - cx) + abs(y - cy):
                H = -1
                break
        if H > 0:
            ansH = H
            ansX = cx
            ansY = cy
            break
    if ansH > 0:
        break

print(ansX, ansY, ansH)