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:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi == 0:
      if (hi-abs(xi-cx)-abs(yi-cy))<=0:
        continue
      else:
        break
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    print(cx, cy, h)
    break

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi == 0:
      continue
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    ans = [cx, cy, h]
    break
print(ans[0], ans[1], ans[2])

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi == 0:
      continue
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    break
print(cx, cy, hhh[0])

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi == 0:
      continue
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    break   
print(cx, cy, h)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    temp = [int(i) for i in input().split()]
    if temp[2] != 0:
        l.append(temp)
for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)
            else:
                if(checker==point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])

for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        count = 0
        for point_info in l:
            if(point_info[2] != 0):
                if(checker == -1):
                    checker = point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)
                else:
                    if(checker==point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)):
                        pass
                    else:
                        exit_code = 1
                        break
            else:
                count += 1
                pass
        if(exit_code == 0 and count != N):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])

for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(point_info[2] != 0):
                if(checker == -1):
                    checker = point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)
                else:
                    if(checker==point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)):
                        pass
                    else:
                        exit_code = 1
                        break
            else:
                exit_code = 1
                break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])

for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(point_info[2] != 0):
                if(checker == -1):
                    checker = point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)
                else:
                    if(checker==point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)):
                        pass
                    else:
                        exit_code = 1
                        break
            else:
                break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])

for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(point_info[2] != 0):
                if(checker == -1):
                    checker = point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)
                else:
                    if(checker==point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)):
                        pass
                    else:
                        exit_code = 1
                        break
            else:
                pass
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])

for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)
            else:
                if(checker==max(point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY),0)):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])
for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = max([point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY),1])
            else:
                if(checker == max([point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY),1])):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])
for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = max([point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY),0])
            else:
                if(checker == max([point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY),0])):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])
for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = max([point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY),0])
            else:
                if(checker == point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,CY,checker)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])
for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)
            else:
                if(checker == point_info[2]+abs(point_info[0]-CX)+abs(point_info[1]-CY)):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,CY,checker)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
    l.append([int(i) for i in input().split()])
for CX in range(101):
    for CY in range(101):
        checker = -1
        exit_code = 0
        for point_info in l:
            if(checker == -1):
                checker = point_info[2]+(point_info[0]-CX)+(point_info[1]-CY)
            else:
                if(checker == point_info[2]+(point_info[0]-CX)+(point_info[1]-CY)):
                    pass
                else:
                    exit_code = 1
                    break
        if(exit_code == 0):
            print(CX,' ',CY,' ',checker)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
l1=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l1=l1[::-1]
  l.append(l1)      
l=sorted(l)
print(l)
for i in range(101):
  for j in range(101):
    b=True
    h=abs(i-l[-1][2])+abs(j-l[-1][1])+l[-1][0]
    for k in range(n-1):
      if max(h-abs(i-l[-2-k][2])-abs(j-l[-2-k][1]),0)!=l[-2-k][0]:
        b=False
    if b:
      print(i,j,h)
      break

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
l1=[]
for i in range(n):
  l1=list(map(int,input().split()))
  l1=l1[::-1]
  l.append(l1)      
l=sorted(l)
for i in range(101):
  for j in range(101):
    b=True
    h=abs(i-l[-1][2])+abs(j-l[-1][1])+l[-1][0]
    for i in range(n-1):
      if max(h-abs(i-l[-2-i][2])-abs(j-l[-2-i][1]),0)!=l[-2-i][0]:
        b=False
    if b:
      print(i,j,h)
      break

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split(' '))) for i in [0]*N]


ls = [[0]*101 for i in [0]*101]

cor = [[i,j] for i in range(101) for j in range(101)]

x,y,h = xyh[0]
for cx,cy in cor[:]:
	hx = abs(cx-x)
	hy = abs(cy-y)
	H = h+hx+hy
	ls[cx][cy] = H

for x,y,h in xyh[1:]:
	tls = [[0]*101 for i in [0]*101]
	for cx,cy in cor[:]:
		hx = abs(cx-x)
		hy = abs(cy-y)
		H = h + hx + hy
		tls[cx][cy] = H
	for cx,cy in cor[:]:
		if tls[cx][cy] != ls[cx][cy]:
			cor.remove([cx,cy])
	'''
	H = ls[cx][cy]
	if h != max(H-hx-hy,0):
		cor.remove([cx,cy])
		'''

for cx,cy in cor:
	if not ls[cx][cy] == 0:
		print(cx,cy,ls[cx][cy])
		exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split(' '))) for i in [0]*N]


ls = [[0]*101 for i in [0]*101]

cor = [[i,j] for i in range(101) for j in range(101)]

x,y,h = xyh[0]
for cx,cy in cor[:]:
	hx = abs(cx-x)
	hy = abs(cy-y)
	H = h+hx+hy
	ls[cx][cy] = H

for x,y,h in xyh[1:]:
	for cx,cy in cor[:]:
		hx = abs(cx-x)
		hy = abs(cy-y)
		H = ls[cx][cy]
		if h != max(H-hx-hy,0):
			cor.remove([cx,cy])

for cx,cy in cor:
	if not ls[cx][cy] == 0:
		print(cx,cy,ls[cx][cy])
		exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int,input().split(' '))) for i in [0]*N]


ls = [[0]*101 for i in [0]*101]

cor = [[i,j] for i in range(101) for j in range(101)]

x,y,h = xyh[0]
for cx,cy in cor[:]:
	hx = abs(cx-x)
	hy = abs(cy-y)
	H = h+hx+hy
	ls[cx][cy] = H

for x,y,h in xyh[1:]:
	for cx,cy in cor[:]:
		hx = abs(cx-x)
		hy = abs(cy-y)
		H = h + hx + hy
		ch = ls[cx][cy]
		if H != 0 and ch != 0 and ch != H:
			cor.remove([cx,cy])

for cx,cy in cor:
	if not ls[cx][cy] == 0:
		print(cx,cy,ls[cx][cy])
		exit()

Submission status: Wrong Answer

Solution code:
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)
MAX=101
for posX in range(MAX):
  for posY in range(MAX):
    needH=-1
    for i in range(N):
      tmp=h[i]+abs(posX-x[i])+abs(posY-y[i])
      if needH == -1:
        needH=tmp
      elif needH != tmp:
        needH=-2
        break
    if needH==-2:
      continue
    for i in range(N):
      if h[i] == 0:
        dist=abs(posY-y[i])+abs(posX-x[i])
        if needH > dist:
          needH=-2
          break
    if needH == -2:
      continue
    print(posX,posY,needH)

Submission status: Wrong Answer

Solution code:
N = int(input())
info = [list(map(int,input().split())) for _ in range(N)]
info.sort(key=lambda x:x[2])
x,y,h = info[0]

for cx in range(101):
  for cy in range(101):
    H = h+abs(x-cx)+abs(y-cy)
    if all(max(H-abs(xx-cx)-abs(yy-cy),0) == hh for xx,yy,hh in info):
      print(cx, cy, H)
      exit(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(n):
    x,y,h=map(int,input().split())
    if h>0:
        l.append((x,y,h))
ma=len(l)
x,y,h=l[0]
for s in range(101):
    for t in range(101):
        x2,y2,h2=s,t,h+abs(x-s)+abs(y-t)  #候補点
        c=0
        for(x3,y3,h3)in l:
            if h3!=h2-abs(x3-x2)-abs(y3-y2):
                break
            else:
                c+=1
            #print(c)
            if c==ma:
                print(x2,y2,h2)
                exit()
print(-1,-1,-1)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag2=True
    stack2=10**18
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      elif h==0:
        stack2=min(stack2,H)
      elif h!=0 and flag2==False:
        if stack!=H:
          stack=10**18+1
          break
    if stack<=stack2:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag2=True
    stack=10**18+1
    stack2=10**18
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      elif h==0:
        stack2=min(stack2,H)
      elif h!=0 and flag2==False:
        if stack!=H:
          stack=10**18+1
          break
    if stack<=stack2:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    stack=10**18+1
    stack2=10**18
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      elif h==0:
        stack2=min(stack2,H)
      elif h!=0 and flag2==False:
        if stack!=H:
          flag=False
          break
    if flag and stack<=stack2:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    Z=10**18
    flag=True
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        if flag:
          H=abs(x-cx)+abs(y-cy)+h
        else:
          if H!=abs(x-cx)+abs(y-cy)+h:
            H=10**18+1
            break
      else:
        Z=min(Z,abs(x-cx)+abs(y-cy))
    if H<=Z:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    stack=10**18+1
    stack2=10**18
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      if h==0:
        stack2=min(stack2,H)
      if h!=0 and flag2==False:
        if stack!=H:
          flag=False
          break
    if flag and stack<=stack2:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    stack2=10**18
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      if h==0:
        stack2=min(stack2,H)
      if h!=0 and flag2==False:
        if stack!=H:
          flag=False
          break
    if flag and stack<=stack2:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    stack2=10**18
    for i in range(n):
      if flag==False:
        break
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if h!=0 and flag2:
        stack=H
        flag2=False
      if h==0:
        stack2=min(stack2,H)
      if h!=0 and flag2==False:
        if stack!=H:
          flag=False
          break
    if flag and stack<=stack2:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      if flag==False:
        break
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if i==0:
        if h==0:
          flag2=False
        stack=H
        continue
      if stack!=H:
        if h==0 and H>=stack:
          continue
        if flag2==False:
          if h==0 and stack>=H:
            stack=H
            continue
          elif h!=0 and H<=stack:
            stack=H
            flag2=True
            continue
          elif h!=0 and H>stack:
            flag=False
            continue
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if i==0:
        if h==0 and H!=1:
          flag2=False
        stack=H
        continue
      if i==n-1:
        if H==stack:
          flag=True
        else:
          flag=False
      if stack!=H:
        if h==0 and H>=stack:
          continue
        if flag2==False:
          if h==0 and stack>H:
            stack=H
            continue
          elif H<=stack:
            stack=H
            flag2=True
            continue
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if i==0:
        if h==0 and H!=1:
          flag2=False
        stack=H
        continue
      if stack!=H:
        if h==0 and H>=stack:
          continue
        if flag2==False:
          if h==0 and stack>H:
            stack=H
            continue
          elif H<=stack:
            stack=H
            flag2=True
            continue
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      H=abs(x-cx)+abs(y-cy)+h
      if i==0:
        if h==0 and H!=1:
          flag2=False
        stack=H
        continue
      if stack!=H:
        if h==0 and H>=stack:
          continue
        if flag2==False:
          if h==0 and H!=1:
            stack=H
            continue
          elif H<=stack:
            stack=H
            flag2=True
            continue
          else:
            pass
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    H=[]
    Z=[]
    for i in range(n):
      x,y,h=s[i]
      if h!=0:
        H.append(abs(x-cx)+(y-cy)+h)
      else:
        Z.append(abs(x-cx)+(y-cy))
    if len(Z)==0:
      Z.append(10**18)
    if H.count(H[0])==len(H) and min(Z)>=H[0]:
      print(cx,cy,H[0])
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if i==0:
        if h==0 and H!=1:
          flag2=False
        stack=H
        continue
      if stack!=H:
        if h==0 and H>=stack:
          continue
        if flag2==False:
          if h==0 and H!=1:
            stack=H
            continue
          elif H<=stack:
            stack=H
            flag2=True
            continue
          else:
            pass
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if i==0:
        if h==0:
          flag2=False
        stack=H
        continue
      if stack!=H:
        if h==0 and H>=stack:
          continue
        if flag2==False:
          if h==0:
            stack=H
            continue
          elif H<=stack:
            stack=H
            flag2=True
            continue
          else:
            pass
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if i==0:
        stack=H
        continue
      if stack!=H:
        if h==0 and H>=stack:
          continue
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if i==0:
        if h==0:
          if H!=1:
            flag2=False
        stack=H
        continue
      if h==0:
        if flag2==False:
          if H==1:
            stack=H
            flag2=True
            continue
          elif H<stack:
            stack=H
          continue
        elif stack>H:
          flag=False
          break
      if flag2==False:
        if H>stack:
          flag=False
          break
        else:
          stack=H
          flag2=True
      if stack!=H:
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    flag2=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if i==0:
        if h==0:
          flag2=False
        stack=H
        continue
      if h==0:
        if flag2==False:
          if H<stack:
            stack=H
          continue
        elif stack>H:
          flag=False
          break
      if flag2==False:
        if H>stack:
          flag=False
          break
        else:
          stack=H
          flag2=True
      if stack!=H:
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if H<1:
        flag=False
        break
      if i==0:
        stack=H
        continue
      if stack!=H:
        flag=False
        break
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if H<1:
        flag=False
        break
      if i==0:
        stack=H
        continue
      if stack!=H:
        flag=False
        break
      stack=H
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
s=[[int(i) for i in l.split()] for l in sys.stdin]
for cx in range(101):
  for cy in range(101):
    flag=True
    for i in range(n):
      x,y,h=s[i]
      if x>=cx and y>=cy:
        H=h+x+y-cx-cy
      elif x>=cx:
        H=h+x-y-cx+cy
      elif y>=cy:
        H=h-x+y+cx-cy
      else:
        H=h-x-y+cx+cy
      if i==0:
        stack=H
        continue
      if stack!=H:
        flag=False
        break
      stack=H
    if flag:
      print(cx,cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]

tx, ty, th = xyh[0]
xyh.sort(key = itemgetter(2))
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()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter

N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]

tx, ty, th = xyh[0]
xyh.sort(key = itemgetter(2))
for Cx in range(101):
  for Cy in range(101):
    H = th + abs(Cx-tx) + abs(Cy-ty)
    if all(h == max(H-abs(Cx-x)-abs(Cy-y), 0) for x, y, h in xyh):
      print(Cx, Cy, H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(x[2]!=0):
                    if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
                else:
                    if(h>abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
        if(flag):
            if(h>ans[2]):
                ans=[i,j,h]

print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
if N==1:
    print(D[0][0],D[0][1],D[0][2])
    exit()
H={}
for cx in range(101):
    for cy in range(101):
        H=set()
        for x, y, h in D:
            if h >=1:
                H.add(abs(x-cx)+abs(y-cy)+h)
        if len(H)==1:
            print(cx, cy, list(H)[0])
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
N = int(input())
li = [[int(x) for x in input().split()] for _ in range(N)]
map = [[-1 for _ in range(101)] for _ in range(101)]
ans = [0]*3
for i in range(101):
    for j in range(101):
        h = -1
        flag = True
        for x in li:
            if(h == -1):
                h=x[2]+abs(x[0]-i)+abs(x[1]-j)
            else:
                if(x[2]!=0):
                    if(h!=x[2]+abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
                else:
                    if(h<abs(x[0]-i)+abs(x[1]-j)):
                        flag = False
        if(flag):
            if(h>ans[2]):
                ans=[i,j,h]

print(str(ans[0])+' '+str(ans[1])+' '+str(ans[2]))