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())
cordinate = [list(map(int, input().split())) for i in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        for k in cordinate:
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                print(i, j, H, tmp)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1 and H > 0:
            print(i, j , H)
            exit()

N = int(input())
cordinate = [list(map(int, input().split())) for i in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for k in zero_height:
                if not max(k[2] + abs(k[0] - i) + abs(k[1] - j), 0):
                    break
                else:
                    print(i, j , H)
                    exit()

N = int(input())
cordinate = [list(map(int, input().split())) for i in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        H = -1
        check = 0
        zero_height = []
        for k in cordinate:
            if k[2] == 0:
                zero_height.append(k)
                continue
            if H == -1:
                check = 1
                H = k[2] + abs(k[0] - i) + abs(k[1] - j)
            else:
                tmp = k[2] + abs(k[0] - i) + abs(k[1] - j)
                if H == tmp:
                    check = 1
                    continue
                else:
                    check = -1
                    break
        if check == 1:
            for x in zero_height:
                if H > abs(x[0] - i) + abs(x[1] - j):
                    check = -1
                    break
            if check == 1:
                print(i, j , H)
                exit()

Verdicts: Wrong Answer

Wrong Answer

Accepted