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())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=max(h+abs(x-cx)+abs(y-cy),0)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            print(cx,cy,ans[cx][cy])

n=int(input())
ans=[[None]*101 for _ in range(101)] 
for i in range(n):
    x,y,h=map(int,input().split())
    for cx in range(101):
        for cy in range(101):
            height=h+abs(x-cx)+abs(y-cy)
            if h>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                if ans[cx][cy]!=None:
                    if ans[cx][cy]>abs(x-cx)+abs(y-cy):
                        ans[cx][cy]=-1
                else:
                    ans[x][y]=-1
        

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]!=None:
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

n=int(input())
ans=[[None]*101 for _ in range(101)] 
a=[[0]*3 for _ in range(n)] 

for i in range(n):
    a[i][0],a[i][1],a[i][2]=map(int,input().split())
a=sorted(a,key=lambda x: x[2],reverse=True)

for i in range(n):
    for cx in range(101):
        for cy in range(101):
            height=a[i][2]+abs(a[i][0]-cx)+abs(a[i][1]-cy)
            if a[i][2]>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                if ans[cx][cy]!=None:
                    if ans[cx][cy]>abs(a[i][0]-cx)+abs(a[i][1]-cy):
                        ans[cx][cy]=-1
                else:
                    ans[a[i][0]][a[i][1]]=-1
        

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]==None: 
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted