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


def func():

    n = int(input())
    data = []
    for i in range(n):
        data.append(list(map(int,input().split())))

    for cx in range(101):
        for cy in range(101):
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                if h == 0:
                    for i in range(h1):
                        
                        #     continue
                        if not h1 in dict:
                            dict[h1] = 0
                        else:
                            dict[h1] += 1

                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()





def func():

    n = int(input())
    data = []
    for i in range(n):
        data.append(list(map(int,input().split())))

    for cx in range(101):
        for cy in range(101):
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                if h == 0:
                    for i in range(h1):
                        if not h1 in dict:
                            dict[h1] = 0
                        else:
                            dict[h1] += 1

                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()





def func():

    n = int(input())
    data = []
    for i in range(n):
        data.append(list(map(int,input().split())))

    for cx in range(101):
        for cy in range(101):
            for line in data:
                x = line[0]
                y = line[1]
                h = line[2]
                disx = x-cx
                disy = y-cy
                h1 = h + abs(disx) + abs(disy)
                if not h1 in dict:
                    dict[h1] = 0
                else:
                    dict[h1] += 1
                if h == 0:
                    for i in range(h1):
                        if i == 0:
                            continue
                        if not h1 in dict:
                            dict[h1] = 0
                        else:
                            dict[h1] += 1

                for key in dict.keys():
                    if dict[key] == n-1:
                        print(cx,end=" ")
                        print(cy,end=" ")
                        print(key)
                        return 0

func()





def func():

    n = int(input())
    data = []
    for i in range(n):
        data.append(list(map(int,input().split())))

    for cx in range(101):
        for cy in range(101):
            for line in data:
                if line[2] != 0:
                    x = line[0]
                    y = line[1]
                    h = line[2]
                    H_max = h + abs(cx - x) + abs(cy - y)
                    break
            flag = True
            for i in range(n):
                    x = data[i][0]
                    y = data[i][1]
                    h = data[i][2]
                    if h != 0:
                        if not H_max == h + abs(cx-x) + abs(cy-y):
                            flag = False
                            break
                    else:
                        if not H_max <=  abs(cx-x) + abs(cy-y):
                            flag = False
                            break
            if flag:
                print(cx,cy,H_max)
                return 0

func()



Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted