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

for i in range(0,101):
  for j in range(0,101):
    temp=0
    onezero=1
    for k in range(0,n):
      xhoukou=abs(i-lis[k][0])
      yhoukou=abs(j-lis[k][1])
      hhoukou=lis[k][2]
      if hhoukou!=0:
        keep=xhoukou+yhoukou+hhoukou
        if temp!=0:
          if not temp==keep:
            onezero=0
            break
        else:
          temp=keep
    if onezero==1:
      print(i,j,temp)
      break

Submission status: Wrong Answer

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

for i in range(0,101):
  for j in range(0,101):
    x=i
    y=j
    temp=0
    onezero=1
    for k in range(0,n):
      xhoukou=abs(x-lis[k][0])
      yhoukou=abs(y-lis[k][1])
      hhoukou=lis[k][2]
      if hhoukou==0:
        continue
      else:
        keep=xhoukou+yhoukou+hhoukou
        if temp:
          if not temp==keep:
            onezero=0
            break
        else:
          temp=keep
    if onezero==1:
      print(i,j,temp)
      break

Submission status: Wrong Answer

Solution code:
from itertools import product
n, *XYH = map(int, open(0).read().split())
X, Y, H = XYH[::3], XYH[1::3], XYH[2::3]
A = []
for cx, cy in product(range(101), repeat=2):
    B = set()
    C = set()
    for x, y, h in zip(X, Y, H):
        s = h + abs(x-cx) + abs(y-cy)
        if h == 0:
            B.add(s)
        else:
            C.add(s)
    if len(C) == 1:
        A.append((cx, cy, C.pop()))
print(*A.pop())

Submission status: Wrong Answer

Solution code:
import sys
import bisect

def getH(Cx, Cy, x, y, h):
    return h + abs(x-Cx) + abs(y-Cy)

inf = 10**15
mod = 10**9+7
n = int(input())
Hinfo = [list(map(int, input().split())) for i in range(n)]
H = -1
Hmax = inf
for Cx in range(101):
    for Cy in range(101):
        H = -1
        flag = True
        for tmp in Hinfo:
            x,y,h = tmp
            if h == 0:
                Hmax = getH(Cx, Cy, x, y, h)
            else:
                canH = getH(Cx, Cy, x, y, h)
                if H > 0:
                    if H != canH:
                        flag = False
                        break
                else:
                    H = canH
            if Hmax < H:
                flag = False
                break
        if Hmax > H and flag:
            print('{} {} {}'.format(Cx, Cy, H))
            sys.exit()

Submission status: Wrong Answer

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

for Cx in range(101):
	for Cy in range(101):

		for x,y,h in xyh:
			if h == 0:
				continue

			H = h + abs(x - Cx) + abs(y - Cy)
			break
		ok = True
		for x,y,h in xyh:
			if H - abs(x - Cx) -abs(y - Cy) != h:
				ok = False
				break
		if ok:
			print("{} {} {}".format(Cx, Cy, H))
			sys.exit(0)

Submission status: Wrong Answer

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

u = [i for i in u if i[2] != 0]

z = []
c =0
for cx in range(101):
    for cy in range(101):
        c = u[0][2]+abs(u[0][0]-cx)+abs(u[0][1]-cy)
        for j in u:
            if c != j[2]+abs(j[0]-cx)+abs(j[1]-cy):
                break
        else:
            z.append((cx,cy))
            break
    else:
        continue
    break
 
print(z[0][0],z[0][1],u[0][2]+abs(u[0][0]-z[0][0])+abs(u[0][1]-z[0][1]))

Submission status: Wrong Answer

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

u = [i for i in u if i[2] != 0]

z=[]
c =0
for cx in range(101):
    for cy in range(101):
        c = u[0][2]+abs(u[0][0]-cx)+abs(u[0][1]-cy)
        for j in u:
            if c != j[2]+abs(j[0]-cx)+abs(j[1]-cy):
                break
        else:
            z.append((cx,cy))
 
print(z[0][0],z[0][1],u[0][2]+abs(u[0][0]-z[0][0])+abs(u[0][1]-z[0][1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []
 
for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))
 
 
for cx in range(101):
    for cy in range(101):
        flag = True
        # x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        # prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for x0, y0, h0 in XYH[0:]:
            prob_H = h0 + abs(x0-cx) + abs(y0-cy)
            if h0 == 0:
                continue
            break
        for xi, yi, hi in XYH[0:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue
 
        print(cx,cy,prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        # x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        # prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for x0, y0, h0 in XYH[0:]:
            prob_H = h0 + abs(x0-cx) + abs(y0-cy)
            if h0 == 0:
                continue
            break
        for xi, yi, hi in XYH[1:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue

        print(cx,cy,prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        # x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        # prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for x0, y0, h0 in XYH[0:]:
            prob_H = h0 + abs(x0-cx) + abs(y0-cy)
            if h0 == 0:
                if prob_H > abs(x0-cx) + abs(y0-cy):
                    continue
            break
        for xi, yi, hi in XYH[1:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue

        assert prob_H > 0
        print(cx,cy,prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        # for x0, y0, h0 in XYH[0:]:
        #     if h0 == 0:
        #         continue
        #     prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        #     # print(prob_H)
        #     break
        for xi, yi, hi in XYH[1:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue

        assert prob_H > 0
        print(cx,cy,prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        # prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for x0, y0, h0 in XYH[0:]:
            if h0 == 0:
                continue
            prob_H = h0 + abs(x0-cx) + abs(y0-cy)
            # print(prob_H)
            break
        for xi, yi, hi in XYH[1:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue

        print(cx,cy,prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for xi, yi, hi in XYH[1:]:
            if hi == 0:
                if prob_H > abs(xi-cx) + abs(yi-cy):
                    flag = False
                    break
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue

        print(cx, cy, prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for xi, yi, hi in XYH[1:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                if hi == 0:
                    if prob_H > abs(xi-cx) + abs(yi-cy):
                        flag = False
                        break
                    else:
                        continue
            else:
                flag = False
                break
        if flag == False:
            continue
        print(cx, cy, prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for xi, yi, hi in XYH[1:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                if hi == 0:
                    if prob_H < abs(xi-cx) + abs(yi-cy):
                        flag = False
                        break
                    else:
                        continue
            else:
                flag = False
                break
        if flag == False:
            continue
        print(cx, cy, prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
N = int(input())
XYH = []

for _ in range(N):
    xi, yi, hi = map(int, input().split())
    XYH.append((xi, yi, hi))


for cx in range(101):
    for cy in range(101):
        flag = True
        x0, y0, h0 = XYH[0][0],XYH[0][1],XYH[0][2]
        prob_H = h0 + abs(x0-cx) + abs(y0-cy)
        for xi, yi, hi in XYH[1:]:
            if hi + abs(xi-cx) + abs(yi-cy) == prob_H:
                continue
            else:
                flag = False
                break
        if flag == False:
            continue
        print(cx, cy, prob_H)
        quit()

Submission status: Wrong Answer

Solution code:
n = int(input())
hist = [tuple(map(int,input().split())) for _ in range(n)]
hist.sort(key=lambda x: x[2], reverse=1)

cands = []
x0,y0,h0 = hist[0]

for i in range(0,101):
  for j in range(0,101):
    if h0 == 0:
      cands.append((i,j,1))
    else:
      cands.append((i,j, h0+abs(i-x0)+abs(j-y0)))
    
for X,Y,H in cands:
  for x,y,h in hist:
    if H-abs(X-x)-abs(Y-y) == h:
      continue
    else:
      break
  else:
    print(X,Y,H)
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
hist = [tuple(map(int,input().split())) for _ in range(n)]
hist.sort(key=lambda x: x[2], reverse=1)

cands = []
x0,y0,h0 = hist[0]

for i in range(0,101):
  for j in range(0,101):
    cands.append((i,j, h0+abs(i-x0)+abs(j-y0)))
    
for X,Y,H in cands:
  for x,y,h in hist:
    if H-abs(X-x)-abs(Y-y) == h:
      continue
    else:
      break
  else:
    print(X,Y,H)
    break

Submission status: Wrong Answer

Solution code:
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    vx = []
    vy = []
    vh = []
    for i in range(n):
        x,y,h = readInts()
        vx.append(x)
        vy.append(y)
        vh.append(h)
    # 基準となる座標はどこでもいい
    si = 0
    resx,resy,resh = -1,-1,-1
    for x in range(101):
        for y in range(101):
            h = vh[si] + abs(x - vx[si]) + abs(y - vy[si])
            ok = True
            for i in range(n):
                if vh[i] > 0 and h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]):
                    ok = False
                if vh[i] == 0 and h > abs(x - vx[i]) + abs(y - vy[i]):
                    ok = False
            if ok:
                resx = x
                resy = y
                resh = h
    print(resx,resy,resh)
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      for x,y,h in pos:
        H = h+abs(x-cx)+abs(y-cy)
        if h > 0:
          res.append(H)
        if h != max(H-abs(x-cx)-abs(y-cy), 0):
          break
      else:
        if len(set(res)) == 1:
          return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

Submission status: Wrong Answer

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

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      edge=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        H = h+abs(x-cx)+abs(y-cy)
        if h > 0:
          res.append(H)
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

Submission status: Wrong Answer

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

def solve():
  for cx in range(101):
    for cy in range(101):
      res=[]
      for i in range(n):
        x=pos[i][0]
        y=pos[i][1]
        h=pos[i][2]
        if h !=0:
          res.append(h+abs(x-cx)+abs(y-cy))
      if len(set(res)) ==1:
        return [cx,cy,res[0]]
cx,cy,h=solve()
print(cx,cy,h)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    for cx in range(101):
        for cy in range(101):
            ch = {
                hi + abs(xi - cx) + abs(yi - cy)
                for xi, yi, hi in zip(x, y, h)
                if hi != 0
            }
            if len(ch) != 1:
                continue
            print(cx, cy, list(ch)[0])
            return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    h = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
li = [0]*N
for i in range(N):
    li[i] = inputlist()
for cx in range(101):
    for cy in range(101):
        l = []
        for i in range(N):
            x,y,h = li[i]
            H = h + abs(cx-x)+abs(cy-y)
            l.append(H)
        if len(set(l)) == 1:
            ha = l[0]
            count = 0
            for i in range(N):
                x,y,h = li[i]
                if max(ha-abs(cx-x)-abs(cy-y),0) == h:
                    count+=1
            if count == N:
                print(cx,cy,ha)

Submission status: Wrong Answer

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
li = [0]*N
for i in range(N):
    li[i] = inputlist()
for cx in range(101):
    for cy in range(101):
        l = []
        for i in range(N):
            x,y,h = li[i]
            H = h + abs(cx-x)+abs(cy-y)
            l.append(H)
        if len(set(l)) == 1:
            print(cx,cy,l[0])

Submission status: Wrong Answer

Solution code:
#template
def inputlist(): return [int(k) for k in input().split()]
#template
N = int(input())
li = [0]*N
for i in range(N):
    li[i] = inputlist()
for cx in range(101):
    for cy in range(101):
        l = []
        for i in range(N):
            x,y,h = li[i]
            if h == 0:
                continue
            H = h + abs(cx-x)+abs(cy-y)
            l.append(H)
        if len(set(l)) == 1:
            print(cx,cy,l[0])
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int,input().split()))for _ in range(n)]
for xx in range(101):
  for yy in range(101):
    f=True
    hh=xyh[0][2]+abs(xx-xyh[0][0])+abs(yy-xyh[0][1])
    for x,y,h in xyh[1:]:
      if max(hh-abs(x-xx)-abs(y-yy),0)!=h:f=False
    if f:print(xx,yy,hh);exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int,input().split()))for _ in range(n)]
for xx in range(101):
  for yy in range(101):
    f=True
    hh=xyh[0][2]+abs(xx-xyh[0][0])+abs(yy-xyh[0][1])
    for x,y,h in xyh[1:]:
      if hh-abs(x-xx)-abs(y-yy)!=h:f=False
    if f:print(xx,yy,hh);exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
a = abs
z = [list(map(int, input().split()[::-1])) for _ in range(int(input()))]
z.sort
h, y, x = z[-1]
r = range(101)
for c in r:
    for d in r:
        H = h + a(c-x) + a(d-y)
        if all(u == max(H - a(s-c) - a(t-d), 0) for u, t, s in z):
            print(c, d, H)
            exit()

Submission status: Wrong Answer

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

def calc_h(cx, cy, xyh):
    return xyh[2] + abs(cx - xyh[0]) + abs(cy - xyh[1])

base = -1
for i in range(n):
    if xyhn[i][2] != 0:
        base = i
        break

ans = None
for cx in range(0, 101):
    for cy in range(0, 101):
        result = True
        tmp_h = calc_h(cx, cy, xyhn[base])
        for k in range(n):
            if xyhn[k][2] > 0 and tmp_h != calc_h(cx, cy, xyhn[k]):
                result = False
                break
        if result:
            ans = [cx, cy, calc_h(cx, cy, xyhn[base])]
            break

print(' '.join(map(str, list(ans))))

Submission status: Wrong Answer

Solution code:
import sys
import collections
from math import ceil

ma = lambda : map(int,input().split())
ni = lambda : int(input())
def height(cy,cx,y,x):
    return hs[y][x] + abs(cy-y) + abs(cx-x)

n = ni()
hs = [[-1]*101 for i in range(101)]
ls = []
#E h >0?
for i in range(n):
    x,y,h = ma()
    hs[y][x] = h
    ls.append((y,x))

for cy in range(101):
    for cx in range(101):
        hmin = 10**10
        se = set()
        for y,x in ls:
            if hs[y][x] >0:
                se.add(height(cy,cx,y,x))
            else:
                hmin = min(hmin,height(cy,cx,y,x))
        if len(se) ==1:
            h = se.pop()
            if h>=hmin or hmin==10**10:
                print(cx,cy,h)
                exit()

Submission status: Wrong Answer

Solution code:
import sys
import collections
from math import ceil

ma = lambda : map(int,input().split())
ni = lambda : int(input())
def height(cy,cx,y,x):
    return hs[y][x] + abs(cy-y) + abs(cx-x)

n = ni()
hs = [[-1]*101 for i in range(101)]
ls = []
#e h >0
for i in range(n):
    x,y,h = ma()
    hs[y][x] = h
    if h>=1:
        ls.append((y,x))

for cy in range(101):
    for cx in range(101):

        se = set()
        for y,x in ls:
            se.add(height(cy,cx,y,x))
        if len(se) ==1:
            print(cx,cy,se.pop())
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
    for y in range(101):
        a,s,d=l[0]
        k=set(d+abs(x-a)+abs(s-y)  for a,s,d in l )
        for pre in k:
            for a,s ,d in l:
                if d!=max(0,pre-abs(x-a)-abs(s-y)):break
            print(x,y,pre);exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
    for y in range(101):
        a,s,d=l[0]
        k=set(d+abs(x-a)+abs(s-y)  for a,s,d in l if d)
        if len(k)==1 and list(k)[0]>=1:print(x,y,list(k)[0]);exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
    for y in range(101):
        a,s,d=l[0]
        k=set(d+abs(x-a)+abs(s-y) for a,s,d in l)
        if len(k)==1 and list(k)[0]>=1:print(x,y,sum(k));exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
for x in range(101):
    for y in range(101):
        a,s,d=l[0]
        k=set(d+abs(x-a)+abs(s-y) for a,s,d in l)
        if len(k)==1 and list(k)[0]:print(x,y,sum(k));exit()

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    X = []
    Y = []
    H = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h > 0:
            X.append(x)
            Y.append(y)
            H.append(h)

    for cx in range(0, 101):
        for cy in range(0, 101):
            res = set()
            for i, h in enumerate(H):
                d = abs(X[i] - cx) + abs(Y[i] - cy)
                res.add(d + h)
            if len(res) == 1:
                return print(cx, cy, res.pop())


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    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)

    INF = 1000000005

    for cx in range(0, 101):
        for cy in range(0, 101):
            res = set()
            min_h = INF
            for i in range(N):
                d = abs(X[i] - cx) + abs(Y[i] - cy)
                h = H[i]
                if h > 0:
                    res.add(d + h)
                elif d > 0:
                    min_h = min(min_h, d)
            if len(res) == 0:
                return print(cx, cy, min_h)
            elif len(res) == 1:
                ans = res.pop()
                if min_h != INF:
                    if ans >= min_h:
                        return print(cx, cy, ans)
                    else:
                        continue
                else:
                    return print(cx, cy, ans)
            else:
                continue


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    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)

    INF = 1000000005

    for cx in range(0, 101):
        for cy in range(0, 101):
            res = set()
            min_h = INF
            for i in range(N):
                d = abs(X[i] - cx) + abs(Y[i] - cy)
                h = H[i]
                if h > 0:
                    res.add(d + h)
                elif d > 0:
                    min_h = min(min_h, d)
            if len(res) == 0:
                return print(cx, cy, min_h)
            elif len(res) == 1:
                return print(cx, cy, res.pop())
            else:
                continue


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    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)

    INF = 1000000005

    for cx in range(0, 101):
        for cy in range(0, 101):
            res = set()
            min_h = INF
            for i in range(N):
                d = abs(X[i] - cx) + abs(Y[i] - cy)
                h = H[i]
                if h > 0:
                    res.add(d + h)
                else:
                    min_h = min(min_h, d)
            if len(res) == 0:
                return print(cx, cy, min_h)
            elif len(res) == 1:
                return print(cx, cy, res.pop())
            else:
                continue


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = [tuple(map(int, input().split())) for _ in range(n)]
grids = [(i, j) for i in range(101) for j in range(101)]
for x, y, h in coords:
    if h > 0:
        break    
for xj, yj in grids:
    flag = True
    base = dis(x, xj, y, yj) + h
    for xi, yi, hi in coords:
        if base != dis(xi, xj, yi, yj) + hi:
            flag = False
    if flag:
        break
print(xj, yj, dis(x, xj, y, yj) + h)

Submission status: Wrong Answer

Solution code:
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = [tuple(map(int, input().split())) for _ in range(n)]
coords = sorted(coords, reverse=True)
grids = [(i, j) for i in range(101) for j in range(101)]
for x, y, h in coords:
    if h > 0:
        break    
for xj, yj in grids:
    flag = True
    x0, y0, h0 = coords[0]
    base = dis(x0, xj, y0, yj) + h0
    for xi, yi, hi in coords:
        if base != dis(xi, xj, yi, yj) + hi:
            flag = False
    if flag:
        break
print(xj, yj, dis(x, xj, y, yj) + h)

Submission status: Wrong Answer

Solution code:
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = [tuple(map(int, input().split())) for _ in range(n)]
grids = [(i, j) for i in range(101) for j in range(101)]
for x, y, h in coords:
    if h > 0:
        break    
for xj, yj in grids:
    flag = True
    x0, y0, h0 = coords[0]
    base = dis(x0, xj, y0, yj) + h0
    for xi, yi, hi in coords:
        if base != dis(xi, xj, yi, yj) + hi:
            flag = False
    if flag:
        break
print(xj, yj, dis(x, xj, y, yj) + h)

Submission status: Wrong Answer

Solution code:
def dis(xi, xj, yi, yj):
    return abs(xi - xj) + abs(yi - yj)
n = int(input())
coords = [tuple(map(int, input().split())) for _ in range(n)]
grids = [(i, j) for i in range(101) for j in range(101)]
for xj, yj in grids:
    flag = True
    x0, y0, h0 = coords[0]
    base = dis(x0, xj, y0, yj) + h0
    for xi, yi, hi in coords:
        if base != dis(xi, xj, yi, yj) + hi:
            flag = False
    if flag:
        break
print(xj, yj, dis(xi, xj, yi, yj) + hi)

Submission status: Wrong Answer

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

calculate = lambda xyh, cx, cy: abs(xyh[0] - cx) + abs(xyh[1] - cy) + xyh[2]

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidates = [calculate(xyhi, cx, cy) for xyhi in xyh]

        found = True
        height = None
        for candidate in candidates:
            if candidate <= 0: continue
            if height is None:
                height = candidate
                continue
            if candidate != height:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)

Submission status: Wrong Answer

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

calculate = lambda xyh, cx, cy: abs(xyh[0] - cx) + abs(xyh[1] - cy) + xyh[2]

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        found = True
        candidates = [calculate(xyhi, cx, cy) for xyhi in xyh]

        found = True
        height = None
        for candidate in candidates:
            if candidate < 0: continue
            if height is None:
                height = candidate
                continue
            if candidate != height:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)