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())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

HC = 0
CX = 0
CY = 0
OKFLG = True

for i in range(101):
    for j in range(101):
        HC = int(XYHA[0][2]) + abs(int(XYHA[0][0]) - i) + abs(int(XYHA[0][1]) - j)
        OKFLG = True
        for k in range(1, N):
            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC != H:
                OKFLG = False
                break

        if OKFLG:
            CX = i
            XY = j
            break
    if OKFLG:
        break

print(CX,CY,HC)

N = int(input())

XYHA = []

for i in range(N):
    x,y,h = map(int,input().split())
    if h == 0:
        N -= 1
        continue
    XYHA.append([x,y,h])

for i in range(101):
    for j in range(101):
        HC = XYHA[0][2] + abs(XYHA[0][0] - i) + abs(XYHA[0][1] - j)

        for k in range(1, N):
            H = XYHA[k][2] + (XYHA[k][0] - i) + abs(XYHA[k][1] - j)

            if HC != H:
                break

            if k == N - 1:
                print(i,j,HC)
                exit()
print(0,0,0)

N = int(input())

XYHA = []

for i in range(N):
    XYHA.append(input().split(" "))

HC = 0
CX = 0
CY = 0
OKFLG = True

for i in range(101):
    for j in range(101):
        HC = 0
        OKFLG = True
        for k in range(N+1):
            XYH = XYHA[k]
            H = int(XYH[2]) + abs(int(XYH[0]) - i) + abs(int(XYH[1]) - j)
            if HC == 0:
                HC = H
                CX = i
                CY = j
                continue
            
            if HC == H:
                continue
            else:
                OKFLG = False
                break

        if OKFLG:
            break
    if OKFLG:
        break


print(CX,CY,HC)

N = int(input())
 
XYHA = []
 
for i in range(N):

    BBBB = input().split(" ")

    if BBBB[2] == '0':
        continue

    XYHA.append(BBBB)

HC = 0

for i in range(101):
    for j in range(101):
        OKFLG = True
        HC = 0
        for k in range(len(XYHA)):

            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j), 0)

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

N = int(input())
 
XYHA = []
 
for i in range(N):

    BBBB = input().split(" ")

    if BBBB[2] == '0':
        continue

    XYHA.append(BBBB)

HC = 0

for i in range(101):
    for j in range(101):
        OKFLG = True
        
        for k in range(len(XYHA)):

            H = int(XYHA[k][2]) + abs(int(XYHA[k][0]) - i) + abs(int(XYHA[k][1]) - j)

            if HC == 0:
                HC = H
                continue

            if HC != H:
                OKFLG = False
                break
        if OKFLG:
            print(i,j,HC)
            exit()

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

    if h == 0:
        continue
    XYHA.append([x,y,h])

if len(XYHA) == 1:
    print(XYHA[0][0],XYHA[0][1],XYHA[0][2])
    exit()

for i in range(101):
    for j in range(101):
        HC = max(XYHA[0][2] + abs(XYHA[0][0] - i) + abs(XYHA[0][1] - j), 0)
        for k in range(1, len(XYHA)):

            H = max(XYHA[k][2] + abs(XYHA[k][0] - i) + abs(XYHA[k][1] - j), 0)

            if HC != H:
                break
            elif k == len(XYHA) - 1:
                print(i,j,HC)
                exit()

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Accepted