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())
lis=[]
res=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    res.append([[0],i[1],l])
                    if len(res)>1:
                        m=res[1]
                    else: m=res
            else: break
print('{} {} {}'.format(m[0],m[1],m[2]))

N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    m=(i[0],i[1],l)
            else: break
print(m)

N=int(input())
lis=[]
res=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    res.append([[0],i[1],l])
                    if len(res)>1:
                        m=res[1]
                    else: m=res[0]
            else: break
print('{} {} {}'.format(m[0],m[1],m[2]))

N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if l==k or l=0:
            l=k
            n-=1
            if n==0:
                print(j[0],j[1],l)
                break
        else: break
    break

N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2],reverse=True)
for i in lis:
    n=N
    l=0
    for j in l2:
        k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
        if j[2]==0:
            if k>l:
                n-=1
            else:
                if l==k or l==0:
                    l=k
                    n-=1
                else: break
        else:
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted