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=[list(map(int,input().split())) for i in range(n)]
lx=[];ly=[]
for p in range(n):
  lx.append(l[p][0]+l[p][1])
for q in range(n):
  ly.append(l[q][0]-l[q][1])
if n>=4:
  L=[l[lx.index(min(lx))],l[lx.index(max(lx))],l[ly.index(min(ly))],l[ly.index(max(ly))]]
  for x in range(101):
    for y in range(101):
      if abs(L[0][0]-x)+abs(L[0][1]-y)+L[0][2]==abs(L[1][0]-x)+abs(L[1][1]-y)+L[1][2]==abs(L[2][0]-x)+abs(L[2][1]-y)+L[2][2]==abs(L[3][0]-x)+abs(L[3][1]-y)+L[3][2]:
        print(x,y,abs(L[0][0]-x)+abs(L[0][1]-y)+L[0][2])
elif n>=3:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]==abs(l[2][0]-x)+abs(l[2][1]-y)+l[2][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
else:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for w in range(n):
   if l[w][2]>0:
     k=w
     break
for x in range(101):
  for y in range(101):
    a=max(l[z][2]-(abs(l[0][0]-x)-abs(l[0][1]-y)),0)
    c=0
    for z in range(1,n):
      if max(l[z][2]-(abs(l[0][0]-x)-abs(l[0][1]-y)),0)==a:c+=1
    if c==n-1:print(x,y,l[k][2]+(abs(l[k][0]-x)+abs(l[k][1]-y))

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
    w=0
    for z in range(1,n):
      if l[z][2]>0 and abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]!=a:
        w=0
        break
      else:w=1
      if w==1:
        print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
        break

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
    w=0
    for z in range(1,n):
      if l[z][2]>0 and abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]!=a:w=0
        break
      else:w=1
      if w==1:print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
  for y in range(101):
    a=abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]
    w=0
    for z in range(1,n):
      if l[z][2]>0 and abs(l[z][0]-x)+abs(l[z][1]-y)+l[z][2]!=a:w=0
        break
      else:w=1
      if w==1:print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])​

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for w in range(n):
   if l[w][2]>0:
     k=w
     break
for x in range(101):
  for y in range(101):
    a=l[k][2]+abs(l[k][0]-x)+abs(l[k][1]-y)
    c=0
    for z in range(n):
      if max((a-abs(l[z][0]-x)-abs(l[z][1]-y)),0)==l[z][2]:c+=1
      if c==n:
        print(x,y,a)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted