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())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
for i in range(101):
    for j in range(101):
        c = 0
        x = map_list[0][0]
        y = map_list[0][1]
        h = map_list[0][2]
        h = max(int(h), 0)
        val = abs(i - int(x)) + abs(j - int(y)) + int(h)
        #print('base:',i, j, val)
        
        for data in map_list[1:]:
            x, y, h = data
            h = max(int(h), 0)
            
            if int(h) != max(H - abs(i - int(x)) - abs(j - int(y)), 0):
                break
            c += 1
        if c >= n - 1:
            found_data = True
            break
    if found_data:
        break

h = abs(i - int(x)) + abs(j - int(y)) + int(h)
print(i, j, h)


n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    for i in range(101):
        if map_list[i][2] > 0:
            x = int(map_list[i][0])
            y = int(map_list[i][1])
            h = int(map_list[i][2])
            break
        else:
            continue

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for data in map_list:
                xx, yy, hh = map(int, data)
                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)



n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

found_data = False
x = int(map_list[-1][0])
y = int(map_list[-1][1])
h = int(map_list[-1][2])

for i in range(101):
    for j in range(101):
        cont_check = True
        H = abs(i - x) + abs(j - y) + h
        
        for data in map_list:
            xx, yy, hh = map(int, data)
            if h != max(H - abs(i - x) - abs(j - y), 0):
                cont_check = False
                break
        if cont_check:
            break
    if cont_check:
        break

print(i, j, H)

n = int(input())
map_list = []
for _ in range(n):
    map_list.append(input().split())

def function():
    for i in range(101):
        if int(map_list[i][2]) > 0:
            x = int(map_list[i][0])
            y = int(map_list[i][1])
            h = int(map_list[i][2])
            break
        else:
            continue

    for i in range(101):
        for j in range(101):
            cont_check = True
            H = abs(x - i) + abs(y - j) + h
            
            for data in map_list:
                xx, yy, hh = map(int, data)
                if hh != max(H - abs(xx - i) - abs(yy - j), 0):
                    cont_check = False
                    break
            if cont_check:
                return i, j, H

i, j, H = function()
print(i, j, H)



Verdicts: Runtime Error

Runtime Error

Wrong Answer

Accepted