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 = [[0, 0, 0] for _ in range(N)]
for i in range(N):
    XYH[i] = list(map(int, input().split()))

H_dict = {}
cnt = 1
for x in range(0, 101):
    for y in range(0, 101):
        diff_x = abs(XYH[0][0] - x)
        diff_y = abs(XYH[0][1] - y)
        H = XYH[0][2] + diff_x + diff_y
        for j in range(1, N):
            if max(H - abs(XYH[j][0] - x) - abs(XYH[j][1] - y), 0) == XYH[j][2]:
                cnt += 1
                if cnt == N:
                    print(x, y, H)
                continue
            else:
                break

Submission status: Wrong Answer

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

H_dict = {}

for x in range(0, 101):
    for y in range(0, 101):
        for i in range(N):
            diff_x = abs(XYH[i][0] - x)
            diff_y = abs(XYH[i][1] - y)
            H = XYH[i][2] + diff_x + diff_y
            H_dict[i] = H
        h_max = max(H_dict.items(), key = lambda x: x[1])[1]
        h_min = min(H_dict.items(), key = lambda x: x[1])[1]
        if h_max == h_min:
            print(x, y, H)
            break

Submission status: Wrong Answer

Solution code:
def dist(h,xi, yi, cx, cy):
    return h + abs(xi - cx) + abs(yi - cy)

N = int(input())
P = []
for i in range(N):
    h, xi, yi, = map(int, input().split())
    P.append([h, xi, yi])
P.sort(reverse = True)

for i in range(101):
    for j in range(101):
        H = dist(P[0][0], P[0][1], P[0][2],i, j)
        for p in P[1:]:
            if max(H - abs(p[1]-i)-abs(p[2]-j), 0) != p[0]:
                break
        else:
            print(i, j, H)
            break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list()
flag = 0
for i in range(n):
    a.append(list(map(int, input().split())))
for k in range(101):
    for j in range(101):
        h = list()
        mH0 = 10**8
        cnt = 0
        for i in range(n):
            if a[i][2] == 0:
                cnt += 1
                H0 = abs(k-a[i][0])+abs(j-a[i][1])
                if mH0 > H0:
                    mH0 = H0
                    h0 = (k,j,mH0)
            else:
                h.append(a[i][2]+abs(k-a[i][0])+abs(j-a[i][1]))
        H = collections.Counter(h)
#         print(h)
#         print(H)
#         print('x=',k,'y=',j)
        if n == cnt:
            print(h0)
            break
        if max(H.values()) == n-cnt:
            print(k,j,h[0])
            flag = 1
            break
        else: 
            continue
    if flag == 1:
        break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list()
flag = 0
for i in range(n):
    a.append(list(map(int, input().split())))
for k in range(101):
    for j in range(101):
        h = list()
        cnt = 0
        for i in range(n):
            if a[i][2] == 0:
                cnt += 1
                continue
            else:
                h.append(a[i][2]+abs(k-a[i][0])+abs(j-a[i][1]))
        H = collections.Counter(h)
#         print(h)
#         print(H)
#         print('x=',k,'y=',j)
        if max(H.values()) == n-cnt:
            print(k,j,h[0])
            flag = 1
            break
        else: 
            continue
    if flag == 1:
        break

Submission status: Wrong Answer

Solution code:
import collections
n = int(input())
a = list()
flag = 0
for i in range(n):
    a.append(list(map(int, input().split())))
for k in range(101):
    for j in range(101):
        h = list()
        for i in range(n):
            h.append(a[i][2]+abs(k-a[i][0])+abs(j-a[i][1]))
        H = collections.Counter(h)
#         print(h)
#         print(H)
#         print('x=',k,'y=',j)
        if max(H.values()) == n:
            print(k,j,h[0])
            flag = 1
            break
        else: 
            continue
    if flag == 1:
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
x_list = []
y_list = []
h_list = []

for i in range(n):
    a, b, c = map(int, input().split())
    x_list.append(a)
    y_list.append(b)
    h_list.append(c)

k = h_list.index(max(h_list))

for x in range(101):
    for y in range(101):
        h_max = h_list[k] + abs(x_list[k] - x) + abs(y_list[k] - y)
        
        for j in range(n):
            if h_list[j] == 0 :
                if h_max - (abs(x_list[j] - x) + abs(y_list[j] - y)) > 0 :
                    h_max = -1
            else:
                if h_max != abs(x_list[j] - x) + abs(y_list[j] - y) + h_list[j]:
                    h_max = -1
        
        if h_max != -1:
            print(f"{j} {h_max - (abs(x_list[j] - x) + abs(y_list[j] - y))}")
            print(str(x)+' '+str(y)+ ' '+ str(h_max))
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
 
for i in range(101):
    for j in range(101):
        res = []
        for k in range(0,n):
            dx = ab[k][0]
            dy = ab[k][1]
            dh = ab[k][2]
            if dh ==0:
                pass
            else:
                res.append(abs(i-dx)+abs(j-dy)+dh)
        if len(set(res)) == 1:
            ansx =i
            ansy =j
            ansr = res[0]
            break
print(str(ansx)+" "+str(ansy)+" "+str(ansr))

Submission status: Wrong Answer

Solution code:

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

ans = []
for c_x in range(0, 101):
    for c_y in range(0, 101):
        tmp = []
        for x, y, h in X:
            if h == 0:
                continue
            tmp.append(h + abs(x - c_x) + abs(y - c_y))

        if all(tmp[0] == v for v in tmp):
            ans = [c_x, c_y, tmp[0]]

print(*ans)

Submission status: Wrong Answer

Solution code:

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

ans = []
for c_x in range(0, 101):
    for c_y in range(0, 101):
        tmp = []
        for x, y, h in X:
            tmp.append(h + abs(x - c_x) + abs(y - c_y))

        if all(tmp[0] == v for v in tmp):
            ans = [c_x, c_y, tmp[0]]

print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]
xyh = sorted(xyh, key=lambda x:(x[2]))

ans = -1, -1, -1
for cx in range(101):
    for cy in range(101):
        flg = True
        x, y, h = xyh[0][0], xyh[0][1], xyh[0][2]
        ch = abs(cx-x) + abs(cy-y) + h
        for i in range(1,n):
            x, y, h = xyh[i][0], xyh[i][1], xyh[i][2]
            tmph = max(ch - abs(cx-x) - abs(cy-y), 0)
            if h != tmph:
                flg = False
                break
        if flg:
            ans = cx, cy, ch
print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[]
for h in range(N):
    Cx,Cy,h=map(int,input().split())
    L.append([h,Cx,Cy])
L.sort()

for x in range(101):
    for y in range(101):
        cond=True
        H=L[0][0]+abs(x-L[0][1])+abs(y-L[0][2])
        for i in range(1,N):
            h=L[i][0]+abs(x-L[i][1])+abs(y-L[i][2])
            if L[i][0]>0:
                if h!=H:
                    cond=False
                    break
            else:
                if h<H:
                    cond=False
                    break
        if cond:
            break
    if cond:
        break

print(x,y,H)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        cond=True
        H=abs(x-L[0][0])+abs(y-L[0][1])+L[0][2]
        if H<=0:
            cond=False
            continue
        for i in range(1,N):
            if H!=L[i][2]+abs(x-L[i][0])+abs(y-L[i][1]):
                cond=False
                break
        if cond:
            break
    if cond:
        break
print(x,y,H)

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        cond=True
        H=abs(x-L[0][0])+abs(y-L[0][1])+L[0][2]
        if H<0:
            continue
        for i in range(1,N):
            if H!=L[i][2]+abs(x-L[i][0])+abs(y-L[i][1]):
                cond=False
                break
        if cond:
            break
    if cond:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
sw3 = 0
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if h == 0:
                    if abs(X-x) + abs(Y-y) != 0:
                        H = abs(X-x) + abs(Y-y)
                        sw3 = 1
                    pass
                
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
                
        if sw3 == 1:
            i = 0
            while i < n:
                x,y,h = z[i][0], z[i][1], z[i][2]
                if H == -1:
                    if h == 0:
                        pass

                    else:
                        H = h + abs(X-x) + abs(Y-y)
                        if i != 0:
                            i = 0
                else:
                    if h != max(H - abs(X-x) - abs(Y-y), 0):
                        sw = 0
                        break
                        
                i += 1
                        
            if sw == 1:
                if H <= 0:
                    pass
                else:
                    ans = [X,Y,H]
                    sw2 = 1
                    break
                    
            sw3 = 0
                
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
sw3 = 0
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if h == 0:
                    if abs(X-x) + abs(Y-y) != 0:
                        H = abs(X-x) + abs(Y-y)
                        sw3 = 1
                    pass
                
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
                
        if sw3 == 1:
            i = 0
            while i < n:
                x,y,h = z[i][0], z[i][1], z[i][2]
                if H == -1:
                    if h == 0:
                        pass

                    else:
                        H = h + abs(X-x) + abs(Y-y)
                        if i != 0:
                            i = 0
                else:
                    if h != max(H - abs(X-x) - abs(Y-y), 0):
                        sw = 0
                        break
                        
                i += 1
                        
            if sw == 1:
                if H <= 0:
                    pass
                else:
                    ans = [X,Y,H]
                    sw2 = 1
                    break
                
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
sw3 = 0
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if abs(X-x) + abs(Y-y) > h:
                    if h == 0:
                        sw3 = 1
                        pass
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
                
        if sw3 == 1:
            while i < n:
                x,y,h = z[i][0], z[i][1], z[i][2]
                if H == -1:
                    if abs(X-x) + abs(Y-y) == 0:
                        H = 0

                    else:
                        H = h + abs(X-x) + abs(Y-y)
                        if i != 0:
                            i = 0
                else:
                    if h != max(H - abs(X-x) - abs(Y-y), 0):
                        sw = 0
                        break

                i += 1

            if sw == 1:
                if H <= 0:
                    pass
                else:
                    ans = [X,Y,H]
                    sw2 = 1
                    break
                
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
sw3 = [0,0]
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if h == 0:
                    if abs(X-x) + abs(Y-y) == 0:
                        H = 0
                        sw3 = [1,i]
                    else:
                        pass
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
                
        if sw3[0] == 1:
            while i < n:
                x,y,h = z[i][0], z[i][1], z[i][2]
                if H == -1:
                    if abs(X-x) + abs(Y-y) > h:
                        pass
                    else:
                        H = h + abs(X-x) + abs(Y-y)
                        if i != 0:
                            i = 0
                else:
                    if h != max(H - abs(X-x) - abs(Y-y), 0):
                        sw = 0
                        break

                i += 1

            if sw == 1:
                if H <= 0:
                    pass
                else:
                    ans = [X,Y,H]
                    sw2 = 1
                    break
                
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
sw3 = [0,0]
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if h == 0:
                    if abs(X-x) + abs(Y-y) == 0:
                        H = 0
                        sw3 = [1,i]
                    else:
                        pass
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
                
        if sw3[0] == 1:
            while i < n:
                x,y,h = z[i][0], z[i][1], z[i][2]
                if H == -1:
                    if h == 0:
                        pass
                    else:
                        H = h + abs(X-x) + abs(Y-y)
                        if i != 0:
                            i = 0
                else:
                    if h != max(H - abs(X-x) - abs(Y-y), 0):
                        sw = 0
                        break

                i += 1

            if sw == 1:
                if H <= 0:
                    pass
                else:
                    ans = [X,Y,H]
                    sw2 = 1
                    break
                
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if h == 0:
                    if abs(X-x) + abs(Y-y) == 0:
                        H = 0
                    else:
                        pass
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break       
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if abs(X-x) + abs(Y-y) > h:
                    pass
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break       
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if h == 0:
                    pass
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
            
        
            
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
ans = [0,0,0]
for X in range(101):

    for Y in range(101):
        sw = 1
        H = -1
        for i,[x,y,h] in enumerate(z):
            if H == -1:
                H = h + abs(X-x) + abs(Y-y)
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
            
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
ans = [0,0,0]
for X in range(101):
    if sw2 == 1:
        break
    for Y in range(101):
        sw = 1
        H = -1
        for i,[x,y,h] in enumerate(z):
            if H == -1:
                H = h + abs(X-x) + abs(Y-y)
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
            
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
ans = [0,0,0]
for X in range(100):
    if sw2 == 1:
        break
    for Y in range(100):
        sw = 1
        H = -1
        for i,[x,y,h] in enumerate(z):
            if H == -1:
                if h + abs(X-x) + abs(Y-y) >= 1:
                    H = h + abs(X-x) + abs(Y-y)
                else:
                    sw = 0
                    break
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
        if sw == 1:
            ans = [X,Y,H]
            sw2 = 1
            break
            
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
ans = [0,0,0]
for X in range(101):
    if sw2 == 1:
        break
    for Y in range(101):
        sw = 1
        H = -1
        for i,[x,y,h] in enumerate(z):
            if H == -1:
                H = h + abs(X-x) + abs(Y-y)
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
        if sw == 1:
            ans = [X,Y,H]
            sw2 = 1
            break
            
print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
hs = [list(map(int, input().split())) for _ in range(n)]
hs.sort(key = lambda x: x[2], reverse = True)

#print(hs)
def main():
    for x in range(101):
        for y in range(101):
            height = hs[0][2] + abs(x-hs[0][0]) + abs(y-hs[0][1])
            for i in range(n):
                if hs[i][2] != 0:
                    if hs[i][2] == height - abs(x-hs[i][0]) - abs(y-hs[i][1]):
                        pass
                    else:
                        break
                else:
                    if hs[i][2] != height - abs(x-hs[i][0]) + abs(y-hs[i][1]):
                        break
                if i == n-1:
                    print(x,y,height)
                    return x,y,height
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
hs = [list(map(int, input().split())) for _ in range(n)]
hs.sort(key = lambda x: x[2], reverse = True)

#print(hs)
def main():
    for x in range(101):
        for y in range(101):
            height = hs[0][2] + abs(x-hs[0][0]) + abs(y-hs[0][1])
            for i in range(n):
                if hs[i][2] != 0:
                    if hs[i][2] == height - abs(x-hs[i][0]) - abs(y-hs[i][1]):
                        pass
                    else:
                        break
                if i == n-1:
                    print(x,y,height)
                    return x,y,height
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
hs = [list(map(int, input().split())) for _ in range(n)]
hs.sort(key = lambda x: x[2], reverse = True)

#print(hs)
def main():
    for x in range(101):
        for y in range(101):
            height = hs[0][2] + abs(x-hs[0][0]) + abs(y-hs[0][1])
            for i in range(n):
                if hs[i][2] != 0:
                    if hs[i][2] == height - abs(x-hs[i][0]) - abs(y-hs[i][1]):
                        pass
                    else:
                        break
                if i == n-1:
                    return x,y,height
print(main())

Submission status: Wrong Answer

Solution code:
N = int(input())
K = 101
D = []
for _ in range(N):
    x, y, h = map(int, input().split())
    D.append((x,y,h))
V = set()
for i in range(K):
    for j in range(K):
        flg = True
        H = -1
        for x, y, h in D:
            if h == 0:
                V.add((x,y))
                continue
            if H == -1:
                H = abs(x-i) + abs(y-j) + h
                continue
            if H != abs(x-i) + abs(y-j) + h:
                flg = False
                break
        if flg:
            print(i,j,H)
            exit()
for i in range(K):
    for j in range(K):
        if (i,j) not in V:
            print(i,j,1)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
K = 101
D = []
for _ in range(N):
    x, y, h = map(int, input().split())
    D.append((x,y,h))
for i in range(K):
    for j in range(K):
        flg = True
        H = -1
        for x, y, h in D:
            if h == 0:
                continue
            if H == -1:
                H = abs(x-i) + abs(y-j) + h
                continue
            if H != abs(x-i) + abs(y-j) + h:
                flg = False
                break
        if flg:
            print(i,j,H)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    h = abs(x-m[0][0])+abs(y-m[0][1])+m[0][2]
    for z in range(1, n):
      if max(h-abs(x-m[z][0])-abs(y-m[z][1]), 0)==m[z][2]:
        continue
      else:
        break
    else:
      print(x, y, h)
      exit()

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    res = [0]*n
    res1 = 0
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] += h
        res1 = h
        t += 1
      else:
        if res1-abs(x-m[z][0])-abs(y-m[z][1])>0:
          break
    if res.count(res1)==t and m[0][2]==max(res1-abs(x-m[0][0])-abs(y-m[0][1]), 0):
      print(x, y, res1)
      exit()

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    res = [0]*n
    res1 = float('inf')
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] += h
        res1 = min(res1, h)
        t += 1
      else:
        res1 = min(res1, abs(x-m[z][1])+abs(y-m[z][1]))
    if res.count(res1)==t:
      print(x, y, res1)
      exit()

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    res = [0]*n
    res1 = 0
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] += h
        res1 = max(res1, h)
        t += 1
      else:
        res1 = max(res1, abs(x-m[z][1])+abs(y-m[z][1]))
    if res.count(res1)==t:
      print(x, y, res1)
      exit()

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    res = [0]*n
    res1 = 0
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] += h
        res1 = max(res1, h)
        t += 1
      else:
        if z != 0:
          if res1-abs(x-m[z][0])-abs(y-m[z][1])>0:
            break
        else:
          res1 = abs(x-m[z][1])+abs(y-m[z][1])
    if res.count(res1)==t:
      print(x, y, res1)
      exit()

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    res = [0]*n
    res1 = 0
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] += h
        res1 = h
        t += 1
      else:
        if res1-abs(x-m[z][0])-abs(y-m[z][1])>0:
          break
    if res.count(res1)==t:
      print(x, y, res1)
      exit()

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    res = [0]*n
    res1 = 0
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] += h
        res1 = h
        t += 1
    if res.count(res1)==t:
      print(x, y, res1)
      exit()