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

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []
first = True

for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        if h == 0:
            continue
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        if h == 0:
            continue
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        xy = tmpxy
        H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

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

H = []
xy = []
first = True
for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            tm = h0-abs(x-xy0[0])-abs(y-xy0[1])
            if h == max(0, tm):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH


print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []

for i, xyh in enumerate(in_list):
    x, y, h = xyh[0], xyh[1], xyh[2]
    if i == 0:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []
first = True

for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        xy = tmpxy
        H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

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

H = []
xy = []

for i, xyh in enumerate(in_list):
    x, y, h = xyh[0], xyh[1], xyh[2]

    if i == 0:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            tm = h0-abs(x-xy0[0])-abs(y-xy0[1])
            if h == max(0, tm):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        H = tmpH
        xy = tmpxy

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

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

H = []
xy = []
first = True
for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH


print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

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

H = []
xy = []
first = True
for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = max(h + abs(x-x1) + abs(y-y1), 0)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            tm = h0-abs(x-xy0[0])-abs(y-xy0[1])
            if h == max(0, tm):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH


print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []
first = True

for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        if h == 0:
            continue
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        xy = tmpxy
        H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

in_list = []
for i in range(N):
    xyh = list(map(int, input().split()))
    if xyh[2] != 0:
        in_list.append(xyh)

H = []
xy = []
first = True
for xyh in in_list:
    x, y, h = xyh[0], xyh[1], xyh[2]
    if first:
        for x1 in range(0, 101):
            for y1 in range(0, 101):
                H1 = h + abs(x-x1) + abs(y-y1)
                H.append(H1)
                xy.append([x1, y1])
        first = False
    else:
        tmpH = []
        tmpxy = []
        for xy0, h0 in zip(xy, H):
            if h == max(h0-abs(x-xy0[0])-abs(y-xy0[1]), 0):
                tmpH.append(h0)
                tmpxy.append([xy0[0], xy0[1]])
        if len(tmpH) != 0:
            xy = tmpxy
            H = tmpH

print(xy[0][0], end=" ")
print(xy[0][1], end=" ")
print(H[0], end=" ")

N = int(input())

in_list = []
x0, y0, h0 = 0, 0, 0
for i in range(N):
    xyh = list(map(int, input().split()))
    in_list.append(xyh)

for i in range(N):
    if in_list[i][2]:
        x0, y0, h0 = in_list[i]

for Cx in range(0, 101):
    for Cy in range(0, 101):
        for xyh in in_list:
            x, y, h = xyh[0], xyh[1], xyh[2]
            H = h0 + abs(x0-Cx) + abs(y0-Cy)
            if h != max(H-abs(x-Cx)-abs(y-Cy), 0):
                break
        else:
            print(Cx, Cy, H)



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted