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)]

"""
方針：0<=cx,cy<=100なのでcx,cyの特定は全数探索で間に合う
(cx,cy)があっていればh+(abs(cx-x)+abs(cy-y))=const
"""
for cx in range(101):
	for cy in range(101):
		const = xyh[0][2] + (abs(cx-xyh[0][0]) + abs(cy-xyh[0][1]))
		correct_center = True
		for i in range(N):
			if const != xyh[i][2] + (abs(cx-xyh[i][0]) + abs(cy-xyh[i][1])):
				correct_center = False
				break
		if correct_center:
			break
	if correct_center:
		break

H = xyh[0][2] + abs(cx-xyh[0][0]) + abs(cy-xyh[0][1])
print(cx,cy,H)

Submission status: Wrong Answer

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

ans = []
for X in range(101):
    for Y in range(101):
        flag = True
        height = []
        for i in range(n):
            if h[i] >= 1:
                height.append(h[i]+abs(x[i]-X)+abs(y[i]-Y))
        for i in range(len(height)):
            if height[i] != height[0]:
                flag = False
        if flag:
            print(X, Y, height[0])
            break

Submission status: Wrong Answer

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

ans = []
for X in range(101):
    for Y in range(101):
        flag = True
        height = []
        for i in range(n):
            height.append(h[i]+abs(x[i]-X)+abs(y[i]-Y))
        for i in range(n):
            if height[i] != height[0]:
                flag = False

        if flag:
            print(X, Y, height[0])
            break

Submission status: Wrong Answer

Solution code:
def main():
    from operator import itemgetter
    from itertools import product

    n, *xyh = map(int, open(0).read().split())
    a = range(101)

    for x, y in product(a, a):
        l = None
        for i, j, h in zip(*[iter(xyh)]*3):
            hh = h + abs(x - i) + abs(y - j)
            if l:
                if l != hh or hh < 0:
                    l = None
                    break
            else:
                l = hh
        else:
            print(x, y, l)
            break


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from operator import itemgetter
    n, *xyh = map(int, open(0).read().split())
    xyh = list(zip(*[iter(xyh)] * 3))
    xyh.sort(key=itemgetter(2,0,1))
    
    x, y, now = xyh[0]
    c, r = -1, -1

    for i, j, h in xyh[1:]:
        if h > now:
            x, y, now = i, j, h
        elif h == now:
            if i == x:
                r = (j + y) // 2
                x, y = i, j
            elif j == y:
                c = (i + x) // 2
                x, y = i, j

    if c == -1 and r != -1:
        c = 50 + 50 * (-1) ** (y < 50)
    elif r == -1 and c != -1:
        r = 50 + 50 * (-1) ** (x < 50)
    elif r == -1 and c == -1:
        c = 50 + 50 * (-1) ** (x < 50)
        r = 50 + 50 * (-1) ** (y < 50)

    h = now + abs(c - x) + abs(r - y)
    print(c, r, h)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *xyh = map(int, open(0).read().split())
    xyh = list(zip(*[iter(xyh)] * 3))
    xyh.sort(key=lambda x: x[0])

    x, y, now = xyh[0]
    c, r = -1, -1

    for i, j, h in xyh[1:]:
        if h > now:
            x, y, now = i, j, h
        elif h == now:
            if i == x:
                r = (j + y) // 2
            elif j == y:
                c = (i + x) // 2
            x, y, now = i, j, h

    if c == -1 and r != -1:
        c = 50 + 50 * (-1) ** (y < 50)
    elif r == -1 and c != -1:
        r = 50 + 50 * (-1) ** (x < 50)
    elif r == -1 and c == -1:
        c = 50 + 50 * (-1) ** (x < 50)
        r = 50 + 50 * (-1) ** (y < 50)

    h = now + abs(c - x) + abs(r - y)
    print(x,y)
    print(c, r, h)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, *xyh = map(int, open(0).read().split())
    xyh = list(zip(*[iter(xyh)] * 3))
    xyh.sort(key=lambda x: x[2])

    x, y, now = xyh[0]
    c, r = -1, -1

    for i, j, h in xyh[1:]:
        if h > now:
            x, y, now = i, j, h
        elif h == now:
            if i == x:
                r = (j + y) // 2
            elif j == y:
                c = (i + x) // 2
            x, y, now = i, j, h

    if c == -1 and r != -1:
        c = 50 + 50 * (-1) ** (y < 50)
    elif r == -1 and c != -1:
        r = 50 + 50 * (-1) ** (x < 50)
    elif r == -1 and c == -1:
        c = 50 + 50 * (-1) ** (x < 50)
        r = 50 + 50 * (-1) ** (y < 50)


    h = now + abs(c - x) + abs(r - y)
    print(c, r, h)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
xyh = [LI() for _ in range(n)]
lst = []
for cx in range(101):
    for cy in range(101):
        for x,y,h in xyh:
            X,Y = abs(cx-x), abs(cy-y)
            if h == 0:
                lst.append([X+Y,cx,cy,1])
            else:
                lst.append([X+Y+h,cx,cy,0])
for a,b,c,d in lst:
    if d == 1:
        for H in range(1,a+1):
            for x,y,h in xyh:
                if max(H - abs(x-b) - abs(y-c),0) != h:
                    break
            else:
                print(H,b,c)
                quit()
    else:
        for x,y,h in xyh:
            if max(a - abs(x-b) - abs(y-c),0) != h:
                break
        else:
            print(b,c,a)
            quit()

Submission status: Wrong Answer

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
t = []
for i in range(n):
    t.append(inl())
for i in range(n):
    if t[i][2]>0:
        k = i
        break
for cx in range(101):
    for cy in range(101):
        h = t[k][2]+abs(t[k][0]-cx)+abs(t[k][1]-cy)
        ok = True
        for i in range(n):
            if h != max(0,t[i][2]+abs(t[i][0]-cx)+abs(t[i][1]-cy)):
                ok = False
                break
        if ok:
            print("{} {} {}".format(cx,cy,h))
            exit()

Submission status: Wrong Answer

Solution code:
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
t = []
for i in range(n):
    t.append(inl())
for i in range(n):
    if t[i][2]>0:
        k = i
        break
for cx in range(101):
    for cy in range(101):
        h = t[k][2]+abs(t[k][0]-cx)+abs(t[k][1]-cy)
        ok = True
        for i in range(n):
            if h != t[i][2]+abs(t[i][0]-cx)+abs(t[i][1]-cy):
                ok = False
                break
        if ok:
            print("{} {} {}".format(cx,cy,h))
            exit()

Submission status: Wrong Answer

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

for i in range(101):
  for j in range(101):
    H=xyh[0][2]+abs(i-xyh[0][0])+abs(j-xyh[0][1])
    cnt=1
    for k in range(1,N):
      if H==xyh[k][2]+abs(i-xyh[k][0])+abs(j-xyh[k][1]):
        cnt+=1
      else:
        break
    if cnt==N:
      print(i,j,H)
      exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        x, y, h = map(int, input().split())
        yield x, y, h

def check(lines, cx, cy):
    for x, y, h in lines:
        yield h + abs(x - cx) + abs(y - cy)

def main():
    n = int(input())
    lines = list(readlines(n))
    for cx in range(101):
        for cy in range(101):
            res = set(check(lines, cx, cy))
            if len(res) == 1:
                H = res.pop()
                for x, y, h in lines:
                    if max(H - abs(x - cx) - abs(y - cy), 0) == h:
                        print(cx, cy, H)
                        return



main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        x, y, h = map(int, input().split())
        yield x, y, h

def check(lines, cx, cy):
    for x, y, h in lines:
        if h > 0:
            yield h + abs(x - cx) + abs(y - cy)

def main():
    n = int(input())
    lines = list(readlines(n))
    for cx in range(101):
        for cy in range(101):
            res = set(check(lines, cx, cy))
            if len(res) == 1:
                H = res.pop()
                for x, y, h in lines:
                    if max(H - abs(x - cx) - abs(y - cy), 0) == h:
                        print(cx, cy, H)
                        return



main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        x, y, h = map(int, input().split())
        yield x, y, h

def check(lines, cx, cy):
    for x, y, h in lines:
        yield h + abs(x - cx) + abs(y - cy)

def main():
    n = int(input())
    lines = list(readlines(n))
    for cx in range(101):
        for cy in range(101):
            res = set(check(lines, cx, cy))
            if len(res) == 1:
                H = res.pop()
                for x, y, _ in lines:
                    if H - abs(x - cx) - abs(y - cy) > 0:
                        print(cx, cy, H)
                        return



main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        x, y, h = map(int, input().split())
        yield x, y, h

def check(lines, cx, cy):
    for x, y, h in lines:
        yield h + abs(x - cx) + abs(y - cy)

def main():
    n = int(input())
    lines = list(readlines(n))
    for cx in range(101):
        for cy in range(101):
            if len(set(check(lines, cx, cy))) == 1:
                x, y, h = lines[0]
                print(cx, cy, h + abs(x - cx) + abs(y - cy))


main()

Submission status: Wrong Answer

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

def func():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh if el[2]!=0]
            if H[0]>=1 and len(set(H))==1:
                temp=[H[0]-abs(el[0]-Cx)-abs(el[0]-Cy) for el in xyh if el[2]==0]
                for el in temp:
                    if el>0:
                        break
                else:
                    print(Cx, Cy, H[0])
                    return None
func()

Submission status: Wrong Answer

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

def func():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh if el[2]!=0]
            if len(set(H))==1:
                temp=[H[0]-abs(el[0]-Cx)-abs(el[0]-Cy) for el in xyh if el[2]==0]
                for el in temp:
                    if el>0:
                        break
                else:
                    print(Cx, Cy, H[0])
                    return None
func()

Submission status: Wrong Answer

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

def func():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh]
            if len(set(H))==1:
                print(Cx, Cy, H[0])
                return None
func()

Submission status: Wrong Answer

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

for Cx in range(0, 101):
    for Cy in range(0, 101):
        H=[el[2]+abs(el[0]-Cx)+abs(el[1]-Cy) for el in xyh]
        if len(set(H))==1:
            print(Cx, Cy, H[0])

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        res = []
        for i in range(n):
            x, y, h = query[i]
            p = abs(x - cx) + abs(y - cy)
            H = h + p
            if h != 0:
                res.append(H)

        if len(set(res)) == 1:
            print(cx, cy, res[0])
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        res = []
        for i in range(n):
            x, y, h = query[i]
            p = abs(x - cx) + abs(y - cy)
            H = h + p
            res.append(H)

        if len(set(res)) == 1:
            print(cx, cy, res[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for _ in range(n)]
for i in range(0,101):
  for j in range(0,101):
    h_list = [(abs(xyh[0][0] - i) + abs(xyh[0][1] - j) + xyh[0][2])]
    for k in xyh:
      h = abs(k[0] - i) + abs(k[1] - j) + k[2]
      if (h >= 1) and (h_list[0] == h):
        h_list.append(h)
      else:
        break
    if len(h_list) - 1 == n:
      print(i,j,h_list[0])
      exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[]
e=[]
for i in range(N):
  d.append(list(map(int,input().split())))
for i in range(N):
  if d[i][2]!=0:
    e.append(d[i])
for x in range(101):
  for y in range(101):
    D=set([])
    E=set([])
    for i in range(N):
      D.add(d[i][2]+abs(x-d[i][0])+abs(y-d[i][1]))
    for i in range(len(e)):
      E.add(e[i][2]+abs(x-e[i][0])+abs(y-e[i][1]))
    if len(D)==1:
      print(x,y,max(D))
      exit()
    if len(E)==1:
      print(x,y,max(E))

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[]
e=[]
for i in range(N):
  d.append(list(map(int,input().split())))
for i in range(N):
  if d[i][2]==0:
    e.append(d[i])
for x in range(101):
  for y in range(101):
    D=set([])
    E=set([])
    for i in range(N):
      D.add(d[i][2]+abs(x-d[i][0])+abs(y-d[i][1]))
    for i in range(len(e)):
      E.add(e[i][2]+abs(x-e[i][0])+abs(y-e[i][1]))
    if len(D)==1:
      print(x,y,max(D))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]

for i in range(n):
    a,b,c=map(int,input().split())
    if c!=0:
        x.append(a)
        y.append(b)
        h.append(c)
if len(x)==0:
    print(0,0,0)
    exit()
else:
    n=len(x)

#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=abs(i-x[0])+abs(j-y[0])+h[0]
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                break
        else:
            print(i,j,ha)
            exit()
#print("DFGH")

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]

for i in range(n):
    a,b,c=map(int,input().split())
    if c!=0:
        x.append(a)
        y.append(b)
        h.append(c)
if len(x)==0:
    print(0,0,0)
else:
    n=len(x)

#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=abs(i-x[0])+abs(j-y[0])+h[0]
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                break
        else:
            print(i,j,ha)
            exit()
#print("DFGH")

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]

for i in range(n):
    a,b,c=map(int,input().split())
    if c!=0:
        x.append(a)
        y.append(b)
        h.append(c)
n=len(x)

#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=abs(i-x[0])+abs(j-y[0])+h[0]
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                break
        else:
            print(i,j,ha)
            exit()
#print("DFGH")

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[]
d0=[]
d1=[]
for i in range(N):
  d.append(list(map(int,input().split())))
for i in range(N):
  if d[i][2]==0:
    d0.append(d[i])
  else:
    d1.append(d[i])
#________________________
cx=0
cy=0
for x in range(101):
  for y in range(101):
    H=d1[0][2]+abs(x-d1[0][0])+abs(y-d1[0][1])
    c=0
    for i in range(len(d1)):
      if max((H-abs(x-d1[i][0])-abs(y-d1[i][1])),0)==d1[i][2]:
        c+=1
    if c==len(d1):
      cx=x
      cy=y
      cnt=0
      for j in range(len(d0)):
        if max((H-abs(x-d0[j][0])-abs(y-d0[j][1])),0)==0:
          cnt+=1
      if cnt==len(d0):
        ans=[cx,cy,H]
      else:
        ans=[-1]
        break
  else:
    continue
  ans=[-1]
  break
for i in range(len(ans)):
  print(ans[i],end=' ')

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[]
d0=[]
d1=[]
for i in range(N):
  d.append(list(map(int,input().split())))
for i in range(N):
  if d[i][2]==0:
    d0.append(d[i])
  else:
    d1.append(d[i])
cx=0
cy=0
for x in range(101):
  for y in range(101):
    H=d1[0][2]+abs(x-d1[0][0])+abs(y-d1[0][1])
    c=0
    for i in range(len(d1)):
      if max((H-abs(x-d1[i][0])-abs(y-d1[i][1])),0)==d1[i][2]:
        c+=1
    if c==len(d1):
      cx=x
      cy=y
      break
  else:
    continue
  ans=[-1]
  break
cnt=0
for j in range(len(d0)):
  if max((H-abs(x-d0[j][0])-abs(y-d0[j][1])),0)==0:
    cnt+=1
if cnt==len(d0):
  ans=[cx,cy,H]
else:
  ans=[-1]
for i in range(len(ans)):
  print(ans[i],end=' ')

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]




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

if n==1:
    print(x[0],y[0],h[0])
    exit()

#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=abs(i-x[0])+abs(j-y[0])+h[0]
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                break
        else:
            print(i,j,ha)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=abs(i-x[0])+abs(j-y[0])+h[0]
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                break
        else:
            print(i,j,ha)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=max(0,abs(i-x[0])+abs(j-y[0])+h[0])
        count=0
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                
                break
            else:
                count+=1
        if count==n-1:
            print(i,j,ha)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
#print(h)
#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=max(0,abs(i-x[0])+abs(j-y[0])+h[0])
        for z in range(1,n):#違うかの確かめ作業
            if h[z] != max(ha-abs(i-x[z])-abs(j-y[z]),0):
                break
        else:
            print(i,j,ha)
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
#print(h)
ha=1 
xa=0
ya=0
ha=0

#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        ha=max(0,abs(i-x[0])+abs(j-y[0])+h[0])
        for z in range(1,n):#違うかの確かめ作業
            if ha!=max(0,abs(i-x[z])+abs(j-y[z])+h[z]):
                break
        else:
            print(i,j,ha)
            exit()

Submission status: Wrong Answer

Solution code:
import sys

# import bisect
from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


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

    hbase = 0
    idx = 0
    while hbase == 0:
        xbase = xyh[0][0]
        ybase = xyh[0][1]
        hbase = xyh[idx][2]
        idx += 1

    for x in range(101):
        for y in range(101):
            h = hbase + (abs(xbase - x) + abs(ybase - y))
            for i in range(n):
                htemp = max((h - (abs(xyh[i][0] - x) + abs(xyh[i][1] - y)), 0))
                if htemp != xyh[i][2]:
                    break
            else:
                print(x, y, h)
                sys.exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

# import bisect
from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
from operator import attrgetter, itemgetter

# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    xyh = [list(map(int, readline().split())) for _ in range(n)]
    xbase = xyh[0][0]
    ybase = xyh[0][1]


    for x in range(101):
        for y in range(101):
            d = defaultdict(list)
            for i in range(n):
                diff = abs(xyh[i][0] - x) + abs(xyh[i][1] - y)
                d[diff].append(i)

            h = xyh[0][2] + (abs(xyh[0][0] - x) + abs(xyh[0][1] - y))

            for key, indices in d.items():
                hl = [xyh[index][2] for index in indices]
                if len(set(hl)) != 1:
                    break
                elif (h - key) != hl[0]:
                    break
            else:
                print(x, y, xyh[0][2] + abs(xyh[0][0] - x) + abs(xyh[0][1] - y))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for a,b,c in points:
  if c>0:
    a,b,c
    break

f = lambda x, y: abs(i-x) + abs(j-y)

for i in range(101):
  for j in range(101):
    height = c + f(a, b)
    flg = True
    for x, y, h in points:
      if height != max(h + f(x, y), 0):
        flg = False
        break
    if flg:
      print(i, j, height)
      sys.exit()

Submission status: Wrong Answer

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

f = lambda x, y: abs(i-x) + abs(j-y)

for i in range(101):
  for j in range(101):
    x, y, h = points[0]
    d = f(x, y)
    height = h + d
    flg = True
    for x, y, h in points:
      d = f(x, y)
      if height != h + d:
        flg = False
        break
    if flg:
      print(i, j, height)
      sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split(' '))) for i in range(N)]
for i in range(101):
    for j in range(101):
        H=set([h+abs(x-i)+abs(y-j) for x,y,h in xyh if h!=0])
        if len(H)==1:
            print(i,j,max(H))
            exit()
raise TypeError

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split(' '))) for i in range(N)]
for i in range(101):
    for j in range(101):
        H=set([h+abs(x-i)+abs(y-j) for x,y,h in xyh if h!=0])
        if len(H)==1:
            print(i,j,max(H))
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split(' '))) for i in range(N)]
for i in range(101):
    for j in range(101):
        if len(set([h+abs(x-i)+abs(y-j) for x,y,h in xyh if h!=0]))==1:
            print(i,j,xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j))
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
xyh=[list(map(int,input().split(' '))) for i in range(N)]
for i in range(101):
    for j in range(101):
        if len(set([h+abs(x-i)+abs(y-j) for x,y,h in xyh]))==1:
            print(i,j,xyh[0][2]+abs(xyh[0][0]-i)+abs(xyh[0][1]-j))
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    a,b,c=map(int,input().split())
    x.append(a)
    y.append(b)
    h.append(c)
#print(h)
ha=1 
xa=0
ya=0
ha=10**9+1

#中心座標を列挙
for i in range(101):#x
    for j in range(101):#y
        hc=1
        for z in range(n):#高さのmaxを調べるため
            hc=max(hc,h[z]+abs(x[z]-i)+abs(y[z]-j))
        #print(i,j,hc)
        if ha>=hc:
            xa=i
            ya=j
            ha=hc
print(xa,ya,ha)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(101):
    for j in range(101):
        H = []
        MIN = 10**9 + 1
        for k in range(n):
            if a[k][2] == 0:
                MIN = min(MIN, abs(a[k][0] - i) + abs(a[k][1] - j))
            else:
                H.append(a[k][2] + abs(a[k][0] - i) + abs(a[k][1] - j))
        if len(set(H)) == 1 and H[0] <= MIN:
            print(i, j, H[0])
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
MIN = 10**9 + 1
for i in range(101):
    for j in range(101):
        H = []
        for k in range(n):
            if a[k][2] == 0:
                MIN = min(MIN, abs(a[k][0] - i) + abs(a[k][1] - j))
            else:
                H.append(a[k][2] + abs(a[k][0] - i) + abs(a[k][1] - j))
        if len(set(H)) == 1 and H[0] <= MIN:
            print(i, j, H[0])
            exit()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    points = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        points.append((x, y, h))
        if h >= 1:
            hint = (x, y, h)

    for px in range(1, 101):
        for py in range(1, 101):
            H = hint[2] + abs(px-hint[0]) + abs(py-hint[1])
            clearflag = True
            for point in points:
                x, y, h = point
                val = max([H - abs(px-x) - abs(py-y), 0])
                if val != h:
                    clearflag = False

            if clearflag:
                print(px, py, H)
                return
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[]
for i in range(n):
	x,y,h=map(int,input().split())
	xyh.append((x,y,h))
def dis(a,b):
	return abs(a[0]-b[0])+abs(a[1]-b[1])
for i in range(101):
	for j in range(101):
		f=1
		kari=-1
		if xyh[0][2]!=0:
			kari=dis(xyh[0],(i,j))+xyh[0][2]
		for k in range(1,n):
			if xyh[k][2]!=0:
				r=dis(xyh[k],(i,j))+xyh[k][2]
				if kari!=-1 and kari!=r:
					f=0
					break
				kari=r
		if f:
			print(i,j,kari)

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[]
for i in range(n):
	x,y,h=map(int,input().split())
	xyh.append((x,y,h))
def dis(a,b):
	return abs(a[0]-b[0])+abs(a[1]-b[1])
for i in range(101):
	for j in range(101):
		f=1
		kari=dis(xyh[0],(i,j))+xyh[0][2]
		for k in range(1,n):
			r=dis(xyh[k],(i,j))+xyh[k][2]
			if r!=kari:
				f=0
				break
		if f:
			print(i,j,kari)

Submission status: Wrong Answer

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

for cx in range(0,101):
    for cy in range(0,101):
        H = [0]*N
        for i in range(N):
            H[i] = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
        if max(H) == min(H):
            print(cx,cy,max(H))
            sys.exit()

Submission status: Wrong Answer

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

for cx in range(1,101):
    for cy in range(1,101):
        H = [0]*N
        for i in range(N):
            H[i] = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
        if max(H) == min(H):
            print(cx,cy,max(H))
            sys.exit()

Submission status: Wrong Answer

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

if all(h[i]==0 for i in range(N)):
    c = 0
    for j in range(1000000000):
        c += 1

for i in range(101):
    for j in range(101):
        
        for k in range(N):
            if h[k] == 0:
                continue
            H = abs(i-x[k]) + abs(j-y[k]) + h[k]
            break

        for k in range(N):
            if h[k] == 0:
                continue
            if H != abs(i-x[k]) + abs(j-y[k]) + h[k]:
                break
        else:
            print(i,j,H)