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())
xy = [list(map(int,input().split())) for _ in range(n)]

for x in range(101):
    for y in range(101):
        h = [0,10**10]
        h_memo = 0
        for i in range(n):
            if xy[i][2] == 0:
                h[1] = min(h[1],abs(xy[i][0]-x) + abs(xy[i][1]-y))
            else:
                h_memo = xy[i][2] + abs(xy[i][0]-x) + abs(xy[i][1]-y)
            #print(x,y,h[1],h_memo)
            if h[0]!=0:
                if h_memo == h[0]:
                    continue
                elif h_memo != h[0]:
                    break
                elif h[1] < h[0]:
                    break
            
            elif h[0]==0 and h_memo!=0:
                h[0] = h_memo
            elif h[0]==0 and h_memo==0:
                if h[1] < (abs(xy[i][0]-x) + abs(xy[i][1]-y)):
                    break
            if h[0]>h[1]:
                break
        else:               
            #print(x+1,y+1,h[0])
            if h[0]==0:
                continue
            else:
                print(x,y,h[0])

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = [0,10**10]
        h_memo = 0
        for i in range(n):
            if xy[i][2] == 0:
                h[1] = min(h[1],abs(xy[i][0]-x) + abs(xy[i][1]-y))
            else:
                h_memo = xy[i][2] + abs(xy[i][0]-x) + abs(xy[i][1]-y)
            #print(x,y,h[1],h_memo)
            if h[0]!=0:
                if h_memo == h[0]:
                    continue
                elif h_memo != h[0]:
                    break
                elif h[1] < h[0]:
                    break
                elif h[0]>h[1]:
                    break
            elif h[0]==0 and h_memo!=0:
                h[0] = h_memo
            elif h[0]==0 and h_memo==0:
                if h[1] < (abs(xy[i][0]-x) + abs(xy[i][1]-y)):
                    break
        else:               
            #print(x+1,y+1,h[0])
            if h[0]==0:
                continue
            else:
                print(x,y,h[0])

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        h = [0,10**10]
        h_memo = 0
        for i in range(n):
            if xy[i][2] == 0:
                h[1] = min(h[1],abs(xy[i][0]-x) + abs(xy[i][1]-y))
            else:
                h_memo = xy[i][2] + abs(xy[i][0]-x) + abs(xy[i][1]-y)
            #print(x,y,h[1],h_memo)
            if h[0]!=0:
                if h_memo == h[0]:
                    continue
                elif h_memo != h[0]:
                    break
                elif h[1] < h[0]:
                    break
            elif h[0]==0 and h_memo!=0:
                h[0] = h_memo
            elif h[0]==0 and h_memo==0:
                if h[1] < (abs(xy[i][0]-x) + abs(xy[i][1]-y)):
                    break
        else:               
            #print(x+1,y+1,h[0])
            if h[0]==0:
                continue
            else:
                print(x,y,h[0])

Submission status: Wrong Answer

Solution code:
def decide_H(Cx,Cy):
    for x,y,h in T:
        H=h+abs(x-Cx)+abs(y-Cy)
        if H>=1:
            return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True

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

for Cx in range(101):
    for Cy in range(101):
        H=decide_H(Cx,Cy)
        if check_H(Cx,Cy,H):
            print(Cx,Cy,H)
            exit(0)

Submission status: Wrong Answer

Solution code:
def decide_H(Cx,Cy):
    for x,y,h in T:
        H=h+abs(x-Cx)+abs(y-Cy)
        if H>=1:
            return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if h != max(H - abs(x - Cx) - abs(y - Cy), 0):
            return False
    return True

N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        H=decide_H(Cx,Cy)
        if check_H(Cx,Cy,H):
            print(Cx,Cy,H)
            exit(0)

Submission status: Wrong Answer

Solution code:
def decide_H(Cx,Cy,x,y,h):
    H=h+abs(x-Cx)+abs(y-Cy)
    if H>=1:
        return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if H==decide_H(Cx,Cy,x,y,h) and H!=None and h!=0:
            continue
        else:
            return False
    return True

N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        for x,y,h in T:
            H=decide_H(Cx,Cy,x,y,h)
            if check_H(Cx,Cy,H):
                print(Cx,Cy,H)
                exit()
            else:
                break

Submission status: Wrong Answer

Solution code:
def decide_H(Cx,Cy,x,y,h):
    H=h+abs(x-Cx)+abs(y-Cy)
    if H>=1:
        return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if H==decide_H(Cx,Cy,x,y,h) and H!=None:
            continue
        else:
            return False
    return True

N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        for x,y,h in T:
            H=decide_H(Cx,Cy,x,y,h)
            if H==0:
                break
            else:
                if check_H(Cx,Cy,H):
                    print(Cx,Cy,H)
                    exit()
                else:
                    break

Submission status: Wrong Answer

Solution code:
def decide_H(Cx,Cy,x,y,h):
    H=h+abs(x-Cx)+abs(y-Cy)
    if H>=1:
        return(H)

def check_H(Cx,Cy,H):
    for x,y,h in T:
        if H==decide_H(Cx,Cy,x,y,h) and H!=None:
            continue
        else:
            return False
    return True

N=int(input())
T=[[int(i) for i in input().split()] for _ in range(N)]

for Cx in range(101):
    for Cy in range(101):
        for x,y,h in T:
            H=decide_H(Cx,Cy,x,y,h)
            if check_H(Cx,Cy,H):
                print(Cx,Cy,H)
                exit()
            else:
                break

Submission status: Wrong Answer

Solution code:
N = int(input())
p = [list(map(int, input().split()))for _ in range(N)]
ax=p[0][0]
ay=p[0][1]
ah=p[0][2]
for x in range(101):
    for y in range(101):
        H = ah+abs(ax-x)+abs(ay-y)
        if all(max(H-abs(t[0]-x)-abs(t[1]-y), 0) == t[2]for t in p):
            print(x, y, H)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int, input().split())) for _ in range(N)]
for i in range(101):
  for j in range(101):
    center=[i,j,x[0][2]+abs(x[0][0]-i)+abs(x[0][1]-j)]
    if all(t[2]==max(center[2]-abs(t[0]-center[0])-abs(t[1]-center[1]),0) for t in x) :
      print(center[0],center[1],center[2])

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int, input().split())) for _ in range(N)]
for i in range(101):
  for j in range(101):
    center=[i,j,x[0][2]+abs(x[0][0]-i)+abs(x[0][1]-j)]
    for k in range(1,N):
      if x[k][2]!=max(center[2]-abs(x[k][0]-center[0])-abs(x[k][1]-center[1]),0):
        break
    else:
      print(center[0],center[1],center[2])
      exit()

Submission status: Wrong Answer

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

#(i,j)が中心座標にあるとき
for i in range(101):
  for j in range(101):
    H=abs(B[0][0]-i)+abs(B[0][1]-j)+B[0][2]
    for k in range(N):
      if max(H-abs(B[k][0]-i)-abs(B[k][1]-j),0)!=B[k][2]:
        break
    else:
      print(i,j,H)     
      exit()

Submission status: Wrong Answer

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

#(i,j)が中心座標にあるとき
for i in range(101):
  for j in range(101):
    H=abs(B[0][0]-i)+abs(B[0][1]-j)+B[0][2]
    for k in range(1,N):
      if max(H-abs(B[k][0]-i)-abs(B[k][1]-j),0)!=B[k][2]:
        break
    else:
      print(i,j,H)     
      break

Submission status: Wrong Answer

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

#(i,j)が中心座標にあるとき
for i in range(101):
  for j in range(101):
    H=abs(B[0][0]-i)+abs(B[0][1]-j)+B[0][2]
    for k in range(1,N):
      if max(H-abs(B[k][0]-i)-abs(B[k][1]-j),0)!=B[k][2]:
        break
    else:
      print(i,j,H)     
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int, input().split())) for _ in range(N)]
for i in range(101):
  for j in range(101):
    center=[i,j,x[0][2]+abs(x[0][0]-i)+abs(x[0][1]-j)]
    for k in range(1,N):
      if x[k][2]!=center[2]-abs(x[k][0]-center[0])-abs(x[k][1]-center[1]):
        break
    else:
      print(center[0],center[1],center[2])
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
P = []
for i in range(N):
    x,y,h = map(int,input().split())
    P.append((x,y,h))
def f(x,y,h,i,j):
    H = h + max(x-i,i-x) + max(y-j,j-y)
    return H
for i in range(101):
    for j in range(101):
        Hi = []
        t = 1
        M = 10**100
        for k in range(N):
            x,y,h = P[k]
            if h == 0:
                H = f(x,y,h,i,j)
                M = min(M,H)
                continue
            H = f(x,y,h,i,j)
            if H > M:
                t = 0
            if H not in Hi:
                Hi.append(H)
        if len(Hi) == 1:
            print(i,j,Hi[0])
            quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
P = []
for i in range(N):
    x,y,h = map(int,input().split())
    P.append((x,y,h))
def f(x,y,h,i,j):
    H = h + max(x-i,i-x) + max(y-j,j-y)
    return H
for i in range(101):
    for j in range(101):
        Hi = []
        t = 1
        M = 10**10
        for k in range(N):
            x,y,h = P[k]
            if h == 0:
                H = f(x,y,h,i,j)
                M = min(M,H)
                continue
            H = f(x,y,h,i,j)
            if H > M:
                t = 0
            if H not in Hi:
                Hi.append(H)
        if len(Hi) == 1:
            print(i,j,Hi[0])
            quit()
        if len(Hi) == 0:
            print(i,j,M)

Submission status: Wrong Answer

Solution code:
N = int(input())
P = []
for i in range(N):
    x,y,h = map(int,input().split())
    P.append((x,y,h))
def f(x,y,h,i,j):
    H = h + max(x-i,i-x) + max(y-j,j-y)
    return H
for i in range(101):
    for j in range(101):
        Hi = []
        t = 1
        M = 10**10
        for k in range(N):
            x,y,h = P[k]
            if h == 0:
                H = f(x,y,h,i,j)
                M = min(M,H)
                continue
            H = f(x,y,h,i,j)
            if H > M:
                t = 0
            if H not in Hi:
                Hi.append(H)
        if len(Hi) != 1:
            t = 0
        if t == 1:
            print(i,j,Hi[0])
            quit()

Submission status: Wrong Answer

Solution code:
n=int(input())
L=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[2])
for cx in range(101):
	for cy in range(101):
		H=L[-1][2]+abs(L[-1][0]-cx)+abs(L[-1][1]-cy)
		if all([H==L[i][2]+abs(L[i][0]-cx)+abs(L[i][1]-cy) for i in range(n-1)]):
				print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    X,Y,H = [],[],[]
    xyh = [list(map(int, input().split())) for _ in range(n)]
    xyh = sorted(xyh, key=lambda x:x[2], reverse=True)
    for i in range(n):
        X.append(xyh[i][0])
        Y.append(xyh[i][1])
        H.append(xyh[i][2])

    for cx in range(101):
        for cy in range(101):
            judge = True
            h = H[0]+abs(X[0]-cx)+abs(Y[0]-cy)
            if h == 79:
                print(cx,cy)
            for i in range(n):
                if H[i] != max(h-abs(X[i]-cx)-abs(Y[i]-cy),0):
                    judge = False
                    break
            if judge:
                print(cx,cy,h)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    X,Y,H = [],[],[]
    for _ in range(n):
        x,y,h = map(int, input().split())
        X.append(x)
        Y.append(y)
        H.append(h)

    for cx in range(101):
        for cy in range(101):
            judge = True
            h = H[0]+abs(X[0]-cx)+abs(Y[0]-cy)
            for i in range(n):
                if H[i] != max(h-abs(X[i]-cx)-abs(Y[i]-cy),0):
                    judge = False
                    break
            if judge:
                print(cx,cy,h)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    X,Y,H = [],[],[]
    for _ in range(n):
        x,y,h = map(int, input().split())
        X.append(x)
        Y.append(y)
        H.append(h)

    for cx in range(101):
        for cy in range(101):
            judge = True
            h = H[0]+abs(X[0]-cx)+abs(Y[0]-cy)
            for i in range(n):
                if H[0] != max(h-abs(X[i]-cx)-abs(Y[i]-cy),0):
                    judge = False
                    break
            if judge:
                print(cx,cy,h)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    X,Y,H = [],[],[]
    for _ in range(n):
        x,y,h = map(int, input().split())
        X.append(x)
        Y.append(y)
        H.append(h)

    ans = 10**8
    candidate = []
    for j in range(101):
        for k in range(101):
            h_tmp = 0
            for i in range(n):
                if H[i] == 0:
                    pass
                else:
                    h = H[i]+abs(X[i]-j)+abs(Y[i]-k)
                    if h_tmp == 0:
                        h_tmp = h
                        continue
                    if h != h_tmp:
                        break
                    if i == n-1:
                        print(j,k,h_tmp)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    xyh = sorted(xyh, key=itemgetter(2), reverse=True)

    for cx in range(101):
        for cy in range(101):
            x, y, h = xyh[0]
            H = -1
            if h != 0:
                H = h + abs(x - cx) + abs(y - cy)
            is_correct = True
            for x, y, h in xyh:
                if h == 0:
                    if H - abs(x - cx) - abs(y - cy) > 0:
                        is_correct = False
                        break
                if H == -1:
                    H = h + abs(x - cx) + abs(y - cy)
                    continue
                if H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break

            if is_correct:
                print(cx, cy, H)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    xyh = sorted(xyh, key=itemgetter(2), reverse=True)

    for cx in range(101):
        for cy in range(101):
            x, y, h = xyh[0]
            H = -1
            if h != 0:
                H = h + abs(x - cx) + abs(y - cy)
            is_correct = True
            for x, y, h in xyh:
                if h == 0:
                    break
                if H == -1:
                    H = h + abs(x - cx) + abs(y - cy)
                    continue
                if H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break

            if is_correct:
                print(cx, cy, H)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from operator import itemgetter


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    xyh = sorted(xyh, key=itemgetter(2), reverse=True)

    for cx in range(101):
        for cy in range(101):
            x, y, h = xyh[0]
            H = -1
            if h != 0:
                H = h + abs(x - cx) + abs(y - cy)
            is_correct = True
            for x, y, h in xyh:
                if h == 0:
                    continue
                if H == -1:
                    H = h + abs(x - cx) + abs(y - cy)
                    continue
                if H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break

            if is_correct:
                print(cx, cy, H)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    for cx in range(101):
        for cy in range(101):
            x, y, h = xyh[0]
            H = 0
            if h == 0:
                H = -1
            else:
                H = h + abs(x - cx) + abs(y - cy)
            if H == 0:
                continue
            is_correct = True
            for x, y, h in xyh:
                if h == 0:
                    continue
                if H == -1:
                    H = h + abs(x - cx) + abs(y - cy)
                    continue
                if H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break

            if is_correct:
                print(cx, cy, H)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    for cx in range(100, -1, -1):
        for cy in range(100, -1, -1):
            x, y, h = xyh[0]
            H = h + abs(x - cx) + abs(y - cy)
            if H <= 0:
                continue
            is_correct = True
            for x, y, h in xyh:
                if H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break
            if is_correct:
                print(cx, cy, H)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    for cx in range(101):
        for cy in range(101):
            x, y, h = xyh[0]
            H = h + abs(x - cx) + abs(y - cy)
            is_correct = True
            for x, y, h in xyh:
                if H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break
            if H <= 0:
                continue
            if is_correct:
                print(cx, cy, H)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    xyh = []
    for _ in range(N):
        xyh.append([int(x) for x in input().split()])

    for cx in range(101):
        for cy in range(101):
            x, y, h = xyh[0]
            H = h + abs(x - cx) + abs(y - cy)
            is_correct = True
            for x, y, h in xyh:
                if H != h + abs(x - cx) + abs(y - cy):
                    is_correct = False
                    break

            if is_correct:
                print(cx, cy, H)
                return



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    X,Y,H = [],[],[]
    for _ in range(n):
        x,y,h = map(int, input().split())
        X.append(x)
        Y.append(y)
        H.append(h)

    ans = 0
    candidate = []
    for j in range(101):
        for k in range(101):
            h_tmp = 0
            for i in range(n):
                h = H[i]+abs(X[i]-j)+abs(Y[i]-k)
                if i == 0:
                    h_tmp = h
                    continue
                if h != h_tmp:
                    break
                if i == n-1:
                    print(j,k,h_tmp)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

N = int(input())

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

for cx in range(101):
  for cy in range(101):
    needH = -1
    for (X, Y, H) in edges:
      tmp = abs(X - cx) + abs(Y - cy) + H
      if needH == -1:
        needH = tmp
      elif needH != tmp:
        needH = -2
        break

    if needH == -2:
      continue

    for (X, Y, H) in edges:
      if max(needH - abs(X - cx) - abs(Y - cy), 0) != H:
        break
    else:
      print(cx, cy, needH)
      exit()

Submission status: Wrong Answer

Solution code:

N = int(input())
C = []

for i in range(N):
  x, y, z = map(int, input().split())
  C.append((x, y, z))

for X in range(101):
  for Y in range(101):

    needH = -1
    for i in range(N):
      x, y, h = map(int, C[i])
      tmp = abs(x-X) + abs(y-Y) + h
      if needH == -1:
        needH = tmp
      elif needH != tmp:
        needH = -2
        break

    if needH == -2:
      continue
    
    for i in range(N):
      x, y, h = map(int, C[i])
      if h == 0: # 高さ0のときに矛盾がないか確認をしている
        if needH - (abs(x-X) + abs(y-Y)) > 0:
          break
    else:
      print(X, Y, needH)
      exit()

Submission status: Wrong Answer

Solution code:


N = int(input())

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

for cx in range(101):
  for cy in range(101):
    tmp = set()
    for (X, Y, H) in edges:
      ch = abs(X - cx) + abs(Y - cy) + H

    for (X, Y, H) in edges:
      if max(ch - abs(X - cx) - abs(Y - cy), 0) != H:
        break
    else:
      print(cx, cy, ch)
      exit()

Submission status: Wrong Answer

Solution code:


N = int(input())

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



for cx in range(101):
  for cy in range(101):
    tmp = set()
    for (X, Y, H) in edges:
      ch = abs(X - cx) + abs(Y - cy) + H

    for (X, Y, H) in edges:
      if ch - abs(X - cx) - abs(Y - cy) != H:
        break
    else:
      print(cx, cy, ch)
      exit()

Submission status: Wrong Answer

Solution code:


N = int(input())

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


ans = []

for cx in range(101):
  for cy in range(101):
    tmp = set()
    for (X, Y, H) in edges:
      tmp.add(abs(X - cx) + abs(Y - cy) + H)
    if len(tmp) == 1:
      ch = tmp.pop()
      ans.append((cx, cy, ch))

result = (-1, -1, -1)
for (cx, cy, ch) in ans:
  valid = True
  for (X, Y, H) in edges:
    if H != ch - abs(X - cx) - abs(Y - cy):
      valid = False

  if valid and ch >= result[2]:
    result = (cx, cy, ch)

print(*result)

Submission status: Wrong Answer

Solution code:


N = int(input())

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


ans = (-1,-1,-1)
for cx in range(101):
  for cy in range(101):
    tmp = set()
    for (X, Y, H) in edges:
      tmp.add(abs(X - cx) + abs(Y - cy) + H)
    if len(tmp) == 1:
      ch = tmp.pop()
      if ch > ans[2]:
        ans = (cx, cy, ch)

print(*ans)

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])
for cx in range(101):
    for cy in range(101):
        good = True
        h = xyh[0][2]+abs(cx-xyh[0][0])+abs(cy-xyh[0][1])
        for i in range(n):
            if xyh[i][2] != max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0):
                good = False
                break
        if good:
            print(cx, cy, h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y, H = [], [], []
for i in range(N):
  x, y, h = map(int,input().split())
  X.append(x)
  Y.append(y)
  H.append(h)
for cx in range(101):
  for cy in range(101):
    ans = True
    h = H[0]+abs(X[0]-cx)+abs(Y[0]-cy)
    for i in range(N):
      if H[i] != max(h-abs(X[i]-cx)-abs(Y[i]-cy), 0):
        ans = False
        break
    if ans:
      print(cx, cy, h)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y, H = [], [], []
for i in range(N):
  x, y, h = map(int,input().split())
  X.append(x)
  Y.append(y)
  H.append(h)
for cx in range(101):
  for cy in range(101):
    ans = True
    for i in range(N):
      h = max(H[i] + abs(X[i]-cx) + abs(Y[i]-cy),0)
      if i == 0:
        a = h
      else:
        if h != a:
          ans = False
          break
    if ans:
      print(cx, cy, a)
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
X, Y, H = [], [], []
for i in range(N):
  x, y, h = map(int,input().split())
  X.append(x)
  Y.append(y)
  H.append(h)
for cx in range(101):
  for cy in range(101):
    ans = True
    for i in range(N):
      h = H[i] + abs(X[i]-cx) + abs(Y[i]-cy)
      if h < 0:
        h = 0
      if i == 0:
        a = h
      else:
        if a != h:
          ans = False
          break
    if ans:
      print(cx, cy, a)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
bbn=1000000007
	
#+++++
		
def main():
	n = int(input())
	pl=101
	
	ff=[0]*pl
	for i  in range(pl):
		ff[i]=[0]*pl
	
	v=[]
	for i in range(n):
		x, y, h = map(int, input().split())
		v.append([x,y,h])
	
	tt=0
	for [xi, yi, hi] in v:
		for [xj, yj, hj] in v:
			if xi==xj and yi==yj:
				continue
			tt+=1
			for px in range(pl):
				for py in range(pl):
					ihp=hi+abs(px-xi)+abs(py-yi)
					jhp=hj+abs(px-xj)+abs(py-yj)
					#if px==100 and py ==0:
					#	print(ihp,jhp)
					if ihp==jhp:
						ff[px][py]+=1
	
	for i, vl in enumerate(ff):
		for j, va in enumerate(vl):
			if va == tt:
				[x,y,h]=v[0]
				rh=h+abs(x-i)+abs(y-j)
				print(i,j,rh)
				return 
	#print(ff)
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = [tuple(map(int, input().split())) for _ in range(N)]
for cx in range(101):
    for cy in range(101):
        H = -1
        for x, y, h in XYH:
            if h:
                if H == -1:
                    H = h + abs(x-cx)+abs(y-cy)
                else:
                    if H != h + abs(x-cx)+abs(y-cy):
                        break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c


# ピラミッドの中心は必ず0-100の中にある
# Hは1以上
# 与えられる情報だけで一意に定まる

# 中心座標をa,bと置いたとき、ある点x,yにおける高さは
# h(x,y; a,b)=max(H-|x-a|-|y-b|,0)である。
# ここで、真の高さとの誤差としてe(x,y;a,b)=|h(x,y;a,b) - h(x,y;Cx,Cy)|とすると。
# 任意のx,yでe=0となるa,bが答え。しかしHはわからないので0とする。
# そうすると任意のx,yでe(x,y;a,b)=constとなるa,bが答え。(ただしmaxの扱いが面倒なのでh==0は無視して処理を行う)
# またその定数constはHである

# 座標は10**4点。Nはたかだか100なので 最悪10**6回計算。間に合う。

import numpy as np
from itertools import product

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

if N == 1:
    print(x, y, h)
    exit()

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_eq_loss(X, Y, H, a, b):
    loss = np.abs(-np.abs(X - a) - np.abs(Y - b) - H)
    if (loss[-1] == loss).all():
        return True, loss[-1]
    else:
        return False, False


# def sum_loss(X, Y, H, a, b):
#     loss = np.abs(-np.abs(X - a) - np.abs(Y - b) - H)
#     return loss.sum()


for a, b in product(range(101), range(101)):
    flg, ansH = is_eq_loss(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

# for a, b in product(range(101), range(101)):
#     flg, ansH = is_eq_loss(X, Y, H, a, b)
#     if flg:
#         ans = (a, b, ansH)

print(*ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c


# ピラミッドの中心は必ず0-100の中にある
# Hは1以上
# 与えられる情報だけで一意に定まる

# 中心座標をa,bと置いたとき、ある点x,yにおける高さは
# h(x,y; a,b)=max(H-|x-a|-|y-b|,0)である。
# ここで、真の高さとの誤差としてe(x,y;a,b)=|h(x,y;a,b) - h(x,y;Cx,Cy)|とすると。
# 任意のx,yでe=0となるa,bが答え。しかしHはわからないので0とする。
# そうすると任意のx,yでe(x,y;a,b)=constとなるa,bが答え。(ただしmaxの扱いが面倒なのでh==0は無視して処理を行う)
# またその定数constはHである

# 座標は10**4点。Nはたかだか100なので 最悪10**6回計算。間に合う。

import numpy as np
from itertools import product

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

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_eq_loss(X, Y, H, a, b):
    loss = np.abs(-np.abs(X - a) - np.abs(Y - b) - H)
    if (loss[-1] == loss).all():
        return True, loss[-1]
    else:
        return False, False


for a, b in product(range(101), range(101)):
    flg, ansH = is_eq_loss(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

print(*ans)