TnT/Multi_CodeNet4Repair huggingface dataset:
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())
l = []
for i in range(n):
    l.append(list(map(int, input().split())))
for i in range(101):
    for j in range(101):
        H = l[0][2]+abs(i-l[0][0])+abs(j-l[0][1])
        for k in range(1,n):
            if not h==max(H-abs(i-l[k][0])-abs(j-l[k][1]), 0):
                break
            if k==n-1 and h>0:
                print(i,j,h)
                import sys
                sys.exit()

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh = sorted(xyh, key = lambda x: -x[2])
tx, ty, th = xyh[0]
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(tx - Cx) + abs(ty - Cy)
    if(all(h == max(H - abs(x - Cx) - abs(y - Cy), 0) for x,y,h in xyh)):
      print(Cx, Cy, H)
      exit()

Verdicts: Runtime Error

Accepted
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):
import numpy as np

def solve():
    n = int(input())
    val = []
    for i in range(min(n, 3)):
        x, y, h = map(int, input().split())
        val.append([x+y+h, -x+y+h, x-y+h, -x-y+h])
    base = [[1, 1, 1], [1, -1, 1], [1, 1, -1], [1, -1, -1]]
    ans = []
    for i, xx in enumerate(base):
        for j, yy in enumerate(base):
            for k, zz in enumerate(base):
                A = np.array([xx, yy, zz])
                Y = np.array([[val[0][i]], [val[1][j]], [val[2][k]]])
                try:
                    AA = np.linalg.inv(A)
                except np.linalg.LinAlgError as e:
                    if 'Singular matrix' in str(e):
                        continue
                    else:
                        raise
                ans.append(np.dot(AA, Y).tolist())
    print(int(*ans[5][1]), int(*ans[5][2]), int(*ans[5][0]))

solve()


def solve():
    n = int(input())
    X, Y, H = [], [], []
    for i in range(n):
        x, y, h = map(int, input().split())
        X.append(x), Y.append(y), H.append(h)

    for cx in range(101):
        for cy in range(101):
            res = []
            for x, y, h in zip(X, Y, H):
                if h == 0:
                    continue
                hh = h + abs(x - cx) + abs(y - cy)
                res.append(hh)
            if len(set(res)) == 1:
                flg = True
                for x, y, h in zip(X, Y, H):
                    if h != max(res[0] - abs(x - cx) - abs(y - cy), 0):
                        flg = False
                if flg:
                    print(cx, cy, res[0])

solve()

Verdicts: Runtime Error

Accepted
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())
x = [None]*N
y = [None]*N
h = [None]*N

for i in range(N):
    x[i],y[i],h[i] = map(int, input().split())

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        else:
            if H-abs(X-x[n])-abs(Y-y[n])>0:
            return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            H = height(X,Y,x[n],y[n],h[n])
            if check(x,y,h,X,Y,H) is True:
                print(X,Y,H)
                exit()


N = int(input())
x = [None]*N
y = [None]*N
h = [None]*N

for i in range(N):
    x[i],y[i],h[i] = map(int, input().split())

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        elif H-abs(X-x[n])-abs(Y-y[n])>0:
            return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            if h[n]>0:
                H = height(X,Y,x[n],y[n],h[n])
                if check(x,y,h,X,Y,H) is True:
                    print(X,Y,H)
                    exit()


Verdicts: Runtime Error

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

Copy
Copy
N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

import sys
N = int(input())
 
cor = [0] * N
 
for i in range(N):
    cor[i] = list(map(int, input().split()))

maximum_h = max([cor[i][2] for i in range(N)])
for x in range(101):
    for y in range(101):
        Height_list = [item[2] + abs(item[0] - x) + abs(item[1] - y) for item in cor if item[2] >= 1]
        print(Height_list)
        if len(list(set(Height_list))) == 1 and Height_list[0] >= maximum_h:
            print(x, y, Height_list[0])
            sys.exit()
            break

import sys
N = int(input())

cor = [0] * N

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

height = {}
maximum_h = max([cor[i][2] for i in range(N)])

for x in range(101):
    for y in range(101):
        Height_list = [item[2] + abs(item[0] - x) + abs(item[1] - y) for item in cor]
        if len(list(set(Height_list))) == 1 and Height_list[0] >= maximum_h and Height_list[0] >= 1:
            height[Height_list[0]] = [x, y]

for item in sorted(height.items(), key=lambda x: x[0], reverse=True):
    print(item[0], item[1][0], item[1][1])
    break
    sys.exit()

N = int(input())
xyh = [list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x:-x[2])
for cx in range(101):
    for cy in range(101):
        H = 0
        ok = True
        for i in range(N):
            x,y,h = xyh[i]
            if h != 0:
                if H == 0:
                    H = h+abs(cx-x)+abs(cy-y)
                else:
                    ok = H==h+abs(cx-x)+abs(cy-y)
            else:
                ok = abs(cx-x)+abs(cy-y)-H>=0
            if not ok:
                break
        if ok:
            break
    if ok:
        break
    
print('{} {} {}'.format(cx,cy,H))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
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):
import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[1][2]==0:
    print(ans[0][0],ans[0][1],ans[0][2])

for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if p==q:
            for k in range(2,N):
                if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
                elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<=p : break
                if k==N-1:
                    print(i,j,p)
                    sys.exit()

        if p==100: print(i,j,100)

N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[1],reverse=True)

ans=[]
for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])
        q=a[1][2]+abs(i-a[1][0])+abs(j-a[1][1])
        if N>2: r=a[2][2]+abs(i-a[2][0])+abs(j-a[2][1])

        if N==2 and p==q: ans.append([i,j,p])
        elif p==q and p==r: ans.append([i,j,p])

for i in range(3,N) :
    if len(ans)==1: break
    for x in ans:
        if x[2]!=a[i][2]+abs(x[0]-a[i][0])+abs(x[1]-a[i][1]):
            ans.remove(x)

print(ans[0][0],ans[0][1],ans[0][2])

import sys
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort(key=lambda x: x[2],reverse=True)
ans=[]

if a[0][2]==100:
    print(a[0][0],a[0][1],a[0][2])
    sys.exit()



for i in range(0,101):
    for j in range(0,101):
        p=a[0][2]+abs(i-a[0][0])+abs(j-a[0][1])

        for k in range(1,N):
            if a[k][2]>0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])!=p : break
            elif a[k][2]==0 and a[k][2]+abs(i-a[k][0])+abs(j-a[k][1])<p : break
            if k==N-1:
                print(i,j,p)
                sys.exit()

Verdicts: Runtime Error

Runtime Error

Accepted
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().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xtst=xi
        ytst=yi
        htst=hi
    xyh.append([xi,yi,hi])

for ny in range(101):
    for nx in range(101):
        nh=abs(xtst-nx)+abs(ytst-ny)+htst
        nh=max(nh,0)
        fl=True
        for lis in xyh:
                if lis[2]!=max(0,nh-abs(lis[0]-nx)+abs(lis[1]-ny)):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

N, M = map(int, input().strip().split())

for i in range(M//N,0,-1):
    if M%i==0:
        print(i)
        break

N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xtst=xi
        ytst=yi
        htst=hi
    xyh.append([xi,yi,hi])

for ny in range(101):
    for nx in range(101):
        nh=abs(xtst-nx)+abs(ytst-ny)+htst
        nh=max(nh,0)
        fl=True
        for lis in xyh:
                if lis[2]!=max(0,nh-abs(lis[0]-nx)+abs(lis[1]-ny)):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))

N=int(input().strip())
xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    xyh.append([xi,yi,hi])
    if hi>=1:
        xyhset=[xi,yi,hi]
        
for nx in range(101):
    for ny in range(101):
        He = xyhset[2]+abs(xyhset[0]-nx)+abs(xyhset[1]-ny)
        He=max(0,He)
        flag=True
        for i in range(N):
            h=He-abs(xyh[i][0]-nx)-abs(xyh[i][1]-ny)
            h=max(0,h)
            if xyh[i][2]!=h:
                flag=False
        if flag:
            ax=nx
            ay=ny
            ah=He

print("{} {} {}".format(ax,ay,ah))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
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())
p = list(list(map(int,input().split()))for _ in range(N))
for Cx in range(101):
    for Cy in range(101):
        H = -1
        for x,y,h in p:
            if H != abs(Cx-x) + abs(Cy-y) + h:
                if h == 0 and H < abs(Cx-x) + abs(Cy-y) + h:
                    continue
                elif H == -1:
                    if h == 0:
                        H = abs(Cx-x) + abs(Cy-y) + h
                else:
                    H = 0
                    break
        if H:
            print(Cx,Cy,H)
    


N = int(input())
p = list(list(map(int,input().split()))for _ in range(N))

for i in range(N):
    if p[i][2]:
        tmp = i
        break

for Cx in range(101):
    for Cy in range(101):
        H = p[tmp][2] + abs(Cx-p[tmp][0]) + abs(Cy-p[tmp][1])
        flag = True
        for x,y,h in p:
            if h != max(abs(Cx-x) + abs(Cy-y) + H , 0):
                flag = False
                break
        if flag:
            print(Cx,Cy,H)
    


N = int(input())
p = list(list(map(int,input().split()))for _ in range(N))

for i in range(N):
    if p[i][2]:
        tmp = i
        break

for Cx in range(101):
    for Cy in range(101):
        H = p[tmp][2] + abs(Cx-p[tmp][0]) + abs(Cy-p[tmp][1])
        flag = True
        for x,y,h in p:
            if h != max(H -abs(Cx-x) - abs(Cy-y), 0):
                flag = False
                break
        if flag:
            print(Cx,Cy,H)
    


Verdicts: Wrong Answer

Wrong Answer

Accepted
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 manhattan(i, j, x, y):
    
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    for i in range(101):
        for j in range(101):
            
            for k in range(N):
                if H[k] != 0:
                    x, y, h = X[k], Y[k], H[k]
                    hmax = h + manhattan(i, j, x, y)
                    break
            
            for k in range(N):
                x, y, h = X[k], Y[k], H[k]
                if hmax - h > manhattan(i, j, x, y):
                    break
            else:
                return i, j, hmax

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

def manhattan(i, j, x, y):
    
    return abs(i-x) + abs(j-y)

def main(N, X, Y, H):
    cand = [0, 0, 0]
    for i in range(101):
        for j in range(101):
            
            for k in range(N):
                if H[k] != 0:
                    x, y, h = X[k], Y[k], H[k]
                    hmax = h + manhattan(i, j, x, y)
                    break
            
            for k in range(N):
                x, y, h = X[k], Y[k], H[k]
                if h == 0:
                    if hmax > manhattan(i, j, x, y):
                        break
                else:
                    if hmax - h != manhattan(i, j, x, y):
                        break
            else:
                if cand[2] < hmax:
                    cand = [i, j, hmax]
    return cand

N = int(input())
X, Y, H = [], [], []
for _ in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
i, j, hmax = main(N, X, Y, H)
print(str(i) + ' ' + str(j) + ' ' + str(hmax))

Verdicts: Wrong Answer

Accepted
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())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
for cx in range(101):
    for cy in range(101):
        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            break

print(cx,cy,h)

N = int(input())
xyh = []

for i in range(N):
    x,y,h = map(int,input().split())
    xyh.append((x,y,h))
    if h > 0:
        ids = i
        
for cx in range(101):
    for cy in range(101):

        dct = 1
        h = xyh[ids][2] + abs(xyh[ids][0]-cx) + abs(xyh[ids][1]-cy)
        
        for i in range(N):
            if xyh[i][2] != max(h - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy),0):
                dct = 0
                break

        if dct:
            print(cx,cy,h)
            break

Verdicts: Wrong Answer

Accepted
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())
x=[]
y=[]
h=[]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c>0:
        g=i

for i in range(101):
    for j in range(101):
        t=h[g]+abs(x[0]-i)+abs(y[0]-j)
        f=1
        for k in range(0,n):
            if h[k]==max(0,t-abs(x[k]-i)-abs(y[k]-j)):
                f+=1
        if f==n:
            print(i,j,t)
            exit()
        


n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
    if c>0:
        g=i

for i in range(101):
    for j in range(101):
        t=h[g]+abs(x[g]-i)+abs(y[g]-j)
        f=0
        for k in range(0,n):
            if h[k]==max(0,t-abs(x[k]-i)-abs(y[k]-j)):
                f+=1
        if f==n:
            print(i,j,t)
            exit()
        


Verdicts: Wrong Answer

Accepted
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())
hs = [list(map(int, input().split())) for _ in range(n)]
hs.sort(key = lambda x: x[2], reverse = True)

#print(hs)
def main():
    for x in range(101):
        for y in range(101):
            height = hs[0][2] + abs(x-hs[0][0]) + abs(y-hs[0][1])
            for i in range(n):
                if hs[i][2] != 0:
                    if hs[i][2] == height - abs(x-hs[i][0]) - abs(y-hs[i][1]):
                        pass
                    else:
                        break
                if i == n-1:
                    return x,y,height
print(main())

n = int(input())
hs = [list(map(int, input().split())) for _ in range(n)]
hs.sort(key= lambda x: x[2], reverse = True)

def main():
    for x in range(101):
        for y in range(101):
            height = hs[0][2] + abs(x-hs[0][0]) + abs(y-hs[0][1])
            for i in range(1,n):
                if max(height-(abs(x-hs[i][0]) + abs(y-hs[i][1])),0)== hs[i][2]:
                    pass
                else:
                    break
                
                if i ==n-1:
                    print(x,y,height)
                    return x,y,height
main()

Verdicts: Wrong Answer

Accepted
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):
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    xs = list()
    ys = list()
    hs = list()

    # See:
    
    # https://img.atcoder.jp/abc112/editorial.pdf
    # https://www.youtube.com/watch?v=CURWJ1Dr44A
    for i in range(n):
        xi, yi, hi = map(int, input().split())
        xs.append(xi)
        ys.append(yi)
        hs.append(hi)

        if hi >= 1:
            pos = i

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            is_consistent = True
            candidate_height = abs(xs[pos] - cx) + abs(ys[pos] - cy) + hs[pos]

            for i in range(n):
                each_height = max(abs(xs[i] - cx) + abs(ys[i] - cy) + hs[i], 0)

                if candidate_height != each_height:
                    global is_consistent
                    is_consistent = False
                    break

            if is_consistent:
                print(cx, cy, candidate_height)
                exit()


if __name__ == '__main__':
    main()


# -*- coding: utf-8 -*-


def main():
    n = int(input())
    xs = list()
    ys = list()
    hs = list()

    # See:
    
    # https://img.atcoder.jp/abc112/editorial.pdf
    # https://www.youtube.com/watch?v=CURWJ1Dr44A
    for i in range(n):
        xi, yi, hi = map(int, input().split())
        xs.append(xi)
        ys.append(yi)
        hs.append(hi)

        # Record a position satisfying the task conditions.
        if hi > 0:
            pos = i

    for cx in range(100 + 1):
        for cy in range(100 + 1):
            is_consistent = True
            candidate_height = abs(xs[pos] - cx) + abs(ys[pos] - cy) + hs[pos]

            for i in range(n):
                each_height = max(candidate_height - abs(xs[i] - cx) - abs(ys[i] - cy), 0)

                if hs[i] != each_height:
                    is_consistent = False
                    break

            if is_consistent:
                print(cx, cy, candidate_height)
                exit()


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
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())
x_list=[]
y_list=[]
h_list=[]
hantei = 0
count=0
for i in range(N):
    a,b,c=map(int,input().split())
    x_list.append(a)
    y_list.append(b)
    h_list.append(c)
    if c>0: 
        judge_x = a
        judge_y = b
        judge_h = c
for x in range(101):
    for y in range(101):
        for j in range(N):
            if h_list[j] == 0 : count+=1
            elif judge_h + abs(x-judge_x) + abs(y-judge_y) != h_list[j] + abs(x-x_list[j]) + abs(y-y_list[j]):
                break
            else: count+=1
        if count == N-1:
            hantei=1
        if(hantei):break
    if(hantei): break

print(x,y,judge_h + abs(x-judge_x) + abs(y-judge_y))

N = int(input())
x_list=[]
y_list=[]
h_list=[]
hantei = 0
count=0
for i in range(N):
    a,b,c=map(int,input().split())
    x_list.append(a)
    y_list.append(b)
    h_list.append(c)
    if c>0: 
        judge_x = a
        judge_y = b
        judge_h = c

for x in range(101):
    for y in range(101):
        H = judge_h + abs(judge_x-x)+abs(judge_y-y)
        for j in range(N):
            if h_list[j] != max(0,H-abs(x-x_list[j])-abs(y-y_list[j])): break
            if j == N-1 : print(x,y,judge_h + abs(x-judge_x) + abs(y-judge_y))



Verdicts: Wrong Answer

Accepted
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())
x = []
y = []
h = []
for i in range(n):
    temp = [int(_) for _ in input().split(' ')]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])

for cx in range(101):
    for cy in range(101):
        ch = -1
        correctness = True
        for i in range(n):
            if ch > 0:
                if h[i] != max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0):
                    correctness = False
            if h[i] > 0:
                ch = h[i] + abs(cx - x[i]) + abs(cy - y[i])
        if correctness:
            print(ch)


n = int(input())
x = []
y = []
h = []
for i in range(n):
    temp = [int(_) for _ in input().split(' ')]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])

for cx in range(101):
    for cy in range(101):
        correctness = True
        for i in range(n):
            if h[i] > 0:
                ch = h[i] + abs(cx - x[i]) + abs(cy - y[i])
        for i in range(n):
            if h[i] != max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0):
                correctness = False
        if correctness:
            print('{0} {1} {2}'.format(cx, cy, ch))


Verdicts: Wrong Answer

Accepted
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())

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

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
flag = True
for cy in range(101):
    for cx in range(101):
        H = xyh[0][2] + abs(xyh[0][0] - cx) + abs(xyh[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh[i][0] - cx) - abs(xyh[i][1] - cy), 0)
            if h2 != xyh[i][2]:
                flag = False
        if flag:
            answer = [cx, cy, H]
            break

print(answer)

N = int(input())

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

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
for cy in range(0, 101):
    for cx in range(0, 101):
        H = xyh_sorted[0][2] + abs(xyh_sorted[0][0] - cx) + abs(xyh_sorted[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh_sorted[i][0] - cx) - abs(xyh_sorted[i][1] - cy), 0)
            if h2 != xyh_sorted[i][2]:
                flag = False
                break
        if flag:
            answer = [cx, cy, H]
            break
    if flag:
        break

answerString = str(answer[0]) + " " + str(answer[1]) + " " + str(answer[2])
print(answerString)

Verdicts: Wrong Answer

Accepted
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())
Inputs = [tuple(map(int, input().split())) for _ in range(N)]
H = 0
f = 0
for cx in range(101):
    for cy in range(101):
        n = 0
        while(n < N-1):
            x1, y1, h1 = Inputs[n]
            if h1 == 0:
                continue
            H1 = h1 + abs(x1-cx) + abs(y1-cy)
            x2, y2, h2 = Inputs[n+1]
            H2 = h2 + abs(x2-cx) + abs(y2-cy)
            if H1 != H2:
                f = 0
                break
            else:
                f = 1
                n += 1
        if f:
            print('aaaa')
            Cx = cx
            Cy = cy
            H = H1
            
                
print(Cx, Cy, H)

N = int(input())
coordinate = []
ans = -1
for _ in range(N):
    x, y, h = map(int, input().split())
    if h == 0:
        continue
    coordinate.append([x, y, h])
N = len(coordinate)
for cx in range(101):
    for cy in range(101):
        x1, y1, h1 = coordinate[0]
        H1 = h1 + abs(cx-x1) + abs(cy-y1)
        f = 1
        if N == 1:
            f = 2
            Cx = x1
            Cy = y1
            ans = h1
            break
        for n in range(1, N):
            x, y, h = coordinate[n]
            H = h + abs(cx-x) + abs(cy-y)
            if H == H1:
                f *= 1
            else:
                f *= 0
            if f and n == N-1:
                break
        if f == 1:
            Cx = cx
            Cy = cy
            ans = H1
            break
    if f:
        break
        
print(Cx, Cy, ans)

Verdicts: Runtime Error

Accepted
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())
X = [[int(i) for i in input().split()] for j in range(n)]

x_s = 0
x_e = 100
y_s = 0
y_e = 100

for x, y, z in X:
    for x2, y2, z2 in X:
        if (x, y) == (x2, y2):
            continue
        d = abs(x-x2) + abs(y-y2)
        if d == z - z2:            
            if x < x2:
                x_e = min(x_e, x) 
            elif x > x2:
                x_s = max(x_s, x) 
            if y < y2:
                y_e = min(y_e, y) 
            elif y > y2:
                y_s = max(y_s, y) 

        # else:
        #     if x < x2:
        #         x_s = max(x_s, x) 
        #     elif x > x2:
        #         x_e = min(x_e, x) 
        
        #         y_s = max(y_s, y) 
        
        #         y_e = min(y_e, y) 

        # if x_s >= x_e:
        #     print('xover', x, y, x2, y2)
        # if y_s >= y_e:
        #     print('yover', x, y, x2, y2)

x, y, z = X[0]
print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))

n = int(input())
X = [[int(i) for i in input().split()] for j in range(n)]

x_s = 0
x_e = 100
y_s = 0
y_e = 100

for x, y, z in X:
    for x2, y2, z2 in X:
        if (x, y) == (x2, y2):
            continue
        d = abs(x-x2) + abs(y-y2)
        if d == z - z2:            
            if x < x2:
                x_e = min(x_e, x) 
            elif x > x2:
                x_s = max(x_s, x) 
            if y < y2:
                y_e = min(y_e, y) 
            else y > y2:
                y_s = max(y_s, y) 

        else:
            if x < x2:
                x_s = max(x_s, x) 
            elif x > x2:
                x_e = min(x_e, x) 
            if y < y2:
                y_s = max(y_s, y) 
            elif y > y2:
                y_e = min(y_e, y) 

x, y, z = X[0]
print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))

n = int(input())
X = [[int(i) for i in input().split()] for j in range(n)]

X.sort(key=lambda x:x[2], reverse=True)

for h in range(101):
    for w in range(101):
        x, y, z = X[0]
        d = z + abs(x-w) + abs(y-h)
        for x, y, z in X:
            d2 = z + abs(x-w) + abs(y-h)
            if z == 0:
                if d2 < d:
                    break 
            elif d2 != d:
                break
        else:
            print(w, h, d)
            exit()


Verdicts: Wrong Answer

Runtime Error

Accepted
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())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]    
if(n>=3):
    for s in range(101):
        for t in range(101):
            if(abs(x[0]-s)-abs(x[1]-s)+abs(y[0]-t)-abs(y[1]-t)==h[1]-h[0]):
                if(abs(x[1]-s)-abs(x[2]-s)+abs(y[1]-t)-abs(y[2]-t)==h[2]-h[1]):
                    print(s,t,(abs(max_x-s)+abs(max_y-t)+max(h)))
else:
    print(max_x,max_y,max(h))

n=int(input())
x=[]
y=[]
h=[]
for p in range(n):
    temp=[int(u) for u in input().split()]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])
max_x=x[h.index(max(h))]
max_y=y[h.index(max(h))]   
print(max_x,max_y)
if(n>=3):
    for s in range(101):
        for t in range(101):
            if(abs(x[0]-s)-abs(x[1]-s)+abs(y[0]-t)-abs(y[1]-t)==h[1]-h[0]):
                if(abs(x[1]-s)-abs(x[2]-s)+abs(y[1]-t)-abs(y[2]-t)==h[2]-h[1]):
                    print(s,t,(abs(max_x-s)+abs(max_y-t)+max(h)))
else:
    print(max_x,max_y,max(h))

from sys import setrecursionlimit
from operator import itemgetter

def main():
    N = int(input())
    XYH = [list(map(int,input().split())) for _ in range(N)]
    XYH.sort(key = itemgetter(2),reverse = True)
    ansx = -1
    ansy = -1
    for cx in range(0,101):
        for cy in range(0,101):
            H = -1
            flag = True
            for x,y,h in XYH:
                if H >= 0:
                    if h != max(H - abs(x - cx) - abs(y - cy),0):
                        flag = False
                        break
                elif h > 0:
                    H =  h + abs(x - cx) + abs(y - cy)
            if flag:
                ansx = cx
                ansy = cy
                print(ansx,ansy,H)
                return
    return   

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
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):
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
XYH = [tuple(map(int,input().split())) for _ in range(N)]



XYH.sort(key=lambda x:x[2], reverse=True)

print(XYH)


for xi in range(101):
    for yi in range(101):
        flg = True
        x,y,h = XYH[0]
        
        hh0 = abs(xi-x) + abs(yi-y) + h
        for i in range(1,N):
            x,y,h = XYH[i]
            if h == 0:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 > hhi:
                    flg = False
                    break

            else:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 != hhi:
                    flg = False
                    break
        if flg:
            print(xi,yi,hh0)
            sys.exit()

# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
XYH = [tuple(map(int,input().split())) for _ in range(N)]



XYH.sort(key=lambda x:x[2], reverse=True)


for xi in range(101):
    for yi in range(101):
        flg = True
        x,y,h = XYH[0]
        
        hh0 = abs(xi-x) + abs(yi-y) + h
        for i in range(1,N):
            x,y,h = XYH[i]
            if h == 0:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 > hhi:
                    flg = False
                    break
            else:
                hhi = abs(xi-x) + abs(yi-y) + h
                if hh0 != hhi:
                    flg = False
                    break
        if flg:
            print(xi,yi,hh0)
            sys.exit()

Verdicts: Wrong Answer

Accepted
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):
import numpy as np

N = int(input())

point = [[int(item) for item in input().split()] for _ in range(N)]
point.sort(key=lambda x:x[2], reverse=True)

ans = np.zeros((101,101))

for i,p in enumerate(point):
  if i == 0:
    for j in range(101):
      for k in range(101):
        H = p[2] + abs(j - p[0]) + abs(k - p[1])
        ans[j,k] = H
        print(ans[j,k])
  else:
    for j in range(101):
      for k in range(101):
        if not ans[j,k] == 0:
          if ans[j,k] != p[2] + abs(j - p[0]) + abs(k - p[1]):
            ans[j,k] = 0
  if len(ans[ans!=0]) <= 1:
    break
x,y = np.where(ans!=0)
print(x[0],y[0],int(ans[x[0],y[0]]))

N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
C = [[0]*101 for i in range(101)]
P.sort(key=lambda x:x[2], reverse=True)
for X in range(101):
  for Y in range(101):
    tmp1 = -1
    flg = 0
    for i in range(N):
      x,y,h = P[i]
      if h != 0 and tmp1 == -1:
        tmp1 = abs(X-x)+abs(Y-y)+h
      elif tmp1 != -1:
        tmp2 = abs(X-x)+abs(Y-y)+h
        if h != 0: 
          if tmp1 != tmp2:
            flg = 1
            break
        if h == 0:
          if tmp1 > tmp2:
            flg = 1
            break
    if flg == 0:
      print(X, Y, tmp1)        
      exit()

Verdicts: Wrong Answer

Accepted