Problem: 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.

Submission attempts (in order):
 n = int(input())
hint = []
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([a, b, c])
frag2 = False
for i in range(101):
    for j in range(101):
        ans_h = -1
        frag = False
        for k in range(n):
            a, b, c = hint[k][0], hint[k][1], hint[k][2]
            if c != 0:
                if ans_h == -1:
                    ans_h = abs(a-i)+abs(b-j)+c
                else:
                    if ans_h != abs(a-i)+abs(b-j)+c:
                        frag = True
                        break
                    else:
                        continue
        if not frag:
            answer = [i, j, ans_h]
            frag2 = True
            break
    if frag2:
        break

for i in range(3):
    print(answer[i], end=" ")

import sys

n = int(input())
hint = []
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([a, b, c])
frag2 = False
for i in range(101):
    for j in range(101):
        ans_h = -1
        frag = False
        for k in range(n):
            a, b, c = hint[k][0], hint[k][1], hint[k][2]
            if c != 0:
                if ans_h == -1:
                    ans_h = abs(a-i)+abs(b-j)+c
                else:
                    if ans_h != abs(a-i)+abs(b-j)+c:
                        frag = True
                        break
                    else:
                        continue
        if not frag:
            answer = [i, j, ans_h]
            for i in range(3):
                print(answer[i], end=" ")
            sys.exit()



n = int(input())
hint = []
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([a, b, c])
frag2 = False
for i in range(101):
    for j in range(101):
        ans_h = -1
        frag = False
        for k in range(n):
            a, b, c = hint[k][0], hint[k][1], hint[k][2]
            if c != 0:
                if ans_h == -1:
                    ans_h = abs(a-i)+abs(b-j)+c
                else:
                    if ans_h != abs(a-i)+abs(b-j)+c:
                        frag = True
                        break
                    else:
                        continue
        if not frag:
            answer = [i, j, ans_h]
            frag2 = True
            break
    if frag2:
        break

for i in range(3):
    print(answer[i], end=" ")

import sys

def height(a, b, c, d, e):
    return abs(a-d)+abs(b-e)+c

n = int(input())
hint = []
q = 0
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append(c, a, b)
hint.sort(reverse=True)

for i in range(101):
    for j in range(101):
        frag = True
        H = height(hint[0][1], hint[0][2], hint[0][0] i, j)
        for h in hint[1:]:
            if height(h[1], h[2], h[0], i, j) != H:
                frag = False
                break
        if frag:
            print(i, j, H)
            sys.exit()
        


import sys

def height(a, b, c, d, e):
    return abs(a-d)+abs(b-e)+c

n = int(input())
hint = []
q = 0
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([c, a, b])
hint.sort(reverse=True)

for i in range(101):
    for j in range(101):
        frag = True
        H = height(hint[0][1], hint[0][2], hint[0][0], i, j)
        for h in hint[1:]:
            if h[0] != max(-abs(h[1]-i)-abs(h[2]-j)+H,0):
                frag = False
                break
        if frag:
            print(i, j, H)
            sys.exit()

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted