Problem:


Score: 300 points

Problem Statement

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.  

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:  

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.  

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.  

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.  



Sample input:
4
2 3 5
2 1 5
1 2 5
3 2 5


Sample output:
2 2 6

Submission status: Wrong Answer

Solution code:
n = int(input())
m = [list(map(int, input().split())) for i in range(n)]

for x in range(101):
  for y in range(101):
    res = [0]*n
    res1 = 0
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] = h
        res1 = h
        t += 1
    if res.count(res1)==t:
      print(x, y, res1)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
m = [list(map(int, input().split())) for i in range(n)]

for x in range(101):
  for y in range(101):
    res = [0]*n
    t = 0
    for z in range(n):
      if m[z][2]!=0:
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] = h
        t += 1
    if res.count(res[0])==t:
      print(x, y, res[0])
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
m = [list(map(int, input().split())) for i in range(n)]

for x in range(101):
  for y in range(101):
    res = [0]*n
    for z in range(n):
        h = m[z][2]+abs(x-m[z][0])+abs(y-m[z][1])
        res[z] = h
    if res.count(res[0])==n:
      print(x, y, res[0])
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
m = [list(map(int, input().split())) for i in range(n)]

h = 0
for i in range(n):
  h += m[i][2]
h = round(h/n)+1

for x in range(101):
  for y in range(101):
    t = 0
    for k in range(n):
      if m[k][2] == h-abs(x-m[k][0])-abs(y-m[k][1]):
        t += 1
      else:
        break
    if t == n:
      print(x, y, h)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def check(pos):
    # 2つ目以降の条件について検討
    flg = True
    for x, y, h in xyh[1:]:
        if h != max(pos[2] - abs(x - pos[0]) - abs(y - pos[1]), 0):
            flg = False
            break
    return flg


def main():
    # Aは頂点候補のリスト
    # 1つ目の条件から高さを求める
    A = []
    x, y, h = xyh[0]
    for i in range(101):
        for j in range(101):
            H = h + abs(x - i) + abs(y - j)
            A.append([i, j, H])
    # 全ての頂点候補について条件に合うかチェック
    for pos in A:
        if check(pos):
            break
    top = pos
    return top


n = int(readline())
xyh = [list(map(int, readline().split())) for _ in range(n)]

top = main()
print(*top)

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]

for i in range(0,101):
    for j in range(0,101):
        minh=10**9
        
        for k in range(1,n):

            
            if xy[k][2]!=0:
                temp=abs(xy[k][0]-i)+abs(xy[k][1]-j)+xy[k][2]-(abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j)+xy[k-1][2])
                
                if temp!=0:
                    break
            else:
                minh=min(minh,abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j))
                minh=min(minh,abs(xy[k][0]-i)+abs(xy[k][1]-j))
            

            
            
            


        else:
            if xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)>=1 and minh>=(xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)):
                print("{} {} {}".format(i,j,xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)))
                
                exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]

for i in range(0,101):
    for j in range(0,101):
        minh=10**9
        
        for k in range(1,n):

            
            if xy[k][2]!=0:
                temp=abs(xy[k][0]-i)+abs(xy[k][1]-j)+xy[k][2]-(abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j)+xy[k-1][2])
                
                if temp!=0:
                    break
            else:
                minh=min(minh,abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j))
                minh=min(minh,abs(xy[k][0]-i)+abs(xy[k][1]-j))
            

            
            
            


        else:
            if xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)>=1 and minh>=(xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)):
                print("{} {} {}".format(i,j,xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)))
                print(minh)
                exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int, input().split())) for _ in range(n)]

for cx in range(0,101):
    for cy in range(0,101):
        flag=True
        h=abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]
        for i in range(n):
            if max(h-abs(cx-xyh[i][0])-abs(cy-xyh[i][1]), 0)!=xyh[i][2]:
                flag=False
        if flag:
            print(cx,cy,h)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=sorted([list(map(int, input().split())) for _ in range(n)], key=lambda x: -x[2])

for cx in range(0,101):
    for cy in range(0,101):
        flag=True
        h=abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]
        for i in range(n):
            if (abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2])!=h:
                flag=False
        if flag:
            print(cx,cy,h)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int, input().split())) for _ in range(n)]

for cx in range(0,101):
    for cy in range(0,101):
        flag=True
        h=max(abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2],0)
        for i in range(n):
            if abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2]!=h:
                flag=False
        if flag:
            print(cx,cy,h)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int, input().split())) for _ in range(n)]

for cx in range(0,101):
    for cy in range(0,101):
        flag=True
        h=abs(cx-xyh[0][0])+abs(cy-xyh[0][1])+xyh[0][2]
        for i in range(n):
            if abs(cx-xyh[i][0])+abs(cy-xyh[i][1])+xyh[i][2]!=h:
                flag=False
        if flag:
            print(cx,cy,h)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if flag==False:
    break
    
  for cy in range(0,101):
    ansh = 0
    for pira in xyh:
      if ansh==0:
        ansh=pira[2]+(abs(cx-pira[0])+abs(cy-pira[1]))
        ans[0]=[cx,cy,ansh]
        
      elif len(ans[0])>0 and max(ansh -(abs(cx-pira[0])+abs(cy-pira[1])), 0) != pira[2]:
        ans[0]=[]
    if len(ans[0])>0:
      flag=False
      break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if flag==False:
    break
    
  for cy in range(0,101):
    ansh = -1
    flag=True
    for pira in xyh:
      if ansh==-1 or ansh==0:
        ansh=pira[2]+(abs(cx-pira[0])+abs(cy-pira[1]))
        ans[0]=[cx,cy,ansh]
        
      elif len(ans[0])>0 and max(ansh -(abs(cx-pira[0])+abs(cy-pira[1])), 0) != pira[2]:
        ans[0]=[]
    if len(ans[0])>0:
      flag=False
      break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if len(ans[0])>0:
    break
  for cy in range(0,101):
    if len(ans[0])>0:
      break
    ansh = -1
    for pira in xyh:
      if ansh==-1 or ansh==0:
        ansh=pira[2]+(abs(cx-pira[0])+abs(cy-pira[1]))
        ans[0]=[cx,cy,ansh]
      elif len(ans[0])>0 and max(ansh -(abs(cx-pira[0])+abs(cy-pira[1])), 0) != pira[2]:
        ans[0]=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if len(ans[0])>0:
    break
  for cy in range(0,101):
    if len(ans[0])>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      if ansh==-1 or ansh==0:
        ansh=pira[2]-(abs(cx-pira[0])+abs(cy-pira[1]))
      elif len(ans[0])>0 and max(ansh -(abs(cx-pira[0])+abs(cy-pira[1])), 0) != pira[2]:
        ans[0]=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if len(ans[0])>0:
    break
  for cy in range(0,101):
    if len(ans[0])>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if (flag or ansh==-1) and pira[2] == 0:
        if pira[2]+abs(cx-pira[0])+abs(cy-pira[1])==0:
          ansh = 0
          flag=False
        else:
          ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
          flag=True
        ans[0]=[cx,cy,ansh]
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans[0]=[cx,cy,ansh]
        flag=False
      elif len(ans[0])>0 and max(ansh -(abs(cx-pira[0])+abs(cy-pira[1])), 0) != pira[2]:
        ans[0]=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if len(ans[0])>0:
    break
  for cy in range(0,101):
    if len(ans[0])>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if (flag or ansh==-1) and pira[2] == 0:
        if pira[2]+abs(cx-pira[0])+abs(cy-pira[1])==0:
          ansh = 0
          flag=False
        else:
          ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
          flag=True
        ans[0]=[cx,cy,ansh]
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans[0]=[cx,cy,ansh]
        flag=False
        
      elif len(ans[0])>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans[0]=[]
        break
        
      elif len(ans[0])>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans[0]=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if len(ans[0])>0:
    break
  for cy in range(0,101):
    if len(ans[0])>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if (flag or ansh==-1) and pira[2] == 0 and abs(cx-pira[0])+abs(cy-pira[1])>=0:
        ansh = 0
        ans[0]=[cx,cy,ansh]
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans[0]=[cx,cy,ansh]
        flag=False
        
      elif len(ans[0])>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans[0]=[]
        break
        
      elif len(ans[0])>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans[0]=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[[]]
flag=True
for cx in range(0,101):
  if len(ans[0])>0:
    break
  for cy in range(0,101):
    if len(ans[0])>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if (flag or ansh==-1) and pira[2] == 0 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = 0
        ans[0]=[cx,cy,ansh]
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans[0]=[cx,cy,ansh]
        flag=False
        
      elif len(ans[0])>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans[0]=[]
        break
        
      elif len(ans[0])>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans[0]=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[]
flag=True
for cx in range(0,101):
  if len(ans)>0:
    break
  for cy in range(0,101):
    if len(ans)>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if (flag or ansh==-1) and pira[2] == 0 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        if len(ans)>0:
          ans=[]
        ans.append([cx,cy,ansh])
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        if len(ans)>0:
          ans=[]
        ans.append([cx,cy,ansh])
        flag=False
        
      elif len(ans)>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans=[]
        break
        
      elif len(ans)>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[]
flag=True
for cx in range(0,101):
  if len(ans)>0:
    break
  for cy in range(0,101):
    if len(ans)>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if (flag or ansh==-1) and pira[2] == 0 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        if len(ans)>0:
          ans=[]
        ans.append([cx,cy,ansh])
        flag=False
        
      elif len(ans)>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans=[]
        break
        
      elif len(ans)>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[]
flag=True
for cx in range(0,101):
  if len(ans)>0:
    break
  for cy in range(0,101):
    if len(ans)>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if (flag or ansh==-1) and pira[2] == 0 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
        flag=False
        
      elif len(ans)>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans=[]
        break
        
      elif len(ans)>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[]
flag=True
for cx in range(0,101):
  if len(ans)>0:
    break
  for cy in range(0,101):
    if len(ans)>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if flag and pira[2] == 0 and ansh==-1 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
      
      elif (flag or ansh == -1) and pira[2] > 0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
        flag=False
        
      elif len(ans)>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans=[]
        break
        
      elif len(ans)>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[]
flag=True
for cx in range(0,101):
  if len(ans)>0:
    break
  for cy in range(0,101):
    if len(ans)>0:
      break
    ansh = -1
    flag=True
    for pira in xyh:
      
      if flag and pira[2] == 0 and ansh==-1 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
      
      elif flag and pira[2] > 0 and ansh == -1:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
        flag=False
        
      elif len(ans)>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans=[]
        break
        
      elif len(ans)>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[]
for cx in range(0,101):
  if len(ans)>0:
    break
  for cy in range(0,101):
    if len(ans)>0:
      break
    ansh = -1
    for pira in xyh:
      
      if pira[2] == 0 and ansh==-1 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
      
      elif pira[2] > 0 and ansh == -1:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
        
      elif len(ans)>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans=[]
        break
        
      elif len(ans)>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh = [list(map(int,input().split())) for i in range(n)]

ansh=-1
ans=[]
for cx in range(0,101):
  if len(ans)>0:
    break
  for cy in range(0,101):
    if len(ans)>0:
      break
    ansh = -1
    for pira in xyh:
      
      if pira[2] == 0 and pira[2]+abs(cx-pira[0])+abs(cy-pira[1])<=0:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
      
      elif pira[2] > 0 and ansh == -1:
        ansh = pira[2]+abs(cx-pira[0])+abs(cy-pira[1])
        ans.append([cx,cy,ansh])
        
      elif len(ans)>0 and pira[2] > 0 and ansh !=pira[2]+abs(cx-pira[0])+abs(cy-pira[1]):
        ans=[]
        break
        
      elif len(ans)>0 and pira[2]==0 and ansh-abs(cx-pira[0])-abs(cy-pira[1])>0:
        ans=[]
        break
print(*ans[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]

for i in range(0,101):
    for j in range(0,101):
        minh=10**9
        
        for k in range(1,n):

            
            
            temp=abs(xy[k][0]-i)+abs(xy[k][1]-j)+xy[k][2]-(abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j)+xy[k-1][2])
            minh=min(minh,abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j))   
            if temp!=0:
                break
            
            
            


        else:
            if xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)>=1 and xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)<=minh:
                print("{} {} {}".format(i,j,xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)))
                exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]

for i in range(0,101):
    for j in range(0,101):
        
        for k in range(1,n):

            
            if xy[k-1][2]!=0:
                temp=abs(xy[k][0]-i)+abs(xy[k][1]-j)+xy[k][2]-(abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j)+xy[k-1][2])
                if temp!=0:
                    break
        else:
            if xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)>=1:
                print("{} {} {}".format(i,j,xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)))
                exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xy=[list(map(int,input().split())) for _ in range(n)]

for i in range(0,101):
    for j in range(0,101):
        
        for k in range(1,n):

            
            if xy[k-1][2]!=1:
                temp=abs(xy[k][0]-i)+abs(xy[k][1]-j)+xy[k][2]-(abs(xy[k-1][0]-i)+abs(xy[k-1][1]-j)+xy[k-1][2])
                if temp!=0:
                    break
        else:
            print("{} {} {}".format(i,j,xy[0][2]+abs(xy[0][0]-i)+abs(xy[0][1]-j)))
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xxx=[list(map(int,input().split())) for i in range(n)]
xxx.sort(key=lambda x:x[2])

for cx in range(101):
  for cy in range(101):
      H=xxx[-1][2]+abs(cx-xxx[-1][0])+abs(cy-xxx[-1][1])
      judge=True
      for i in range(n):
        if max(abs(cx-xxx[i][0])+abs(cy-xxx[i][1])+xxx[i][2],0)!=H:
          judge=False
        
      if judge==True:
        print(cx,cy,H)
        exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]
xx=[]
for i in range(n):
  xx.append(x[i][2])

for cx in range(101):
  for cy in range(101):
    for H in range(max(1,min(xx)),max(xx)+200):

      judge=True
      for i in range(n):
        if max(abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2],0)!=H:
          judge=False
        
      if judge==True:
        print(cx,cy,H)
        exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(101):
  for cy in range(101):
    cnt=0
    while True:
      H=abs(cx-x[cnt][0])+abs(cy-x[cnt][1])+x[cnt][2]
      if H>=1:
        break
      cnt+=1

    judge=True
    for i in range(n):
      if max(abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2],0)!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(101):
  for cy in range(101):
    cnt=0
    while True:
      H=abs(cx-x[cnt][0])+abs(cy-x[cnt][1])+x[cnt][2]
      if H>=1:
        break
      cnt+=1

    judge=True
    for i in range(n):
      if abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2]!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(101):
  for cy in range(101):
    while True:
      H=abs(cx-x[0][0])+abs(cy-x[0][1])+x[0][2]
      if H>=1:
        break

    judge=True
    for i in range(n):
      if abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2]!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(101):
  for cy in range(101):
    H=abs(cx-x[0][0])+abs(cy-x[0][1])+x[0][2]
    if H<=0:
      continue
    judge=True
    for i in range(1,n):
      if abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2]!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(101):
  for cy in range(101):
    H=abs(cx-x[0][0])+abs(cy-x[0][1])+x[0][2]
    judge=True
    for i in range(1,n):
      if abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2]!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(101):
  for cy in range(101):
    H=abs(cx-x[0][0])+abs(cy-x[0][1])+x[0][2]
    if H<0:
      continue
    judge=True
    for i in range(1,n):
      if abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2]!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(101):
  for cy in range(101):
    H=abs(cx-x[0][0])+abs(cy-x[0][1])+x[0][2]
    judge=True
    for i in range(1,n):
      if abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2]!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n)]

for cx in range(0,100):
  for cy in range(0,100):
    H=abs(cx-x[0][0])+abs(cy-x[0][1])+x[0][2]
    judge=True
    for i in range(1,n):
      if abs(cx-x[i][0])+abs(cy-x[i][1])+x[i][2]!=H:
        judge=False
        
    if judge==True:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())  #空白あり

N = I()
xyh = [tuple(MI()) for i in range(N)]

for i in range(101):  # ピラミッドの中心座標のx座標
    for j in range(101):  # ピラミッドの中心座標のy座標
        x,y,h = xyh[0]
        H = h + abs(x-i) + abs(y-j)
        for k in range(1,N):
            x,y,h = xyh[k]
            if h != H - abs(x-i) - abs(y-j):
                break
        else:
            print(i,j,H)
            exit()

Submission status: Wrong Answer

Solution code:
# import itertools
# import math
# import sys
# import numpy as np

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# H, W, K = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# S = input()

# d = sorted(d.items(), key=lambda x:x[0])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

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

ans_x = 0
ans_y = 0
ans_h = 0
for i in range(101):
    for j in range(101):
        H = -1
        for l in data:
            _ = l[2] + abs(l[0] - i) + abs(l[1] - j)
            if H == -1:
                H = _
            elif H != _:
                break
        else:
            ans_x = i
            ans_y = j
            ans_h = H

print(ans_x, ans_y, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]

for i in range(0,101):
    for j in range(0,101):
        hlist = []
        for k in range(n):
            if xyh[k][2]>0:
                hlist += [xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1])]
        if len(set(hlist)) == 1:
            print(i,j,hlist[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]

for i in range(0,101):
    for j in range(0,101):
        hlist = []
        for k in range(n):
            if xyh[k][2]>0:
                hlist += [xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1])]
        if len(set(hlist)) == 1 and hlist:
            print(i,j,hlist[0])

Submission status: Wrong Answer

Solution code:
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    n = ii()
    x = [0]*n
    y = [0]*n
    h = [0]*n
    for i in range(n):
        x[i], y[i], h[i] = mi()
    for cx in range(101):
        for cy in range(101):
            flag = True
            H = abs(cx-x[0])+abs(cy-y[0])+h[0]
            for i in range(1, n):
                tmp = abs(cx-x[i])+abs(cy-y[i])+h[i]
                flag &= (H==tmp)
                if not flag:
                    break
            if flag:
                print(cx, cy, H)
                return
            
            
        
        




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[]
aa=[]
for i in range(n):
     z.append(list(map(int,input().split())))
for cx in range(101):
    for cy in range(101):
        ans=set()
        for i in range(n):
            x,y,h=z[i][0],z[i][1],z[i][2]
            if h!=0:
                tmp=h+abs(x-cx)+abs(y-cy)
                ans.add(tmp)
        if len(ans)==1:
            ans=list(ans)
            aa.append((ans[0],cx,cy))
for a,cx,cy in aa:
    for i in range(n):
        x,y,h=z[i][0],z[i][1],z[i][2]
        if h!=max(a-abs(x-cx)-abs(y-cy),0):
                continue
        else:
            print(cx,cy,a)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[]
aa=[]
for i in range(n):
     z.append(list(map(int,input().split())))
for cx in range(101):
    for cy in range(101):
        ans=set()
        for i in range(n):
            x,y,h=z[i][0],z[i][1],z[i][2]
            if h!=0:
                tmp=h+abs(x-cx)+abs(y-cy)
                ans.add(tmp)
        if len(ans)==1:
            ans=list(ans)
            aa.append((ans[0],cx,cy))
for a,cx,cy in aa:
    for i in range(n):
        x,y,h=z[i][0],z[i][1],z[i][2]
        if h==0:
            if a-abs(x-cx)-abs(y-cy)>0:
                continue
    print(cx,cy,a)
    exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[]
aa=[]
for i in range(n):
     z.append(list(map(int,input().split())))
for cx in range(101):
    for cy in range(101):
        ans=set()
        for i in range(n):
            x,y,h=z[i][0],z[i][1],z[i][2]
            if h!=0:
                tmp=h+abs(x-cx)+abs(y-cy)
                ans.add(tmp)
        if len(ans)==1:
            ans=list(ans)
            aa.append((ans[0],cx,cy))
for a,cx,cy in aa:
    for i in range(n):
        x,y,h=z[i][0],z[i][1],z[i][2]
        if h==0:
            if a-abs(x-cx)-abs(y-cy)>0:
                break
    print(cx,cy,a)
    exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[]
for i in range(n):
     z.append(list(map(int,input().split())))
for cx in range(101):
    for cy in range(101):
        ans=set()
        for i in range(n):
            x,y,h=z[i][0],z[i][1],z[i][2]
            if h!=0:
                tmp=h+abs(x-cx)+abs(y-cy)
                ans.add(tmp)
        if len(ans)==1:
            print(cx,cy,*ans)
            exit()