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())
xyh= [list(map(int,input().split())) for _ in range(n)]

def find_xyh(xyh,n):
  for xi in range(0,100+1):
    for yi in range(0,100+1):
      x,y,h = xyh[0]
      H = h + abs(xi-x) + abs(yi-y)      
      is_fill = True

      for x,y,h in xyh[1:]:
        if h != max(H -abs(xi-x) -abs(yi-y), 0):
          is_fill = False
          break
                
      if is_fill:
        print(xi,yi,H)
        return

find_xyh(xyh,n)

Submission status: Wrong Answer

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

def find_xyh(xyh,n):
  for xi in range(0,100+1):
    for yi in range(0,100+1):
      H = xyh[0][2] + abs(xi-xyh[0][0]) + abs(yi-xyh[0][1])
      is_fill = True
      
      if len(xyh) > 1: 
        for xyhi in xyh[1:]:
          if xyhi[0]==0: # hi=0の場合は無視
            continue
          if H != xyhi[2] + abs(xi-xyhi[0]) + abs(yi-xyhi[1]):
            is_fill = False
            break
        
      if is_fill:
        print(xi,yi,H)
        return

find_xyh(xyh,n)

Submission status: Wrong Answer

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

def find_xyh(xyh,n):
  for xi in range(0,100+1):
    for yi in range(0,100+1):
      H = xyh[0][2] + abs(xi-xyh[0][0]) + abs(yi-xyh[0][1])
      is_fill = True

      for xyhi in xyh[1:]:
        if H != xyhi[2] + abs(xi-xyhi[0]) + abs(yi-xyhi[1]):
          is_fill = False
          break
      if is_fill:
        print(xi,yi,H)
        return

find_xyh(xyh,n)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
for cx in range(101):
    for cy in range(101):
        C = Counter([h+abs(cx-x)+abs(cy-y) for x,y,h in xyh])
        if len(C) == 1:
            H = list(C.keys())[0]
            if 1 <= H:
                print(cx, cy, H)
                exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
for cx in range(101):
    for cy in range(101):
        C = Counter([h+abs(cx-x)+abs(cy-y) for x,y,h in xyh])
        if len(C) == 1:
            H = list(C.keys())[0]
            if 1 <= H:
                print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
for cx in range(101):
    for cy in range(101):
        C = Counter([h+abs(cx-x)+abs(cy-y) for x,y,h in xyh])
        if len(C) == 1:
            print(cx, cy, list(C.keys())[0])
            exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = int(input())
    xyh = []
    for i in range(N):
        x,y,h = map(int,input().split())
        xyh.append((x,y,h))
        
    ans_x = 0
    ans_y = 0
    ans_h = 0
    for cx in range(101):
        for cy in range(101):
            Flg = True
            H = -1
            for i, val in enumerate(xyh):
                x,y,h = val
                if h == 0:
                    continue
                if H == -1:
                    H = h + abs(cx-x) + abs(cy-y)
                    continue
                tmp = h + abs(cx-x) + abs(cy-y)
                if tmp != H:
                    Flg = False
                    break
            if Flg == True:
                ans_x = cx
                ans_y = cy
                ans_h = H
                
                if N == 1:
                    x,y,h = xyh[0]
                    ans_x = x
                    ans_y = y
                        
                print("{} {} {}".format(ans_x, ans_y, ans_h))
                sys.exit()
            
    #("{} {} {}".format(ans_x, ans_y, ans_h))
            	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# 2019/07/26

n=int(input())

xyh=[]

for i in range(n):
    x,y,h=map(int,input().split())
    xyh.append((h,x,y))

xyh.sort(reverse=True)


for i in range(101):
    for j in range(101):
        
        H=xyh[0][0]+abs(xyh[0][1]-i)+abs(xyh[0][2]-j)
        for k in range(1,n):
            h,x,y=xyh[k]
            if H-abs(x-i)-abs(y-j)<0:continue
            if h!=max(H-abs(x-i)-abs(y-j),0):break
        else:
            print(*[i,j,H])

Submission status: Wrong Answer

Solution code:
# 2019/07/26

n=int(input())

xyh=[]

for i in range(n):
    x,y,h=map(int,input().split())
    xyh.append((h,x,y))

xyh.sort(reverse=True)


for i in range(101):
    for j in range(101):
        
        H=max(xyh[0][0]+abs(xyh[0][1]-i)+abs(xyh[0][2]-j),0)
        for k in range(1,n):
            h,x,y=xyh[k]
            if H-abs(x-i)-abs(y-j)<0:continue
            HH=h+abs(x-i)+abs(y-j)
            if HH!=H:break         
        else:
            print(*[i,j,H])

Submission status: Wrong Answer

Solution code:
# 2019/07/26

n=int(input())

x=[0]*n
y=[0]*n
h=[0]*n

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

for i in range(101):
    for j in range(101):
        H=max(h[0]+abs(x[0]-i)+abs(y[0]-j),0)
        for k in range(1,n):
            HH=max(h[k]+abs(x[k]-i)+abs(y[k]-j),0)
            if HH!=H:break         
        else:
            print(*[i,j,H])

Submission status: Wrong Answer

Solution code:
# 2019/07/26

n=int(input())

x=[0]*n
y=[0]*n
h=[0]*n

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

for i in range(101):
    for j in range(101):
        H=h[0]+abs(x[0]-i)+abs(y[0]-j)
        for k in range(1,n):
            HH=h[k]+abs(x[k]-i)+abs(y[k]-j)
            if HH!=H:break         
        else:
            print(*[i,j,H])

Submission status: Wrong Answer

Solution code:
N = int(input())

X = [list(map(int,input().split())) for _ in range(N)]

count = 0
for i in range(101):
	for j in range(101):
		H = X[0][2] + abs(i-X[0][0]) + abs(j-X[0][1])

		for k in range(N):
			if X[k][2] == max(H-abs(i-X[k][0])-abs(j-X[k][1]),0):
				count += 1
		
		if count == N:
			print(i,j,H)
			break
		count = 0

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ABC112C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0
#peak ga (i,j) to katei

m=0
while(h[m]==0):
	m+=1
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[m])
		distance+=abs(j-y[m])
		height=distance+h[m]
		for k in range(0,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(height!=distance+h[k]):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ABC112C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0
#peak ga (i,j) to katei
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[0])
		distance+=abs(j-y[0])
		height=distance+h[0]

		for k in range(1,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(height!=distance+h[k]):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
#ABC110C
import sys

n = int(input())

x = []
y = []
h = []
for i in range(0,n):
	tmp = input().split()
	hoge = list(map(lambda a: int(a), tmp))
	x.append(hoge[0])
	y.append(hoge[1])
	h.append(hoge[2])

distance=0
height=0
#peak ga (i,j) to katei
for i in range(0,101):
	for j in range(0,101):
		distance=abs(i-x[0])
		distance+=abs(j-y[0])
		height=distance+h[0]

		for k in range(1,n):
			distance=abs(i-x[k])
			distance+=abs(j-y[k])
			if(h[k]!=height-distance):
				break
			if(k==n-1):
				print(i,j,height)
				sys.exit()

Submission status: Wrong Answer

Solution code:

n = int(input())
li = [list(map(int, input().split())) for _ in range(n)]
ans = []

for cx in range(101):
    for cy in range(101):
        for i in li:
            if i[2] != 0:
                ans.append([cx, cy, i[2] + abs(i[0]-cx) + abs(i[1] -cy)])
                break

for i in li:
    if len(ans) ==1:
        break
    if i[2] != 0:
        for j in reversed (range(len(ans[:]))):
            if ans[j][2] - abs(i[0]-ans[j][0]) - abs(i[1]-ans[j][1]) != i[2]:
                ans.pop(j)


print(" ".join(map(str, ans[0])))

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    H = max(aaa[0][0] + abs(x-aaa[0][1]) + abs(y-aaa[0][2]), 0)
    for i in range(N-1):
      H_ = max(aaa[i+1][0] + abs(x-aaa[i+1][1]) + abs(y-aaa[i+1][2]), 0)
      if H_ != H:
        break
    else:
      print(x, y, H)
      break

Submission status: Wrong Answer

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

for x in range(101):
  for y in range(101):
    H = aaa[0][0] + abs(x-aaa[0][1]) + abs(y-aaa[0][2])
    for i in range(N-1):
      H_ = aaa[i+1][0] + abs(x-aaa[i+1][1]) + abs(y-aaa[i+1][2])
      if H_ != H:
        break
    else:
      print(x, y, H)
      break

Submission status: Wrong Answer

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

for px in range(101):
    for py in range(101):
        ph = xyhs[0][2] + abs(px-xyhs[0][0]) +abs(py-xyhs[0][1])
        #print(ph)
        cnt = 0
        for idx in range(1,N):
            if ph == xyhs[0][2]:
                cnt += 1
        if cnt == N-1:
            print(px, py, ph)

Submission status: Wrong Answer

Solution code:
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)

C = [[-1 for _ in range(101)] for _ in range(101)]
for i in range(101):
    for j in range(101):
        h = H[0] + abs(X[0]-i) + abs(Y[0]-j)
        flag = True
        for n in range(1, N):
            if h != H[n] + abs(X[n]-i) + abs(Y[n]-j):
                flag = False
                break
        if flag:
            print(i, j, h)
            exit()

Submission status: Wrong Answer

Solution code:
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)

C = [[-1 for _ in range(101)] for _ in range(101)]
for x, y, h in zip(X, Y, H):
    for i in range(101):
        for j in range(101):
            if C[i][j] == -2:
                continue
            elif C[i][j] == -1:
                if h != 0:
                    tmp = h + abs(x - i) + abs(y - j)
                    C[i][j] = max(tmp, 0)
                else:
                    if x == i and y == j:
                        C[i][j] = h
                    else:
                        C[i][j] = abs(x - i) + abs(y - j)
            else:
                if h + abs(x - i) + abs(y - j) != C[i][j]:
                    C[i][j] = -2

for i in range(101):
    for j in range(101):
        if C[i][j] > 0:
            print(i, j, C[i][j])
            exit()

Submission status: Wrong Answer

Solution code:
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)

C = [[-1 for _ in range(101)] for _ in range(101)]
for x, y, h in zip(X, Y, H):
    for i in range(101):
        for j in range(101):
            if C[i][j] == -2:
                continue
            elif C[i][j] == -1:
                if h != 0:
                    tmp = h + abs(x - i) + abs(y - j)
                    C[i][j] = max(tmp, 0)
                else:
                    if x == i and y == j:
                        C[i][j] = h
                    else:
                        C[i][j] = -1
            else:
                if h + abs(x - i) + abs(y - j) != C[i][j]:
                    C[i][j] = -2

for i in range(101):
    for j in range(101):
        if C[i][j] > 0:
            print(i, j, C[i][j])
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
v=[]
r=[]
count=0
#各頂点に対して、ピラミッドの頂点(  高さ200 )と仮定して計算 rに座標保存
for i in range(101):
    for j in range(101):
        for k in range(n):
            x=abs(j-z[k][0])
            y=abs(i-z[k][1])
            v.append(10000-x-y-z[k][2])
        if v.count(v[0])==n:
            r=[j,i]
            #高さを求める
            h=z[0][2]+abs(z[0][0]-r[0])+abs(z[0][1]-r[1])
                
            #候補があってるか確認
            for l in range(n):
                if z[l][2]==max(h-abs(z[l][0]-r[0])-abs(z[l][1]-r[1]),0):
                    count+=1
                
            if count==n and h!=0:
                print(r[0],r[1],h)
            exit()
        v=[]
        count=0

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
v=[]
r=[]
count=0
#各頂点に対して、ピラミッドの頂点(  高さ200 )と仮定して計算 rに座標保存
for i in range(101):
    for j in range(101):
        for k in range(n):
            x=abs(j-z[k][0])
            y=abs(i-z[k][1])
            v.append(10000-x-y-z[k][2])
        if v.count(v[0])==n:
            r=[j,i]
            #高さを求める
            h=z[0][2]+abs(z[0][0]-r[0])+abs(z[0][1]-r[1])
            #候補があってるか確認
            for l in range(n):
                if z[l][2]==max(h-abs(z[l][0]-r[0])-abs(z[l][1]-r[1]),0):
                    count+=1
                
            if count==n:
                print(r[0],r[1],h)
            exit()
        v=[]
        count=0

Submission status: Wrong Answer

Solution code:
n=int(input())
z=[list(map(int, input().split())) for i in range(n)]
v=[]
r=[]
#各頂点に対して、ピラミッドの頂点(  高さ200 )と仮定して計算 rに座標保存
for i in range(101):
    for j in range(101):
        for k in range(n):
            x=abs(j-z[k][0])
            y=abs(i-z[k][1])
            v.append(200-x-y-z[k][2])
        if v.count(v[0])==n:
            r=[j,i]
            h=z[0][2]+abs(z[0][0]-r[0])+abs(z[0][1]-r[1])
            print(r[0],r[1],h)
            exit()
        v=[]

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    xyh = []
    for i in range(N):
        x,y,h = map(int,input().split())
        xyh.append((x,y,h))
        
    ans_x = 0
    ans_y = 0
    ans_h = 0
    for cx in range(101):
        for cy in range(101):
            Flg = True
            H = -1
            for i, val in enumerate(xyh):
                x,y,h = val
                if h == 0:
                    continue
                if H == -1:
                    H = h + abs(cx-x) + abs(cy-y)
                    continue
                tmp = h + abs(cx-x) + abs(cy-y)
                if tmp != H:
                    Flg = False
                    break
            if Flg == True:
                ans_x = cx
                ans_y = cy
                ans_h = H
                
                if N == 1:
                    x,y,h = xyh[0]
                    ans_x = x
                    ans_y = y
                        
                print("{} {} {}".format(ans_x, ans_y, ans_h))
                sys.exit()
            
    #("{} {} {}".format(ans_x, ans_y, ans_h))
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    xyh = []
    for i in range(N):
        x,y,h = map(int,input().split())
        xyh.append((x,y,h))
        
    if N == 1:
        x,y,h = xyh[0]
        print("{} {} {}".format(x, y, h))
        sys.exit()
        
    ans_x = 0
    ans_y = 0
    ans_h = 0
    for cx in range(101):
        for cy in range(101):
            Flg = True
            H = -1
            for i, val in enumerate(xyh):
                x,y,h = val
                if h == 0:
                    continue
                if H == -1:
                    H = h + abs(cx-x) + abs(cy-y)
                    continue
                tmp = h + abs(cx-x) + abs(cy-y)
                if tmp != H:
                    Flg = False
                    break
            if Flg == True:
                ans_x = cx
                ans_y = cy
                ans_h = H
                print("{} {} {}".format(ans_x, ans_y, ans_h))
                sys.exit()
            
    #("{} {} {}".format(ans_x, ans_y, ans_h))
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    xyh = []
    for i in range(N):
        x,y,h = map(int,input().split())
        xyh.append((x,y,h))
        
    ans_x = 0
    ans_y = 0
    ans_h = 0
    for cx in range(101):
        for cy in range(101):
            Flg = True
            H = -1
            for i, val in enumerate(xyh):
                x,y,h = val
                if h == 0:
                    continue
                if H == -1:
                    H = h + abs(cx-x) + abs(cy-y)
                    continue
                tmp = h + abs(cx-x) + abs(cy-y)
                if tmp != H:
                    Flg = False
                    break
            if Flg == True:
                ans_x = cx
                ans_y = cy
                ans_h = H
                print("{} {} {}".format(ans_x, ans_y, ans_h))
                sys.exit()
            
    #("{} {} {}".format(ans_x, ans_y, ans_h))
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    xyh = []
    for i in range(N):
        x,y,h = map(int,input().split())
        xyh.append((x,y,h))
        
    ans_x = 0
    ans_y = 0
    ans_h = 0
    for cx in range(101):
        for cy in range(101):
            Flg = True
            H = -1
            for i, val in enumerate(xyh):
                x,y,h = val
                if i == 0:
                    H = h + abs(cx-x) + abs(cy-y)
                    continue
                tmp = h + abs(cx-x) + abs(cy-y)
                if tmp != H:
                    Flg = False
                    break
            if Flg == True:
                ans_x = cx
                ans_y = cy
                ans_h = H
                print("{} {} {}".format(ans_x, ans_y, ans_h))
                sys.exit()
            
    #("{} {} {}".format(ans_x, ans_y, ans_h))
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    xyh = []
    for i in range(N):
        x,y,h = map(int,input().split())
        xyh.append((x,y,h))
        
    ans_x = 0
    ans_y = 0
    ans_h = 0
    for cx in range(101):
        for cy in range(101):
            Flg = True
            H = -1
            for i, val in enumerate(xyh):
                x,y,h = val
                if i == 0:
                    H = h + abs(cx-x) + abs(cy-y)
                    continue
                tmp = h + abs(cx-x) + abs(cy-y)
                if tmp != H:
                    Flg = False
                    continue
            if Flg == True:
                ans_x = cx
                ans_y = cy
                ans_h = H
                break
            
    print("{} {} {}".format(ans_x, ans_y, ans_h))
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    xyh = []
    for i in range(N):
        x,y,h = map(int,input().split())
        xyh.append((x,y,h))
        
    ans_x = 0
    ans_y = 0
    ans_h = 0
    for cx in range(101):
        for cy in range(101):
            Flg = True
            H = -1
            for i, val in enumerate(xyh):
                x,y,h = val
                if i == 0:
                    H = h + abs(cx-x) + abs(cy-y)
                    continue
                tmp = h + abs(cx-x) + abs(cy-y)
                if tmp != H:
                    Flg = False
                    break
            if Flg == True:
                ans_x = cx
                ans_y = cy
                ans_h = H
                break
            
    print("{} {} {}".format(ans_x, ans_y, ans_h))
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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


for cx in range(0,101):
    for cy in range(0,101):
        formerH = 0
        H = 0
        flag = 0
        for i in range(n):
            x = l[i][0]
            y = l[i][1]
            h = l[i][2]
            if i == 0:
                formerH = 0
            else:
                formerH = H
            H = abs(x-cx)+abs(y-cy)+h
            if i > 0 and H != formerH:
                break
            if i == n-1:
                a_cx = cx
                a_cy = cy
                a_H = H
                flag = 1
                break
        if flag == 1:
            break
    if flag == 1:
        break

if flag == 1:
    print(a_cx,a_cy,a_H)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    x, y, h = map(int, input().split())
    l.append([x, y, h])
 
for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if pyh != max(height - abs(x - pyx) - abs(y - pyy), 0):
                break
            else:
                if i == n:
                    print(x, y, height)
                    exit()
                i += 1

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        for pyx, pyy, pyh in l:
            if pyh != max(height - abs(x - pyx) - abs(y - pyy), 0):
                break
        else:
            print(x, y, height)
            exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if pyh != max(height - abs(x - pyx) - abs(y - pyy), 0):
                break
            else:
                print(i)
                if i == n:
                    print(x, y, height)
                    exit()
                i += 1

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if height != pyh + abs(x - pyx) + abs(y - pyy):
                break
            else:
                if i == n:
                    print(x, y, height)
                    exit()
                i += 1

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if pyh != height - abs(x - pyx) - abs(y - pyy):
                break
            else:
                i += 1
                if i == n:
                    print(x, y, height)
                    exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if height != pyh + abs(x - pyx) + abs(y - pyy):
                i = 1
                break
            else:
                i += 1
                if i == n:
                    print(x, y, height)
                    exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if height != pyh + abs(x - pyx) + abs(y - pyy):
                break
            else:
                i += 1
                if i == n:
                    print(x, y, height)
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
height = 0
for i in range(n):
    x, y, h = map(int, input().split())
    l.append([x, y, h])

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if height != pyh + abs(x - pyx) + abs(y - pyy):
                break
            else:
                i += 1
                if i == n:
                    print(x, y, height)
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
height = 0
for i in range(n):
    x, y, h = map(int, input().split())
    l.append([x, y, h])

for x in range(101):
    for y in range(101):
        height = max(l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1]), 0)
        i = 1
        for pyx, pyy, pyh in l:
            if height != l[i][2] + abs(x - l[i][0]) + abs(y - l[i][1]):
                break
            else:
                i += 1
                if i == n:
                    print(x, y, height)
                    exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
height = 0
for i in range(n):
    x, y, h = map(int, input().split())
    l.append([x, y, h])

for x in range(101):
    for y in range(101):
        height = l[0][2] + abs(x - l[0][0]) + abs(y - l[0][1])
        i = 1
        for pyx, pyy, pyh in l:
            if height != l[i][2] + abs(x - l[i][0]) + abs(y - l[i][1]):
                break
            else:
                i += 1
                if i == n:
                    print(x, y, height)
                    exit()

Submission status: Wrong Answer

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

for x in range(101):
    for y in range(101):
        check = []
        for d in xyh:
            if d[2] == 0:
                continue
            ch = abs(d[0] - x) + abs(d[1] - y) + d[2]
            check.append(ch)
        ifans = True
        for c in check:
            if c - check[0] != 0:
                ifans = False
                break
        if ifans:
            ans = [x, y, ch]
            break

print(' '.join([str(a) for a in ans]))