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())
 
hints = []
for i in range(n):
    x, y, h = map(int, input().split())
    hints.append([x, y, h])

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

for i in range(101):
    for j in range(101):
        cent = [i, j]
        hmax = height(cent, hints[0])
        k = 1
        while ((k < n) and (hmax == height(cent, hints[k]) or height(cent, hints[k]) == 0 or hmax == 0)):
            if (hmax == 0 and height(cent, hints[k]) != 0):
                hmax = height(cent, hints[k])
            k += 1
        #print(cent)
        #print(k)
        #print (hmax)
        if k == n:
            break
        else:
            continue
    if k == n:
        break
print("{} {} {}".format(cent[0], cent[1], hmax))

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 height(center , point):
    if point[2] < 0:
        return 0
    else:
        return point[2] + abs(point[0] - center[0]) + abs(point[1] - center[1])

for i in range(101):
    for j in range(101):
        cent = [i, j]
        hmax = height(cent, hints[0])
        k = 1
        while ((k < n) and (hmax == height(cent, hints[k]) or height(cent, hints[k]) == 0 or hmax == 0)):
            if (hmax == 0 and height(cent, hints[k]) != 0):
                hmax = height(cent, hints[k])
            k += 1
        #print(cent)
        #print(k)
        #print (hmax)
        if k == n:
            break
        else:
            continue
    if k == n:
        break
    
print("{} {} {}".format(cent[0], cent[1], hmax))

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 height(center , point):
    if point[2] == 0:
        return 0
    else:
        return point[2] + abs(point[0] - center[0]) + abs(point[1] - center[1])

for i in range(101):
    for j in range(101):
        cent = [i, j]
        hmax = height(cent, hints[0])
        k = 1
        while ((k < n) and (hmax == height(cent, hints[k]) or height(cent, hints[k]) == 0 or hmax == 0)):
            if (hmax == 0 and height(cent, hints[k]) != 0):
                hmax = height(cent, hints[k])
            k += 1
        #print(cent)
        #print(k)
        #print (hmax)
        if k == n:
            break
        else:
            continue
    if k == n:
        break

print("{} {} {}".format(cent[0], cent[1], hmax))

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 height(center , point):
    if point[2] == 0:
        return 0
    else:
        return point[2] + abs(point[0] - center[0]) + abs(point[1] - center[1])

for i in range(101):
    for j in range(101):
        cent = [i, j]
        hmax = height(cent, hints[0])
        k = 1
        while ((k < n) and (hmax == height(cent, hints[k]) or height(cent, hints[k]) == 0)):
            if (hmax == 0 and height(cent, hints[k]) != 0):
                hmax = height(cent, hints[k])
            k += 1
        #print(cent)
        #print(k)
        #print (hmax)
        if k == n:
            break
        else:
            continue
    if k == n:
        break

print("{} {} {}".format(cent[0], cent[1], hmax))

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []
x_t, y_t, h_t = 0, 0, 0
for i in range(N):
    x_i, y_i, h_i = map(int, input().split())
    x.append(x_i)
    y.append(y_i)
    h.append(h_i)
    if h_i > 0 and h_t == 0:
        x_t = x_i
        y_t = y_i
        h_t = h_i

for i in range(101):
    for j in range(101):
        px = i
        py = j
        ph = max(h_t + abs(px - x_t) + abs(py - y_t), 0)
        flag = True
        for k in range(N):
            if max(h[k] + abs(px - x[k]) + abs(py - y[k]), 0) != ph:
                flag = False
                break
        if flag:
            print(px, py, ph)
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []
x_t, y_t, h_t = 0, 0, 0
for i in range(N):
    x_i, y_i, h_i = map(int, input().split())
    x.append(x_i)
    y.append(y_i)
    h.append(h_i)
    if h_i > 0 and h_t == 0:
        x_t = x_i
        y_t = y_i
        h_t = h_i

for i in range(101):
    for j in range(101):
        px = i
        py = j
        ph = max(h_t + abs(px - x_t) + abs(py - y_t), 0)
        flag = True
        for k in range(1, N):
            if max(h[k] + abs(px - x[k]) + abs(py - y[k]), 0) != ph:
                flag = False
                break
        if flag:
            print(px, py, ph)
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_i, y_i, h_i = map(int, input().split())
    x.append(x_i)
    y.append(y_i)
    h.append(h_i)

for i in range(101):
    for j in range(101):
        px = i
        py = j
        ph = max(h[0] + abs(px - x[0]) + abs(py - y[0]), 0)
        flag = True
        for k in range(1, N):
            if max(h[k] + abs(px - x[k]) + abs(py - y[k]), 0) != ph:
                flag = False
                break
        if flag:
            print(px, py, ph)
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_i, y_i, h_i = map(int, input().split())
    x.append(x_i)
    y.append(y_i)
    h.append(h_i)

for i in range(101):
    for j in range(101):
        px = i
        py = j
        ph = h[0] + abs(px - x[0]) + abs(py - y[0])
        flag = True
        for k in range(1, N):
            if h[k] + abs(px - x[k]) + abs(py - y[k]) != ph:
                flag = False
                break
        if flag:
            print(px, py, ph)
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
y = []
h = []
for i in range(N):
    x_i, y_i, h_i = map(int, input().split())
    x.append(x_i)
    y.append(y_i)
    h.append(h_i)

for i in range(101):
    for j in range(101):
        px = i
        py = j
        ph = h[0] + abs(px - x[0]) + abs(py - y[0])
        flag = 0
        for k in range(1, N):
            if h[k] + abs(px - x[k]) + abs(py - y[k]) != ph:
                flag = 1
                break
        if flag == 0:
            print(px, py, ph)
            break

Submission status: Wrong Answer

Solution code:
import sys

zero_list=[]
flag=0
i=0
x=[]
y=[]
h=[]
n=int(input())
for i in range(n):
    a,b,c=list(map(int,input().split()))
    x.append(a)
    y.append(b)
    h.append(c)

for cx in range(101):
    for cy in range(101):
        point=0
        for i in range(n):
            if(h[i]==0):
                zero_list.append(i)
                flag=1
            else:
                H=h[i]+abs(cx-x[i])+abs(cy-y[i])
                break
        for i in range(n):
            if(flag):
                if(zero_list[point]==i):
                    if(H-abs(cx-x[i])-abs(cy-y[i])>0):
                        break
                    point+=1
            else:
                if(H!=h[i]+abs(cx-x[i])+abs(cy-y[i])):
                    break
        else:
            print("{} {} {}".format(cx,cy,H))
            sys.exit(0)

Submission status: Wrong Answer

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

cx_kouho = 0
cy_kouho = 0
h_kouho = 0
H_kakutei = 1
Cx_kakutei = 0
Cy_kakutei = 0

for i in range(101):
	for j in range(101):
		cx_kouho = i
		cy_kouho = j
		cnt = 0

		H_kakutei = data[0][2] + abs(data[0][0]-cx_kouho)+abs(data[0][1]-cy_kouho)
		for n in range(N-1):
			h_kouho = data[n+1][2] + abs(data[n+1][0]-cx_kouho)+abs(data[n+1][1]-cy_kouho)
			if(H_kakutei!=h_kouho or H_kakutei<1):
				break
			else:
				Cx_kakutei = cx_kouho
				Cy_kakutei = cy_kouho
				H_kakutei = h_kouho
				cnt += 1
				if(cnt==N-1):
					print(Cx_kakutei,Cy_kakutei,H_kakutei)
					exit(0)

Submission status: Wrong Answer

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

cx_kouho = 0
cy_kouho = 0
h_kouho = 0
H_kakutei = 1
Cx_kakutei = 0
Cy_kakutei = 0

for i in range(101):
	for j in range(101):
		cx_kouho = i
		cy_kouho = j
		cnt = 0

		H_kakutei = data[0][2] + abs(data[0][0]-cx_kouho)+abs(data[0][1]-cy_kouho)
		for n in range(N-1):
			h_kouho = data[n+1][2] + abs(data[n+1][0]-cx_kouho)+abs(data[n+1][1]-cy_kouho)
			if(H_kakutei!=h_kouho):
				break
			else:
				Cx_kakutei = cx_kouho
				Cy_kakutei = cy_kouho
				H_kakutei = h_kouho
				cnt += 1
				if(cnt==N-1):
					print(Cx_kakutei,Cy_kakutei,H_kakutei)
					exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        cand = []
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            if hs[i] == 0:
                cand.append((h, False))
            else:
                cand.append((h, True))

    
        cand2 = set([c[0] for c in cand if c[1]])
        if len(cand2) != 1:
            continue

        assert len(cand2) == 1
        ans = cand2.pop()

        if all([c[0] <= ans for c in cand if not c[1]]):
            print(x, y, ans)
            ok = True





# assert ok

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        ok2 = True
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            ans.add(h)

        if len(ans) == 1 and ok2:
            h = ans.pop()
            if h > 0:
                ok = True
                print(x, y, h)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        ok2 = True
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            if h == 0:
                ok2 = False
            ans.add(h)

        if len(ans) == 1 and ok2:
            ok = True
            print(x, y, ans.pop())

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        ok2 = True
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            if h == 1:
                ok2 = False
            ans.add(h)

        if len(ans) == 1 and ok2:
            ok = True
            print(x, y, ans.pop())

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            if h == 1:
                ans.add(-1)
                ans.add(-2)
            ans.add(h)

        if len(ans) == 1:
            ok = True
            print(x, y, ans.pop())

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            if h == 1:
                continue
            ans.add(h)

        if len(ans) == 1:
            ok = True
            print(x, y, ans.pop())

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ok = False
for x in range(101):
    for y in range(101):
        if ok:
            break
        ans = set()
        for i in range(N):
            h = hs[i] + abs(xs[i] - x) + abs(ys[i] - y)
            ans.add(h)

        if len(ans) == 1:
            ok = True
            print(x, y, ans.pop())

Submission status: Wrong Answer

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

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

for Cx in range(100):
  for Cy in range(100):
    H = abs(points[0][0]-Cx) + abs(points[0][1]-Cy) + points[0][2]
    accept = True
    for i in range(N):
        accept = accept and ( points[i][2] == (H - abs(points[i][0]-Cx) - abs(points[i][1]-Cy)) )
    if(accept):
        print(Cx,Cy,H)
        break

Submission status: Wrong Answer

Solution code:
ans_arr = [1 for i in range(101*101)]
n = int(input())

change_flag = 0
for k in range(n):
    x, y, h = map(int, input().split())
    if change_flag == 0:
        for i in range(101):
            for j in range(101):
                H = ans_arr[i*101+j]
                if ((H != 0) and h != 0):
                    ans_arr[i*101 + j]=abs(i-x) + abs(j-y) + h
                    change_flag = 1
    else:
        for i in range(101):
            for j in range(101):
                H = ans_arr[i * 101 + j]
                if H != 0 and h!=0:
                    if (max(H-abs(x-i)-abs(j-y),0) - h!=0):
                        ans_arr[i*101+j] = 0

for i in range(101):
    for j in range(101):
        if ans_arr[i*101+j]:
            print('{} {} {}'.format(i,j,ans_arr[i*101+j]))
            break

Submission status: Wrong Answer

Solution code:
ans_arr = [1 for i in range(101*101)]
n = int(input())

change_flag = 0
for k in range(n):
    x, y, h = map(int, input().split())
    if change_flag == 0:
        for i in range(101):
            for j in range(101):
                H = ans_arr[i*101+j]
                if (H != 0) and h != 0:
                    ans_arr[i*101 + j]=abs(i-x) + abs(j-y) + h
                    change_flag = 1
    else:
        for i in range(101):
            for j in range(101):
                H = ans_arr[i * 101 + j]
                if H != 0:
                    if (max(H-abs(x-i)-abs(j-y),0) - h!=0):
                        ans_arr[i*101+j] = 0

for i in range(101):
    for j in range(101):
        if ans_arr[i*101+j]:
            print('{} {} {}'.format(i,j,ans_arr[i*101+j]))
            break

Submission status: Wrong Answer

Solution code:
ans_arr = [1 for i in range(101*101)]
n = int(input())

change_flag = 0
for k in range(n):
    x, y, h = map(int, input().split())
    if change_flag == 0:
        for i in range(101):
            for j in range(101):
                H = ans_arr[i*101+j]
                if (H != 0) and h != 0:
                    ans_arr[i*101 + j]=abs(i-x) + abs(j-y) + h
                    change_flag = 1
    else:
        for i in range(101):
            for j in range(101):
                H = ans_arr[i * 101 + j]
                if H != 0:
                    if (max(H-abs(x-i)-abs(j-y),0) - h!=0):
                        ans_arr[i*101+j] = 0

for i in range(101):
    for j in range(101):
        if ans_arr[i*101+j]:
            print('{} {} {}'.format(i,j,ans_arr[i*101+j]))

Submission status: Wrong Answer

Solution code:

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

for i in range(101):
    for j in range(101):
        tmp_h=h[hizero]+abs(x[hizero]-i)+abs(y[hizero]-j)
        for k in range(0,n):
            if(max([0,tmp_h-abs(x[k]-i)-abs(y[k]-j)])!=h[k]):
                break
        if(tmp_h==h[k]+abs(x[k]-i)+abs(y[k]-j)):
            break
    if(tmp_h==h[k]+abs(x[k]-i)+abs(y[k]-j)):
        break
print("{} {} {}".format(i,j,tmp_h))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[0]*n
y=[0]*n
h=[0]*n
hizero=0
for i in range(n):
    x[i],y[i],h[i]=map(int,input().split())
    if(h[i]!=0):
        hizero=i

for i in range(101):
    for j in range(101):
        tmp_h=h[hizero]+abs(x[hizero]-i)+abs(y[hizero]-j)
        for k in range(0,n):
            if(tmp_h!=h[k]+abs(x[k]-i)+abs(y[k]-j)):
                break
        if(tmp_h==h[k]+abs(x[k]-i)+abs(y[k]-j)):
            break
    if(tmp_h==h[k]+abs(x[k]-i)+abs(y[k]-j)):
        break
print("{} {} {}".format(i,j,tmp_h))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
#print(l) 
for j in range(0,101):
    for k in range(0,101):
        for i in range(n):
            if l[i][2]>0:
                h=(l[i][2]+abs(j-l[i][0])+abs(k-l[i][1]))
                #print(j,k,h)
                break
        for i in range(n):
            h_r=(h-abs(j-l[i][0])-abs(k-l[i][1]))
            if l[i][2] !=h_r:
                #print(True)
                break
        else:
            print(j,k,h)

Submission status: Wrong Answer

Solution code:
n = input()
arr = []
for i in range(n):
    xi, yi, hi = map(int, raw_input().split())
    arr.append((xi, yi, hi))

for cx in range(101):
    for cy in range(101):
        for k in range(n):
            if arr[k][2] > 0:
                H = abs(arr[k][0]-cx)+abs(arr[k][1]-cy) + arr[k][2]
                break
        flag = 0
        for k in range(n):
            if arr[k][2] != max(H - abs(arr[k][0]-cx) - abs(arr[k][1]-cy), 0):
                flag = 1
                break
        if flag == 0:
            print cx, cy, H
        else:
            break

Submission status: Wrong Answer

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

for cx in range(100 + 1):
    for cy in range(100 + 1):

        vals = [h + abs(x - cx) + abs(y - cy) for x, y, h in [v for v in lst if v[2] > 0]]
        if not [x for x in vals if x != vals[0]]:
            print(cx, cy, vals[0])
            exit()

Submission status: Wrong Answer

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

for cx in range(100 + 1):
    for cy in range(100 + 1):

        vals = [h + abs(x - cx) + abs(y - cy) for x, y, h in [v for v in lst if v[2] > 0]]
        if vals[0] <= 0: continue
        if not [x for x in vals if x != vals[0]]:
            print(cx, cy, vals[0])
            exit()

Submission status: Wrong Answer

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

for cx in range(100 + 1):
    for cy in range(100 + 1):

        vals = [h + abs(x - cx) + abs(y - cy) for x, y, h in lst]
        if vals[0] <= 0: continue
        if not [x for x in vals if x != vals[0]]:
            print(cx, cy, vals[0])
            exit()

Submission status: Wrong Answer

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

for cx in range(100 + 1):
    for cy in range(100 + 1):

        vals = [h + abs(x - cx) + abs(y - cy) for x, y, h in lst]
        if not [x for x in vals if x != vals[0]]:
            print(cx, cy, vals[0])

Submission status: Wrong Answer

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

for ny in range(101):
    for nx in range(101):
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl:
            ax=nx
            ay=ny
            ah=nh

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

Submission status: Wrong Answer

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
for ny in range(101):
    for nx in range(101):
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

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

Submission status: Wrong Answer

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
for ny in range(101):
    for nx in range(101):
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl:
            ax=nx
            ay=ny
            ah=nh

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

Submission status: Wrong Answer

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
for ny in range(101):
    for nx in range(101):
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl:
            ax=nx
            ay=ny
            ah=nh

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

Submission status: Wrong Answer

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl:
            ax=nx
            ay=ny
            ah=nh

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

Submission status: Wrong Answer

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
                    break
        if fl and i==len(xyh)-1:
            ax=nx
            ay=ny
            ah=nh

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

Submission status: Wrong Answer

Solution code:
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
nh=0
for ny in range(101):
    if fl:
        break
    for nx in range(101):
        if fl:
            break
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        fl=True
        for i in range(len(xyh)):
                if nh!=abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]:
                    fl=False
                    break
        if fl and i==len(xyh)-1:
            ax=nx
            ay=ny
            ah=nh

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

Submission status: Wrong Answer

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

for cy in range(101):
	for cx in range(101):
		for i in range(N):

			H = abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy) + xyh[i][2]

			flag = False
			for j in range(N):
				th = max(H-abs(xyh[j][0]-cx)-abs(xyh[j][1]-cy),0)
				if th != xyh[j][2]:
					flag = True
					break

			if flag:
				continue
				
			print(cx,cy,H)
			exit()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    tuples = []
    for _ in range(N):
        x, y, h = [int(e) for e in input().split()]
        if h > 0:
            tuples.append((x, y, h))

    sx, sy, sh = tuples.pop()

    for cs in range(101):
        for cy in range(101):
            H = sh + (abs(cs - sx) + abs(cy - sy))
            H = max([H, 0])
            flag = True
            for t in tuples:
                h = H - abs(cs - t[0]) - abs(cy - t[1])
                h = max([h, 0])
                if t[2] != h:
                    flag = False
            if flag:
                print(cs, cy, H)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    pairs = []
    for _ in range(N):
        pair = [int(e) for e in input().split()]
        if pair[2] > 0:
            pairs.append(pair)

    d = defaultdict(int)
    for pair in pairs:
        x, y, h = pair

        for X in range(101):
            for Y in range(101):
                H = h + (abs(X - x) + abs(Y - y))
                if h > 0:
                    d[(X, Y, H)] += 1

    for k, v in d.items():
        if v == N:
            X, Y, H = k
            print(X, Y, H)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    pairs = []
    for _ in range(N):
        pair = [int(e) for e in input().split()]
        pairs.append(pair)

    d = defaultdict(int)
    for pair in pairs:
        x, y, h = pair

        for X in range(101):
            for Y in range(101):
                H = h + (abs(X - x) + abs(Y - y))
                if h > 0:
                    d[(X, Y, H)] += 1

    for k, v in d.items():
        if v == N:
            X, Y, H = k
            print(X, Y, H)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    pairs = []
    for _ in range(N):
        pair = [int(e) for e in input().split()]
        pairs.append(pair)

    d = defaultdict(int)
    for pair in pairs:
        x, y, h = pair

        for X in range(101):
            for Y in range(101):
                H = h + (abs(X - x) + abs(Y - y))
                if h == max(H - abs(X - x) - abs(Y - y), 0):
                    d[(X, Y, H)] += 1

    for k, v in d.items():
        if v == N:
            X, Y, H = k
            # if (0 <= X <= 100) and (0 <= Y <= 100) and (0 <= H <= 10 * 9):
            if 0 <= X and X <= 100 and 0 <= Y and Y <= 100 and 1 <= H and H <= 10 ** 9:
                print(X, Y, H)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    pairs = []
    for _ in range(N):
        pair = [int(e) for e in input().split()]
        pairs.append(pair)

    d = defaultdict(int)
    for pair in pairs:
        x, y, h = pair

        for X in range(101):
            for Y in range(101):
                H = h + (abs(X - x) + abs(Y - y))
                if max(H - abs(X - x) - abs(Y - y), 0) > 1:
                    d[(X, Y, H)] += 1

    for k, v in d.items():
        if v == N:
            X, Y, H = k
            # if (0 <= X <= 100) and (0 <= Y <= 100) and (0 <= H <= 10 * 9):
            if 0 <= X and X <= 100 and 0 <= Y and Y <= 100 and 1 <= H and H <= 10 ** 9:
                print(X, Y, H)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def main():
    N = int(input())
    pairs = []
    for _ in range(N):
        pair = [int(e) for e in input().split()]
        pairs.append(pair)

    d = defaultdict(int)
    for pair in pairs:
        x, y, h = pair

        for X in range(101):
            for Y in range(101):
                H = h + (abs(X - x) + abs(Y - y))
                if max(H - abs(X - x) - abs(Y - y), 0) != 0:
                    d[(X, Y, H)] += 1

    for k, v in d.items():
        if v == N:
            X, Y, H = k
            # if (0 <= X <= 100) and (0 <= Y <= 100) and (0 <= H <= 10 * 9):
            if 0 <= X and X <= 100 and 0 <= Y and Y <= 100 and 1 <= H and H <= 10 ** 9:
                print(X, Y, H)


if __name__ == '__main__':
    main()