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())
x = []
y = []
h = []
sample = -1
reg = -1
reg2 = 1
for i in range(N):
    XYH = list(map(int, input().split()))
    x.append(XYH[0])
    y.append(XYH[1])
    h.append(XYH[2])

for i in range(0, 101):
    for j in range(0, 101):
        sample = -1
        reg = -1
        reg2 = 1
        for k in range(N):
            if sample == -1 and h[k] > 0:
                reg = k
                sample = h[k] + abs(x[k] - i) + abs(y[k] - j)
            elif sample != -1 and h[k] > 0:
                if h[k] + abs(x[k] - i) + abs(y[k] - j) != sample:
                    reg2 = -1
            elif sample != -1 and h[k] == 0:
                if sample - abs(x[k] - i) - abs(y[k] - j) > 0:
                    reg2 = -1
            if reg != 0 and k == N - 1:
                for l in range(k):
                    if sample - abs(x[l] - i) - abs(y[l] - j) > 0:
                        reg2 = -1
                if reg2 == 1:
                    print(i, " ", j, " ", sample)
            if reg == 0 and k == N - 1:
                if reg2 == 1:
                    print(i, " ", j, " ", sample)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = []
for i in range(N):
  D.append(list(map(int, input().split())))
D.sort(key = lambda x:x[2], reverse = True)
for i in range(101):
  for j in range(101):
    F = True
    H = abs(i - D[0][0]) + abs(j-D[0][1]) + D[0][2]
    for k in range(1,N):
      if D[k][2] != 0:
        if H != abs(i - D[k][0]) + abs(j-D[k][1]) + D[k][2]:
          F = False
          break
      else:
        if H < abs(i - D[k][0]) + abs(j-D[k][1]) + D[k][2]:
          F = False
          break
    if F == True:
      print(str(i) + " " + str(j) + " " + str(H))

Submission status: Wrong Answer

Solution code:
N = int(input())
xs = []
ys = []
hs = []
for i in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

for cx in range(100 + 1):
    for cy in range(100 + 1):
        flg = True
        for i in range(N):
            H = hs[i] + abs(xs[i] - cx)  + abs(ys[i] - cy)
            if H != 0:
                break
        if H == 0:
            break
        for i in range(N):
            h_ = max(H - abs(xs[i] - cx) - abs(ys[i] - cy), 0)
            if hs[i] != h_:
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx, cy, H))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xs = []
ys = []
hs = []
for i in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

for cx in range(100 + 1):
    for cy in range(100 + 1):
        flg = True
        for i in range(N):
            H = hs[i] + abs(xs[i] - cx)  + abs(ys[i] - cy)
            if H != 0:
                break
        for i in range(N):
            h_ = max(H - abs(xs[i] - cx) - abs(ys[i] - cy), 0)
            if hs[i] != h_:
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx, cy, H))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xs = []
ys = []
hs = []
for i in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

for cx in range(100 + 1):
    for cy in range(100 + 1):
        flg = True
        H = hs[0] + abs(xs[0] - cx)  + abs(ys[0] - cy)
        if H == 0:
            H = hs[1] + abs(xs[1] - cx)  + abs(ys[1] - cy)
        for i in range(N):
            h_ = max(H - abs(xs[i] - cx) - abs(ys[i] - cy), 0)
            if hs[i] != h_:
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx, cy, H))
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xs = []
ys = []
hs = []
for i in range(N):
    x, y, h = map(int, input().split())
    xs.append(x)
    ys.append(y)
    hs.append(h)

for cx in range(100 + 1):
    for cy in range(100 + 1):
        flg = True
        H = hs[0] + abs(xs[0] - cx)  + abs(ys[0] - cy)
        for i in range(1, N):
            h_ = max(H - abs(xs[i] - cx) - abs(ys[i] - cy), 0)
            if hs[i] != h_:
                flg = False
                break
        if flg:
            print("{0} {1} {2}".format(cx, cy, H))
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
for c_x in range(101):
    for c_y in range(101):
        valid = True
        H = None
        for i in range(n):
            x, y, h = data[i]
            if H is None and h == 0:
                continue
            else:
                if H is None:
                    H = h + abs(x-c_x) + abs(y-c_y)
                else:
                    if h != max(H - abs(x-c_x) - abs(y-c_y), 0):
                        valid = False
                        break
        if valid and H >= 1:
            print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
for c_x in range(101):
    for c_y in range(101):
        valid = True
        H = None
        for i in range(n):
            x, y, h = data[i]
            if H is None and h == 0:
                continue
            else:
                if H is None:
                    H = h + abs(x-c_x) + abs(y-c_y)
                else:
                    if h != max(H - abs(x-c_x) - abs(y-c_y), 0):
                        valid = False
                        break
        if valid:
            print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
for c_x in range(101):
    for c_y in range(101):
        valid = True
        H = None
        for i in range(n):
            x, y, h = data[i]
            if h == 0:
                continue
            else:
                if H is None:
                    H = h + abs(x-c_x) + abs(y-c_y)
                else:
                    if h != H - abs(x-c_x) - abs(y-c_y):
                        valid = False
                        break
        if valid:
            print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
for i in range(n):
    x, y, h = map(int, input().split())
    points.append((h, x, y))
points.sort(reverse=True)

for i in range(101):
    for j in range(101):
        ph, px, py = points[0]
        hp = ph + abs(i - px) + abs(j - py)
        if all([hp == ph + abs(i - px) + abs(j - py) for ph, px, py in points]):
            print(i, j, hp)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
points = []
for i in range(n):
    x, y, h = map(int, input().split())
    points.append((h, x, y))
points.sort(reverse=True)

for i in range(101):
    for j in range(101):
        ph, px, py = points[0]
        hp = ph + abs(i - px) + abs(j - py)
        if all([hp == ph + abs(i - px) + abs(j - py) for ph, px, py in points]):
            print(i, j, hp)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
point = [[int(i) for i in input().split()] for _ in range(N)]
for x in range(101):
    for y in range(101):
        h = point[0][2]+abs(x-point[0][0])+abs(y-point[0][1])
        OK = True
        for i in range(N):
            if not point[i][2]==max(h-abs(x-point[i][0])-abs(y-point[i][1]),0):
                OK = False
                break
        if OK:
            print(x,y,h)
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
point = [[int(i) for i in input().split()] for _ in range(N)]
for x in range(101):
    for y in range(101):
        if point[0][2]==0:
            continue
        h = point[0][2]+abs(x-point[0][0])+abs(y-point[0][1])
        OK = True
        for i in range(N):
            if not point[i][2]==max(h-abs(x-point[i][0])-abs(y-point[i][1]),0):
                OK = False
                break
        if OK:
            print(x,y,h)

Submission status: Wrong Answer

Solution code:
from math import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            result = H - abs(cx - input_list[0]) -  abs(cy - input_list[1])
            if (result < 0) or (input_list[2] != result):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
from math import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            if (input_list[2] != (H - abs(cx - input_list[0]) - abs(cy - input_list[1]))):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            sys.exit(0)

Submission status: Wrong Answer

Solution code:
from math import *

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x_y_h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    flag = 1
    for cy in range(101):
        H = x_y_h[2] + abs(cx - x_y_h[0]) + abs(cy - x_y_h[1])
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                flag = 0
                break
        if (flag == 1):
            print("%s %s %s" % (cx, cy, H))
            break
    if (flag == 1):
        break

Submission status: Wrong Answer

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

arr.sort(key=lambda x:x[2], reverse=True)

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
			if (arr[nn][2] > 0) or (arr[nn][2]==0 and arr[0][2] - abs(arr[0][0] - arr[nn][0]) + abs(arr[0][1] - arr[nn][1])==0):
				if tmp == -1:
					tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])
				else:
					if tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1]):
						continue
					else:
						flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

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

arr.sort(key=lambda x:x[2], reverse=True)

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
			if (arr[nn][2] > 0) or ((arr[nn][2]==0) and (arr[0][2] - abs(arr[0][0] - arr[nn][0]) + abs(arr[0][1] - arr[nn][1])==0)):
				if tmp == -1:
					tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])
				else:
					if tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1]):
						continue
					else:
						flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

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

arr.sort(key=lambda x:x[2], reverse=True)

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
			if (arr[nn][2] > 0) or ((arr[nn][2]==2) and (arr[0][2] - abs(arr[0][0] - arr[nn][0]) + abs(arr[0][1] - arr[nn][1])==0)):
				if tmp == -1:
					tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])
				else:
					if tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1]):
						continue
					else:
						flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

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

arr.sort(key=lambda x:x[2], reverse=True)

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
			if (arr[nn][2] > 0) or (arr[0][2] - abs(arr[0][0] - arr[nn][0]) + abs(arr[0][1] - arr[nn][1])==0):
				if tmp == -1:
					tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])
				else:
					if tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1]):
						continue
					else:
						flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

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

arr.sort(key=lambda x:x[2], reverse=True)

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
				if tmp == -1:
					tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])
				else:
					if (tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])) or (arr[nn][2] == 0):
						continue
					else:
						flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

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

arr.sort(key=lambda x:x[2])

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
				if tmp == -1:
					tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])
				else:
					if tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1]) or arr[nn][2] == 0:
						continue
					else:
						flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

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

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
			if arr[nn][2] > 0:
				if tmp == -1:
					tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])
				else:
					if tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1]):
						continue
					else:
						flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

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

for xx in range(0,101):
	for yy in range(0,101):
		tmp = -1
		flg = 0
		for nn in range(n):
			if tmp == -1:
				tmp = arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1])			
			else:
				if tmp == arr[nn][2] + abs(xx - arr[nn][0]) + abs(yy - arr[nn][1]):
					continue		
				else:
					flg = -1
		if flg == 0:
			print('{} {} {}'.format(xx,yy,tmp))

Submission status: Wrong Answer

Solution code:
N = int(input())

pair = [ list(map(int, input().split())) for i in range(N) ]
pair = sorted(pair, key=lambda x: x[2], reverse=True)

for cx in range(0, 101):
    for cy in range(0, 101):
        H = pair[0][2] + abs( cx - pair[0][0] ) + abs( cy - pair[0][1] )
        for n in range(1, N):
            Hn = pair[n][2] + abs( cx - pair[n][0] ) + abs( cy - pair[n][1] )
            if H != Hn: break
        else:
            print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())

pair = [ list(map(int, input().split())) for i in range(N) ]
pair = sorted(pair, key=lambda x: x[2], reverse=True)

flag = 0
for cx in range(0, 101):
    if flag == 1: break
    for cy in range(0, 101):
        if flag == 1: break
        H = pair[0][2] + abs( cx - pair[0][0] ) + abs( cy - pair[0][1] )
        for n in range(1, N):
            Hn = pair[n][2] + abs( cx - pair[n][0] ) + abs( cy - pair[n][1] )
            if H != Hn: break
        else:
            print(cx, cy, H)
            flag = 1

Submission status: Wrong Answer

Solution code:
n = int(input())

w = [(list(map(int, input().split()))) for i in range(n)]#x,y,h

hcon1 = 0
hcon2 = 0
for cx in range(101):
    for cy in range(101):
        for i in range(n):
            if w[i][2] > 0:
                if i == 0:
                    hcon1 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                elif i != 0 and i != n - 1:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        hcon1 = hcon2
                else:
                    hcon2 = abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]
                    if hcon1 != hcon2:
                        break
                    else:
                        print(cx,cy,hcon1)
                        exit()
            else:
                if i == 0:
                    hcon = 1
                elif i != 0 and i != n - 1:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                else:
                    if hcon1 > abs(w[i][0] - cx) + abs(w[i][1] - cy) + w[i][2]:
                        break
                    else:
                        print(cx, cy, hcon1)
                        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
x,y,h = [0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i] = map(int,input().split())
for a in range(101):
  for b in range(101):
    p = -1
    q = 1000000000
    f = 0
    for i in range(n):
      t = h[i] + abs(x[i]-a) + abs(y[i]-b)
      if h[i]>0:
        if p == -1:
          p = t
        elif not p == t:
          f = 1
          break         
      else:
        q = min(q,t)
    if f == 0 and p<=q:
      print(a,b,p)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

for cx in range(101):
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        flag=True
        for i in range(n):
            h_est=abs(data[i][0]-cx)+abs(data[i][1]-cy)+data[i][2]
            if(data[i][2]!=0):
                if(h!=h_est):
                    falg=False
                    break
            else:
                if(h<h_est):
                    flag=False
                    break
        if(flag):
            print(cx,cy,h)
            break

Submission status: Wrong Answer

Solution code:

n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

for cx in range(101):
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        i=0
        while(True):
            if(data[i][2]!=0):
                h_est=abs(data[i][0]-cx)+abs(data[i][1]-cy)+data[i][2]
                if(h!=h_est):
                    break
            else:
                if(h<h_est):
                    break
            if(i==n-1):
                print(cx,cy,h)
                break
            i+=1

Submission status: Wrong Answer

Solution code:
n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

for cx in range(101):
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        i=0
        while(True):
            if(data[i][2]!=0):
                if(h!=abs(data[i][0]-cx)+abs(data[i][1]-cy)+data[i][2]):
                    break
            if(i==n-1):
                print(cx,cy,h)
                break
            i+=1

Submission status: Wrong Answer

Solution code:

n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

data.sort(key=lambda x:x[2])
data.reverse()

for cx in range(101):
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        for i in range(n):
            if(data[i][2]!=0):
                if(h!=abs(data[i][0]-cx)+abs(data[i][1]-cy)+data[i][2]):
                    break
            if(i==n-1):
                print(cx,cy,h)

Submission status: Wrong Answer

Solution code:

n=int(input())
data=[] # data[[x1,y1,h1],...,[xn,yn,hn]]
for i in range(n):
    (xi,yi,hi)=map(int, input().split())
    data.append([xi,yi,hi])

for cx in range(101):
    for cy in range(101):
        h=abs(data[0][0]-cx)+abs(data[0][1]-cy)+data[0][2]
        for i in range(n):
            if(h!=abs(data[i][0]-cx)+abs(data[i][1]-cy)+data[i][2]):
                break
            if(i==n-1):
                print(cx,cy,h)

Submission status: Wrong Answer

Solution code:
import sys

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

xyh.sort(key=lambda x:x[2])

        
if N==1:
    print(xyh[0][0], xyh[0][1] , xyh[0][2])
else:
    for xc in range(101):
        for yc in range(101):
            H = xyh[0][2] + abs(xyh[0][0] - xc) + abs(xyh[0][1] - yc)
            for xi, yi, hi in xyh:
                if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0):
                    break
            else:
                print(xc, yc, H)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

xyh.sort(key=lambda x:x[2])

        
if N==1:
    print(xyh[0][0], xyh[0][1] , xyh[0][2])
else:
    for xc in range(101):
        for yc in range(101):
            H = xyh[0][2] + abs(xyh[0][0] - xc) + abs(xyh[0][1] - yc)
            for xi, yi, hi in xyh:
                if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0) or H != hi + abs(xi - xc) + abs(yi - yc):
                    break
            else:
                print(xc, yc, H)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

if N==1:
    print(xyh[0][0], xyh[0][1] , xyh[0][2])
else:
    for xc in range(101):
        for yc in range(101):
            H = xyh[0][2] + abs(xc - xyh[0][0]) + abs(yc - xyh[0][1])
        
            if H <= 0:
                break
            else:
                for xi, yi, hi in xyh:
                    if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0) or H != hi + abs(xi - xc) + abs(yi - yc):
                        break
                else:
                    print(xc, yc, H)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

if N==1:
    print(xyh[0][0], xyh[0][1] , xyh[0][2])
else:
    for xc in range(101):
        for yc in range(101):
            H = xyh[0][2] + abs(xc - xyh[0][0]) + abs(yc - xyh[0][1])
        
            if H == 0:
                break
            else:
                for xi, yi, hi in xyh:
                    if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0):
                        break
                else:
                    print(xc, yc, H)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

if N==1:
    print(xyh[0], xyh[1], xyh[2])
else:
    for xc in range(101):
        for yc in range(101):
            H = xyh[0][2] + abs(xc - xyh[0][0]) + abs(yc - xyh[0][1])
        
            if H == 0:
                break
            else:
                for xi, yi, hi in xyh:
                    if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0):
                        break
                else:
                    print(xc, yc, H)
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

for xc in range(101):
    for yc in range(101):
        H = xyh[0][2] + abs(xc - xyh[0][0]) + abs(yc - xyh[0][1])
        
        if H == 0:
            break
        else:
            for xi, yi, hi in xyh:
                if hi !=  max(H - abs(xi - xc) - abs(yi - yc), 0):
                    break
            else:
                print(xc, yc, H)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

for xc in range(101):
    for yc in range(101):
        H = xyh[0][2] + abs(xc - xyh[0][0]) + abs(yc - xyh[0][1])
        
        if H == 0:
            break
        else:
            for xi, yi, hi in xyh:
                if H != hi + abs(xc - xi) + abs(yc - yi):
                    break
            else:
                print(xc, yc, H)
                sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):
        f_i = 0
        for i in range(N):
            if h[i] != 0:
                f_i = i
        preH = h[f_i] + abs(x[f_i]-cx) + abs(y[f_i]-cy)
        for i in range(N):
            if i < N-1 and h[i] == 0:
                continue
            H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
            if H != preH:
                break
            if i == N-1:
                if H == 0:
                    break
                print(cx, cy, H)
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):
        f_i = 0
        for i in range(N):
            if h[i] != 0:
                f_i = i
        preH = h[f_i] + abs(x[f_i]-cx) + abs(y[f_i]-cy)
        for i in range(N):
            if h[i] == 0:
                continue
            H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
            if H != preH:
                break
            if i == N-1:
                if H == 0:
                    break
                print(cx, cy, H)
    else:
        continue
    break

Submission status: Wrong Answer

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

for i in range(N):
    p_infos.append([int(s) for s in input().split()])

is_finished = False
for c_x in range(101):
    if is_finished: break
    for c_y in range(101):
        if is_finished: break
        c_h = -1 # impossible value
        for p in p_infos:
            x, y, h = p[0], p[1], p[2] 
            x_d, y_d = abs(x - c_x), abs(y - c_y)
            if h > 0:
                if c_h == -1:
                    c_h = h + x_d + y_d
                elif c_h != h + x_d + y_d:  
                    break
            elif h - x_d - y_d > 0:
                break

            if p == p_infos[-1]:
                print(c_x, c_y, c_h)
                is_finished = True

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):
        preH = h[0] + abs(x[0]-cx) + abs(y[0]-cy)
        for i in range(N):
            H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
            if H != preH:
                break
            if i == N-1:
                if H == 0:
                    break
                print(cx, cy, H)
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(0, 101):
    for cy in range(0, 101):
        preH = h[0] + abs(x[0]-cx) + abs(y[0]-cy)
        for i in range(N):
            H = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
            if H != preH:
                break
            if i == N-1:
                print(cx, cy, H)
    else:
        continue
    break

Submission status: Wrong Answer

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

def reheight(center, point):
    if point[2] == 0:
        return 0
    else:
        return (point[2] + abs(center[0] - point[0]) + abs(center[1] - point[1]))

def height(center, high, point):
    return max(high - abs(center[0] - point[0]) - abs(center[1] - point[1]), 0)

for i in range(101):
    for j in range(101):
        k_ = 0
        center = [i, j]
        while (reheight(center, hints[k_]) == 0):
            k_ += 1
        hmax = reheight(center, hints[k_])
        k = 0
        while (k < n and ((hints[k])[2] == height(center, hmax, (hints[k])[:2]) or 0 == height(center, hmax, (hints[k])[:2]))):
            k += 1
        if k == n:
            break
    if k == n:
        break
        
print("{} {} {}".format(center[0], center[1], hmax))

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
x = np.empty(N,dtype=np.int)
y = np.empty(N,dtype=np.int)
h = np.empty(N,dtype=np.int)
for n in range(N):
    (x[n],y[n],h[n]) = map(int,input().split())

M = 100

grads = np.array([[1,1],[-1,1],[-1,-1],[1,-1]],dtype=np.int)
def height(x,y,h,i,j,d):
    # d=0-3
    return (h + grads[d,0]*(i-x) + grads[d,1]*(j-y))

def quadrant(x,y):
    if x > 0 and y >= 0:
        return 0
    elif y > 0:
        return 1
    elif x < 0:
        return 2
    else:
        return 3

for (i,j) in [(i,j) for j in range(M+1) for i in range(M+1)]:
    H = height(x[0],y[0],h[0],i,j,quadrant(i-x[0],j-y[0]))
    for n in range(1,N):
        if height(x[n],y[n],h[n],i,j,quadrant(i-x[n],j-y[n])) != H:
            break
    else:
        break

print(i,j,H)