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 sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = True
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
H = 0
all0h = 1
for l in xyh:
  if l[2] != 0:
    all0h = 0
    break
for i in range(101):
  for j in range(101):
    for l in xyh:
      h = abs(i - l[0]) + abs(j - l[1])
      if l[2] != 0:
        if H == 0:
          H = l[2] + h
        else:
          if l[2] + h != H:
            H = 0
            break
      else:
        if all0h == 1:
          H = 1
          if 1 - h > 0:
            H = 0
            break
    if H != 0:
      print(i, j, H)
      exit(0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if pira[i][2] == 0 and tmp != 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
H = 0
all0h = 1
for l in xyh:
  if l[2] != 0:
    all0h = 0
    break
for i in range(101):
  for j in range(101):
    for l in xyh:
      h = abs(i - l[0]) + abs(j - l[1])
      if l[2] != 0:
        if H == 0:
          H = l[2] + h
        else:
          if l[2] + h != H:
            H = 0
            break
      else:
        H = 1
        if 1 - h > 0:
          H = 0
          break
    if H != 0:
      print(i, j, H)
      exit(0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			# if pira[i][2] == 0:
			# 	continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			elif pira[i][2] != 0:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
H = 0
all0h = 1
for l in xyh:
  if l[2] != 0:
    all0h = 0
    H = 10 ** 9 + 1
    break
for i in range(101):
  for j in range(101):
    for l in xyh:
      h = abs(i - l[0]) + abs(j - l[1])
      if l[2] != 0:
        if H == 0:
          H = l[2] + h
        else:
          if l[2] + h != H:
            H = 0
            break
      else:
        H = 1
        if 1 - h > 0:
          H = 0
          break
    if H != 0:
      print(i, j, H)
      exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
H = 0
for i in range(101):
  for j in range(101):
    for l in xyh:
      h = abs(i - l[0]) + abs(j - l[1])
      if l[2] != 0:
        if H == 0:
          H = l[2] + h
        else:
          if l[2] + h != H:
            H = 0
            break
    if H != 0:
      print(i, j, H)
      exit(0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if (i == len(pira)-1) and (pira[i][2] == 0):
				break
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if i == len(pira)-1 and a:
				break
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if i == len(pira)-1 and pira[i][2] == 0:
				break
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if i == len(pira) and pira[i][2] == 0:
				break
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if i == len(pira) and a:
				break
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			# if pira[i][2] == 0:
			# 	continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys


n = int(input())
xyh = []
for i in range(n):
    xyh.append(list(map(int, input().split())))
    if xyh[-1][2] >= 1:
        G = xyh[-1]

for cx in range(0, 101):
    for cy in range(0, 101):
        hs = []
        x, y, h = G
        H = h + abs(x - cx) + abs(y - cy)
        H = max(H, 0)
        invalid = False
        for i in range(1, n):
            x, y, h = xyh[i]
            hh = H - abs(x - cx) - abs(y - cy)
            hh = max(hh, 0)
            if hh != h:
                invalid = True
                break
        if invalid is False:
            print("{} {} {}".format(cx, cy, H))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys


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

for cx in range(0, 101):
    for cy in range(0, 101):
        hs = []
        x, y, h = xyh[0]
        H = h + abs(x - cx) + abs(y - cy)
        H = max(H, 0)
        invalid = False
        for i in range(1, n):
            x, y, h = xyh[i]
            hh = H - abs(x - cx) - abs(y - cy)
            hh = max(hh, 0)
            if hh != h:
                invalid = True
        if invalid is False:
            print("{} {} {}".format(cx, cy, H))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys


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

for cx in range(0, 101):
    for cy in range(0, 101):
        hs = []
        for i in range(n):
            x, y, h = xyh[i]
            H = h + abs(x - cx) + abs(y - cy)
            hs.append(H)
        if len(set(hs)) == 1:
            print("{} {} {}".format(cx, cy, H))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys


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

for cx in range(0, 101):
    for cy in range(0, 101):
        for H in range(max(1, xyh[0][2] - 101),
                       max(2, xyh[0][2] + 101)):
            is_valid = True
            for i in range(n):
                x, y, h = xyh[i]
                if max(H - abs(x - cx) - abs(y - cy), 0) != h:
                    is_valid = False
                    break
            if is_valid is True:
                print('{} {} {}'.format(cx, cy, H))
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys


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

for cx in range(0, 101):
    for cy in range(0, 101):
        for H in range(xyh[0][2] - 101, xyh[0][2] + 101):
            is_valid = True
            for i in range(n):
                x, y, h = xyh[i]
                if max(H - abs(x - cx) - abs(y - cy), 0) != h:
                    is_valid = False
                    break
            if is_valid is True:
                print('{} {} {}'.format(cx, cy, H))
                sys.exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
XYH = []
for i in range(N):
    x, y, h = MAP()
    XYH.append((x, y, h))

# 中心候補として全座標を試す
for y1 in range(101):
    for x1 in range(101):
        H = set()
        for x2, y2, h in XYH:
            # 各座標情報から、中心の高さ(仮)を出す
            tmph = abs(x1-x2) + abs(y1-y2) + h
            # 高さ0以下の情報は使えないので除く
            if h > 0:
                H.add(tmph)
        # 中心の高さ(仮)が1つなら、全ての情報と矛盾がないことになるのでそれが答え
        if len(H) == 1:
            print(x1, y1, list(H)[0])
            exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
XYH = []
for i in range(N):
    x, y, h = MAP()
    XYH.append((x, y, h))

# 中心候補として全座標を試す
for y1 in range(101):
    for x1 in range(101):
        H = set()
        for x2, y2, h in XYH:
            # 各座標情報から、中心の高さ(仮)を出す
            tmph = abs(x1-x2) + abs(y1-y2) + h
            # 高さ0以下の情報は使えないので除く
            if tmph > 0:
                H.add(tmph)
        # 中心の高さ(仮)が1つなら、全ての情報と矛盾がないことになるのでそれが答え
        if len(H) == 1:
            print(x1, y1, list(H)[0])
            exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				# a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
# tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
		for i in range(1,len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))
tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
		else:
			tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
		for i in range(1,len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				# ans = [0,0,0]
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))

for x in range(101):
	for y in range(101):
		tmp = pira[0][2] + abs(pira[0][0]-x) + abs(pira[0][1]-y)
		for i in range(1,len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				# ans = [0,0,0]
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))

for x in range(101):
	for y in range(101):
		tmp = pira[0][2] + abs(pira[0][0]-x) + abs(pira[0][1]-y)
		for i in range(1,len(pira)):
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				# ans = [0,0,0]
				break
			else:
				a = True
				ans = [x,y,tmp]

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))

for x in range(101):
	for y in range(101):
		tmp = pira[0][2] + abs(pira[0][0]-x) + abs(pira[0][1]-y)
		for i in range(1,len(pira)):
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				# ans = [0,0,0]
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    N = II()
    info = []
    for _ in range(N):
        info.append(LMIIS())
    
    
    minx = 0
    maxx = 100
    miny = 0
    maxy = 100
    lines = []
    for i in range(len(info)):
        x1,y1,h1 = info[i]
        for j in range(len(info)):
            if i == j:
                continue
            x2,y2,h2 = info[j]
            diff = abs(x1-x2) + abs(y1-y2)
            if abs(h1-h2) == diff:
                if h1 > h2:
                    if x1 == x2:
                        if y1 > y2:
                            miny = max(y1,miny)
                        else:
                            maxy = min(y1,maxy)
                    elif y1 == y2:
                        if x1 > x2:
                            minx = max(x1,minx)
                        else:
                            maxx = min(x1,maxx)
                    else:
                        if x1 > x2:
                            minx = max(x1,minx)
                        else:
                            maxx = min(x1,maxx)

                        if y1 > y2:
                            miny = max(y1,miny)
                        else:
                            maxy = min(y1,maxy)
            elif h1 == h2:
                if x1 == x2:
                    ansx = x1
                    ansy = (y1 + y2)//2
                    ansh = h1 + abs(y2-y1)//2
                    print(ansx,ansy,ansh)
                    return
                elif y1 == y2:
                    ansx = (x1+x2)//2
                    ansy = y1
                    ansh = h1 + abs(x2-x1)//2
                    print(ansx,ansy,ansh)
                    return

                # else:
                #     a = -(x2-x2)/(y2-y1)
                #     b = -a * x1 + y1
                
                #     if len(lines) == 1:
                #         a2 = lines[0][0]
                #         b2 = lines[0][1]


                #         ansx = (b2-b)//(a-a2)
                #         ansy = ansx * a + b
                #         x,y,h = info[0]
                #         ansh = h + abs(x-ansx) + abs(y-ansy)
                #         print('answer',ansx,ansy,ansh)
                #         return
                #     else:
                #         lines.append((a,b))
    ansx = minx
    ansy = miny
    x,y,h = info[0]
    ansh = h + abs(x-ansx) + abs(y-ansy)
                        
    #print(miny,maxy,minx,maxx)
    print(ansx,ansy,ansh)



                            







if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = False
for i in range(N):
	pira[i] = list(map(int, input().split()))

for x in range(101):
	for y in range(101):
		tmp = pira[0][2] + abs(pira[0][0]-x) + abs(pira[0][1]-y)
		for i in range(1,len(pira)):
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				ans = [0,0,0]
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    N = II()
    info = []
    for _ in range(N):
        info.append(LMIIS())
    
    
    minx = 0
    maxx = 100
    miny = 0
    maxy = 100
    lines = []
    for i in range(len(info)):
        x1,y1,h1 = info[i]
        for j in range(len(info)):
            if i == j:
                continue
            x2,y2,h2 = info[j]
            diff = abs(x1-x2) + abs(y1-y2)
            if abs(h1-h2) == diff:
                if h1 > h2:
                    if x1 == x2:
                        if y1 > y2:
                            miny = max(y1,miny)
                        else:
                            maxy = min(y1,maxy)
                    elif y1 == y2:
                        if x1 > x2:
                            minx = max(x1,minx)
                        else:
                            maxx = min(x2,maxx)
                    else:
                        if x1 > x2:
                            minx = max(x1,minx)
                        else:
                            maxx = min(x1,maxx)

                        if y1 > y2:
                            miny = max(y1,miny)
                        else:
                            maxy = min(y1,maxy)
            elif h1 == h2:
                if x1 == x2:
                    ansx = x1
                    ansy = (y1 + y2)//2
                    ansh = h1 + abs(y2-y1)//2
                    print(ansx,ansy,ansh)
                    return
                elif y1 == y2:
                    ansx = (x1+x2)//2
                    ansy = y1
                    ansh = h1 + abs(x2-x1)//2
                    print(ansx,ansy,ansh)
                    return

                # else:
                #     a = -(x2-x2)/(y2-y1)
                #     b = -a * x1 + y1
                
                #     if len(lines) == 1:
                #         a2 = lines[0][0]
                #         b2 = lines[0][1]


                #         ansx = (b2-b)//(a-a2)
                #         ansy = ansx * a + b
                #         x,y,h = info[0]
                #         ansh = h + abs(x-ansx) + abs(y-ansy)
                #         print('answer',ansx,ansy,ansh)
                #         return
                #     else:
                #         lines.append((a,b))
    ansx = minx
    ansy = miny
    x,y,h = info[0]
    ansh = h + abs(x-ansx) + abs(y-ansy)
                        
    #print(miny,maxy,minx,maxx)
    print(ansx,ansy,ansh)



                            







if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def height(i):
    return abs(XYHs[i][0] - cx) + abs(XYHs[i][1] - cy) + XYHs[i][2]


for cx in range(101):
    s = False
    for cy in range(101):
        H = height(0)
        sw = True
        for i in range(1, len(XYHs)):
            if height(i) != H:
                sw = False
                break
        if sw:
            print("%d %d %d" % (cx, cy, H))
            s = True
            break
    if s:
        break

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n = int(input())
T = []
for _ in range(n):
    x,y,h = input().split()
    T.append([int(x),int(y),int(h)])
    if h != 0: k = [int(x),int(y),int(h)]

for i in range(101):
    for j in range(101):
        H = k[2] + abs(k[0]-i) + abs(k[1]-j)
        for t in T:
            if t[2] != max(H-abs(t[0]-i)-abs(t[1]-j),0):
                break
            if t == T[-1]:
                print(i,j,H)
                exit()

Submission status: Wrong Answer

Solution code:
from operator import itemgetter
n = int(input())
T = []
for _ in range(n):
    x,y,h = input().split()
    T.append([int(x),int(y),int(h)])
    if h != 0: k = [int(x),int(y),int(h)]

for i in range(101):
    for j in range(101):
        H = k[2] + abs(k[0]-i) + abs(k[1]-j)
        for t in T:
            if t[-1] != max(H-abs(t[0]-i)-abs(t[1]-j),0):
                break
            if t == T[-1]:
                print(i,j,H)
                exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
lst=[]
for i in range(n):
  x,y,h=map(int,input().split())
  lst.append([x,y,h])
  
for j in range(101):
  for k in range(101):
    for i in range(n):
      H=abs(j-lst[i][0])+abs(k-lst[i][1])+lst[i][2]
      if H>0:
        if all(max(H-abs(j-lst[l][0])-abs(k-lst[l][1]),0)==lst[l][2] for l in range(n)):
          print([j,k,H])
          sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
lst=[]
for i in range(n):
  x,y,h=map(int,input().split())
  lst.append([x,y,h])
  
for j in range(101):
  for k in range(101):
    for i in range(n):
      H=abs(j-lst[i][0])-abs(k-lst[i][1])+lst[i][2]
      if H>0:
        if all(max(H-abs(j-lst[l][0])-abs(k-lst[l][1]),0)==lst[l][2] for l in range(n)):
          print([j,k,H])
          sys.exit()

Submission status: Wrong Answer

Solution code:
### input test
"""
N = 6
P = [
(16,24,0),
(2,3,5),
(2,1,5),
(1,2,5),
(3,2,5),
(28,69,0),
]
# => expected(2,2,6)
###
"""
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]


###
# get 1 index where h is not 0
# N < 101*101 ==> h > 0 at least 1 point
for i in range(N):
    if P[i][2] > 0:
        REGi = i
        break

def dist(p1, p2):
    return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

def is_correct_center(cx, cy):
    now_C = (cx, cy, 0)  # Is this the center?
    # get first sample where h is not 0
    reg_D = dist(P[REGi], now_C)
    reg_H = P[REGi][2]
    for p in P:
        if p[2] == 0:
            continue
        now_D = dist(p, now_C)
        now_H = p[2]
        # higher_H if nearer_D
        if (- now_D + reg_D) != (now_H - reg_H):
            return False
    return True

def get_answers(cx, cy):
    H = P[REGi][2] + dist(P[REGi], (cx, cy, 0))
    return cx, cy, H

### Start from here...
for cx in range(101):
    for cy in range(101):
        if is_correct_center(cx, cy):
            print(*get_answers(cx, cy))
            exit(0)