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())
G = [list(map(int,input().split())) for k in range(N)]

for Cx in range(101):
    for Cy in range(101):
        f = 1
        H = G[0][2] + abs(Cx-G[0][0]) + abs(Cy-G[0][1])
        for k in range(1,N):
            if G[k][2] + abs(Cx-G[k][0]) + abs(Cy-G[k][1]) != H:
                f = 0
        if f:
            print(Cx,Cy,H)
            exit(0)

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):
        height = -1
        for x, y, h in XYH:
            hi = abs(x - i) + abs(y - j) + h
            if height == -1:
                height = hi
            else:
                if height == hi:
                    pass
                else:
                    break
        else:
            print(i, j, height)
            exit()

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#

"""
RC112 C
"""

n = int(input())
xyhlist = [tuple(map(int,input().split())) for i in range(n)]

from itertools import product
for x,y in product(range(0,101),range(0,101)):
    test = set(map(lambda t:t[2]+abs(t[0]-x)+abs(t[1]-y),xyhlist))
    if len(test) == 1:
        print(x,y,test.pop())
        exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
    s=input().split()
    x.append(int(s[0]))
    y.append(int(s[1]))
    h.append(int(s[2]))
for cx in range(101):
    for cy in range(101):
        hh=h[0]+abs(cx-x[0])+abs(cy-y[0])
        flag=True
        for i in range(n):
            if hh!=h[i]+abs(cx-x[i])+abs(cy-y[i]):
                flag=False
                break
        if flag:
            print(cx,cy,hh)

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(101):
    for j in range(101):
        LIST=[]
        for xyh in XYH:
            if xyh[2]==0:
                continue
            else:
                LIST.append(abs(i-xyh[0])+abs(j-xyh[1])+xyh[2])

        if min(LIST)==max(LIST):
            print(i,j,LIST[0])
            sys.exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
hs=[xyh[i][-1] for i in range(n)]
mh=min(hs)
for cx in range(101):
    for cy in range(101):
        for h in range(mh,mh+101):
            j=True
            for i in range(n):
                if max(h-abs(xyh[i][0]-cx)-abs(xyh[i][1]-cy),0)!=xyh[i][2]:
                    j=False
            if j:
                print(cx,cy,h)
                break

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
valid = [[0 for x in range(101)] for x in range(101)]
certain = [[1 for x in range(101)] for x in range(101)]
x,y,h = map(int,raw_input().split())
for i in range(101):
    for j in range(101):
        valid[i][j] = h+abs(i-x)+abs(j-y)
        if not h:
            certain[i][j] = 0
for i in range(N-1):
    x,y,h = map(int,raw_input().split())
    for j in range(101):
        for k in range(101):
            if not h:
                if valid[j][k]>abs(j-x)+abs(k-y):
                    valid[j][k] = 0
            else:
                if valid[j][k]!=h+abs(j-x)+abs(k-y):
                    if not certain[j][k] and h+abs(j-x)+abs(k-y)<valid[j][k]:
                        certain[j][k] = 1
                        valid[j][k] = h+abs(j-x)+abs(k-y)
                    else:
                        valid[j][k] = 0
for i in range(101):
    for j in range(101):
        if valid[i][j]:
            print i,j,valid[i][j]

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for Cx in range(101):
    for Cy in range(101):
        candidate_set = set()
        for x, y, h in Info:
            H = abs(Cx - x) + abs(Cy - y) + h

            if H >= 0:
                candidate_set.add(H)

        if len(candidate_set) == 1:
            print(Cx, Cy, abs(Cx - Info[0][0]) + abs(Cy - Info[0][1]) + Info[0][2])
            exit()

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
valid = [[0 for x in range(101)] for x in range(101)]
x,y,h = map(int,raw_input().split())
for i in range(101):
    for j in range(101):
        valid[i][j] = h+abs(i-x)+abs(j-y)
for i in range(N-1):
    x,y,h = map(int,raw_input().split())
    for j in range(101):
        for k in range(101):
            if not h:
                if valid[j][k]>abs(j-x)+abs(k-y):
                    valid[j][k] = 0
            else:
                if valid[j][k]!=h+abs(j-x)+abs(k-y):
                    valid[j][k] = 0
for i in range(101):
    for j in range(101):
        if valid[i][j]:
            print i,j,valid[i][j]

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
valid = [[0 for x in range(101)] for x in range(101)]
x,y,h = map(int,raw_input().split())
for i in range(101):
    for j in range(101):
        valid[i][j] = h+abs(i-x)+abs(j-y)
for i in range(N-1):
    x,y,h = map(int,raw_input().split())
    for j in range(101):
        for k in range(101):
            if not h:
                if valid[j][k]<h+abs(j-x)+abs(k-y):
                    valid[j][k] = 0
            else:
                if valid[j][k]!=h+abs(j-x)+abs(k-y):
                    valid[j][k] = 0
for i in range(101):
    for j in range(101):
        if valid[i][j]:
            print i,j,valid[i][j]

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
valid = [[0 for x in range(101)] for x in range(101)]
x,y,h = map(int,raw_input().split())
for i in range(101):
    for j in range(101):
        valid[i][j] = h+abs(i-x)+abs(j-y)
for i in range(N-1):
    x,y,h = map(int,raw_input().split())
    for j in range(101):
        for k in range(101):
            if valid[j][k]!=h+abs(j-x)+abs(k-y):
                valid[j][k] = 0
for i in range(101):
    for j in range(101):
        if valid[i][j]:
            print i,j,valid[i][j]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
list_XYH = []
m = pow(10, 10)
for _ in range(n):
    x, y, h = map(int, input().split())
    m = min(m, h)
    list_XYH.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
z = [0]*n
for i in range(n):
    z[i] = list(map(int,input().split()))
sw2 = 0
sw3 = 0
ans = [0,0,0]
for X in range(101):
    for Y in range(101):
        sw = 1
        H = -1
        
        i = 0
        while i < n:
            x,y,h = z[i][0], z[i][1], z[i][2]
            if H == -1:
                if h == 0:
                    if abs(X-x) + abs(Y-y) != 0:
                        H = abs(X-x) + abs(Y-y)
                        sw3 = 1
                    pass
                
                else:
                    H = h + abs(X-x) + abs(Y-y)
                    if i != 0:
                        i = 0
            else:
                if h != max(H - abs(X-x) - abs(Y-y), 0):
                    sw = 0
                    break
                    
            i += 1
                    
        if sw == 1:
            if H <= 0:
                pass
            else:
                ans = [X,Y,H]
                sw2 = 1
                break
                
        if sw3 == 1:
            i = 0
            while i < n:
                x,y,h = z[i][0], z[i][1], z[i][2]
                if H == -1:
                    if h == 0:
                        pass

                    else:
                        H = h + abs(X-x) + abs(Y-y)
                        if i != 0:
                            i = 0
                else:
                    if h != max(H - abs(X-x) - abs(Y-y), 0):
                        sw = 0
                        break
                        
            if sw == 1:
                if H <= 0:
                    pass
                else:
                    ans = [X,Y,H]
                    sw2 = 1
                    break
                
print(ans[0],ans[1],ans[2])

Submission status: Time Limit Exceeded

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *XYH = map(int, read().split())

    for cx in range(101):
        for cy in range(101):
            ok = 10 ** 12
            ng = 0
            while ok - ng > 1:
                mid = (ok + ng) // 2
                valid = True
                for x, y, h in zip(*[iter(XYH)] * 3):
                    if max(mid - abs(x - cx) - abs(y - cy), 0) < h:
                        valid = False
                        break
                if valid:
                    ok = mid
                else:
                    ng = mid
            H = ok
            valid = True
            for x, y, h in zip(*[iter(XYH)] * 3):
                if max(H - abs(x - cx) - abs(y - cy), 0) != h:
                    valid = False
                    break
            if valid:
                print(cx, cy, H)
                return

    return


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())
mn_h=min(h)
mx_h=max(h)
for H in range(mn_h-210,mx_h+210):
  for C_x in range(101):
    for C_y in range(101):
      for i in range(n):
        if not h[i]==max(H-abs(x[i]-C_x)-abs(y[i]-C_y),0):
          break
      else:
        print(C_x,C_y,H)
        exit()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())
mn_h=min(h)
mx_h=max(h)
for H in range(mn_h-210,mx_h+210):
  for C_x in range(101):
    for C_y in range(101):
      for i in range(n):
        if not h[i]==max(H-abs(x[i]-C_x)-abs(y[i]-C_y),0):
          break
      else:
        print(C_x,C_y,H)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = [None]*N
y = [None]*N
h = [None]*N

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

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        else:
            if H-abs(X-x[n])-abs(Y-y[n])>0:
                return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            H = height(X,Y,x[n],y[n],h[n])
            if check(x,y,h,X,Y,H) is True:
                print(X,Y,H)
                exit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = [None]*N
y = [None]*N
h = [None]*N

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

def height(X,Y,xn,yn,hn):
    return hn+abs(X-xn)+abs(Y-yn)

def check(x,y,h,X,Y,H):
    for n in range(N):
        if h[n]>0:
            if height(X,Y,x[n],y[n],h[n])!=H:
                return False
        elif H-abs(X-x[n])-abs(Y-y[n])>0:
            return False
    return True

for X in range(101):
    for Y in range(101):
        for n in range(N):
            H = height(X,Y,x[n],y[n],h[n])
            if check(x,y,h,X,Y,H) is True:
                print(X,Y,H)
                exit()

Submission status: Time Limit Exceeded

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:
        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(b,c,H)
                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: Time Limit Exceeded

Solution code:
import os, sys, re, math
 
N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N
 
for i in range(N):
    (x[i], y[i], h[i]) = [int(j) for j in input().split()]
 
minH = min(h)
maxH = max(h) + 200
 
for cx in range(101):
    for cy in range(101):
        for H in range(minH, maxH + 1):
            valid = True
            for nn in range(N):
                valid &= max(H - abs(x[nn] - cx) - abs(y[nn] - cy), 0) == h[nn]
            if valid:
                print ('%d %d %d' % (cx, cy, H))
                sys.exit(0)

Submission status: Time Limit Exceeded

Solution code:
import os, sys, re, math

N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N

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

minH = min(h)
maxH = max(h) + 200

for cx in range(min(x), max(x) + 1):
    for cy in range(min(y), max(y) + 1):
        for H in range(minH, maxH + 1):
            valid = True
            for nn in range(N):
                valid &= max(H - abs(x[nn] - cx) - abs(y[nn] - cy), 0) == h[nn]
            if valid:
                print ('%d %d %d' % (cx, cy, H))

Submission status: Time Limit Exceeded

Solution code:
import os, sys, re, math

N = int(input())
x = [0] * N
y = [0] * N
h = [0] * N

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

minH = max(min(h) - 200, 0)
maxH = max(max(h) + 200, 0)

for cx in range(min(x), max(x) + 1):
    for cy in range(min(y), max(y) + 1):
        for H in range(minH, maxH + 1):
            valid = True
            for nn in range(N):
                valid &= max(H - abs(x[nn] - cx) - abs(y[nn] - cy), 0) == h[nn]
            if valid:
                print ('%d %d %d' % (cx, cy, H))

Submission status: Time Limit Exceeded

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

for i in range(N):
    tmp = []
    for cx in range(101):
        for cy in range(101):
            if h[i] > 0:
                H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                tmp.append((cx, cy, H))
            else:
                for H in range(1, abs(x[i] - cx) + abs(y[i] - cy) + 1):
                    tmp.append((cx, cy, H))
            # setはtmp.add(要素)で追加できるが要素としてtupleを追加しようとすると和集合を書いたりしなきゃいけないので遅い
            # tupleとして要素を追加しないと全体をsetとして扱えない
    if i == 0:
        ans = tmp
    else:
        ans = set(ans) & set(tmp)

ans = list(list(ans)[0])
ans = ' '.join(list(map(str, ans)))
print(ans)

Submission status: Time Limit Exceeded

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

def check(cx, cy):
  x, y, h = xy[0]
  ch = h + abs(cx - x) + abs(cy - y)
  if h > 0:
    ch0 = [ch]
  else:
    ch0 = [i for i in range(1, ch+1)]
  
  for (x, y, h) in xy[1:]:
    ch = h + abs(cx - x) + abs(cy - y)
    if h > 0:
      ch0 = [i for i in ch0 if i == ch]
    else:
      ch0 = [i for i in ch0 if i <= ch]
    
    if len(ch0) == 0:
      return False
  return ch0[0]

for cx in range(101):
  for cy in range(101):
    ch = check(cx, cy)
    if ch:
      print(' '.join( map(str, [cx, cy, ch]) ))
      exit()

Submission status: Time Limit Exceeded

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

for Cx in range(101):
    for Cy in range(101):
        for T in range(min(H), min(H)+101):
            flag = 0
            for x,y,h in zip(X,Y,H):
                if h == max(T - abs(x-Cx) - abs(y-Cy),0):
                        flag += 1
                if flag == N:
                    print(Cx,Cy,T)
                    exit()

Submission status: Time Limit Exceeded

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] - 201),
                       max(2, xyh[0][2] + 201)):
            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: Time Limit Exceeded

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: Time Limit Exceeded

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
    log += [(x,y,H)]
if len(log)>1:
  while True:
    u = 1
print(*log[0])

Submission status: Time Limit Exceeded

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


ans = []
for i in range(101):
  for j in range(101):
    ans += [(i,j)]
log = []
for a in ans:
  i, j = a
  pH = -1
  for l in ls:
    h, x, y = l
    if h>0:
      H = h+abs(x-i)+abs(y-j)
      if pH==-1:
        pH = H
      elif not H==pH:
        break
  else:
    x, y = a
while True:
  u = 1
print(x,y,H)

Submission status: Time Limit Exceeded

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

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

for X in range(101):
    for Y in range(101):
        for i in range(n):
            H = h[i] + abs(x[i] - X) + abs(y[i] - Y)
            if all(h[j] == max(H - abs(x[j] - X) - abs(y[j] - Y), 0) for j in range(n)):
                print(X, Y, H)
                break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 1
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] < abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
print(' '.join(list(map(str,can[0]))))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  step += 1
print(' '.join(list(map(str,can[0]))))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
can = []
xyh = []
for _ in range(n):
  xyh.append(list(map(int,input().split())))
time = 0
while xyh[time][2] == 0:
  time += 1
x,y,h = xyh[time]
for i in range(101):
  for j in range(101):
    can.append([i, j, h + abs(x-i) + abs(y-j)])
step = 0
while len(can) != 1:
  x,y,h = xyh[(time + step) % n]
  if h != 0:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2] != h + abs(x-now[0]) + abs(y-now[1]):
        del can[cnt]
      else:
        cnt += 1
  else:
    cnt = 0
    while cnt < len(can):
      now = can[cnt]
      if now[2]  < abs(x-now[0]) + abs(y-now[1]):
        del now
      else:
        cnt += 1
  step += 1
print(' '.join(list(map(str,can[0]))))

Submission status: Time Limit Exceeded

Solution code:
import sys
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
#x = [xyh[i][0] for i in range(n)]
#y = [xyh[i][1] for i in range(n)]
h = [xyh[i][2] for i in range(n)]
ch=max(h)
while ch<=10000000000:
  for cx in range(101):
    for cy in range(101):
      flg=0
      for i in range(n):
        if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)>ch and xyh[i][2]!=0:
          flg=1
          break
        if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)!=ch-xyh[i][2]:
          flg=1
          break
      if flg==0:
        print(cx,cy,ch)
        sys.exit()
  ch+=1

Submission status: Time Limit Exceeded

Solution code:
import sys
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
x = [xyh[i][0] for i in range(n)]
y = [xyh[i][1] for i in range(n)]
h = [xyh[i][2] for i in range(n)]
ch=max(h)
while ch<=10000000000:
  for cx in range(101):
    for cy in range(101):
      flg=0
      for i in range(n):
        if abs(x[i]-cx)+abs(y[i]-cy)!=ch-h[i]:
          flg=1
          break
      if flg==0:
        print(cx,cy,ch)
        sys.exit()
  ch+=1

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter

N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
checked = [[False for _ in range(101)] for _ in range(101)]

xyh.sort(key=itemgetter(2), reverse=True)

q = [xyh[0]]
ans = []
while not ans:
    qq = []
    for s in q:
        x = s[0]
        y = s[1]
        for i, d in enumerate(xyh):
            if d[2] == 0:
                continue
            ch = abs(d[0] - x) + abs(d[1] - y) + d[2]
            if i == 0:
                chpre = ch
            if chpre != ch:
                break
        if chpre == ch:
            ans = [x, y, ch]
            break
        checked[x][y] = True
        nexts = [[x+1, y], [x-1, y], [x, y+1], [x, y-1]]
        for ne in nexts:
            nx = ne[0]
            ny = ne[1]
            if 0 <= nx <= 100 and 0 <= ny <= 100:
                if not checked[nx][ny]:
                    qq.append(ne)
    q = qq


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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
XYH = [list(map(int, input().split())) for _ in range(N)]
H_max = max([XYH[i][2] for i in range(N)])

ans = []

# 高さH,中心座標を(Cx, Cy)として総当たりで試す
for H in range(H_max - 200, H_max + 201):
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            count = 0
            for X, Y, h in XYH:
                if h == max(H - abs(X - Cx) - abs(Y - Cy), 0):
                    count += 1
                else:
                    break

            if count == N:
                ans = [str(Cx), str(Cy), str(H)]

print(' '.join(ans))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
XYH = [list(map(int, input().split())) for _ in range(N)]
H_max = max([XYH[i][2] for i in range(N)])

ans = []

# 高さH,中心座標を(Cx, Cy)として総当たりで試す
for H in range(H_max - 200, H_max + 201):
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            count = 0
            for X, Y, h in XYH:
                if h == max(H - abs(X - Cx) - abs(Y - Cy), 0):
                    count += 1
                else:
                    pass

            if count == N:
                ans = [str(Cx), str(Cy), str(H)]

print(' '.join(ans))

Submission status: Time Limit Exceeded

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


for i in range(101):
    for j in range(101):
        for k in range(min(h),min(h)+201):
            if all(max(k-abs(l[0]-i)-abs(l[1]-j),0) == l[2] for l in a):
                print(i,j,k)
                exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()

st=set()
prevset=set()
for i in range(N):
    x,y,h=LI()
    st = set()
    for i in range(101):
        for j in range(101):
            abso = abs(x-i)+abs(y-j)
            if not h == 0:
                st.add((i,j, h+abso))
            else:
                for k in range(1, abso+1):
                    st.add((i,j, k))

    prevset = st if not prevset else st.intersection(prevset)
    if len(prevset) == 1:
        break

print(*prevset.pop())

Submission status: Time Limit Exceeded

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

minH = int(1e9)
for xyh in xyhs:
  minH = min(minH, xyh[2])

cx, cy, H = 0, 0, 0
for h in range(minH, int(1e9)+200):
  if H != 0: break
  for x in range(101):
    if H != 0: break
    for y in range(101):
      if H != 0: break
      for xyh in xyhs:
        if max(h - abs(xyh[0]-x) - abs(xyh[1]-y), 0) != xyh[2]:
          break
      else:
        cx, cy, H = x, y, h
        break

print(cx, cy, H)

Submission status: Time Limit Exceeded

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

cx, cy, H = 0, 0, 0
for h in range(1, int(1e9)):
  if H != 0: break
  for x in range(101):
    if H != 0: break
    for y in range(101):
      if H != 0: break
      for xyh in xyhs:
        if max(h - abs(xyh[0]-x) - abs(xyh[1]-y), 0) != xyh[2]:
          break
      else:
        cx, cy, H = x, y, h
        break

print(cx, cy, H)

Submission status: Time Limit Exceeded

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

for H in range(XYH[-1][2],XYH[-1][2]+110):
    for Cx in range(101):
        for Cy in range(101):
            if all(h==max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in XYH):
                a=H;b=Cx;c=Cy
                break
print(b,c,a)

Submission status: Time Limit Exceeded

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

hmaxi = ph.index(max(ph))
pmax = p.pop(hmaxi)
hmax = ph.pop(hmaxi)
H,d = hmax,0
ans = False

while not ans:
    C = [[pmax[0]+d, pmax[1]], [pmax[0]-d, pmax[1]], [pmax[0], pmax[1]+d], [pmax[0], pmax[1]-d]]
    for i in range(d-1):
        C += [[pmax[0]+i, pmax[1]+i]]
        C += [[pmax[0]+i, pmax[1]-i]]
        C += [[pmax[0]-i, pmax[1]+i]]
        C += [[pmax[0]-i, pmax[1]-i]]
    for xy in C:
        ans = True
        for i in range(N-1):
            if ph[i] != H - abs(p[i][0]-xy[0]) - abs(p[i][1]-xy[1]):
                ans = False
                break
        if ans:
            print(xy[0],xy[1],H)
            break
    d += 1
    H += 1

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import sys
N=int(stdin.readline().rstrip())
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
for X in range(0,101):
    for Y in range(0,101):
        for data_ in data:
            H = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            flag = True
            for data__ in data:
                if max(H-abs(X-data__[0])-abs(Y-data__[1]),0) != data__[2]:
                    flag = False
            if flag:
                break
        else:
            continue
        break
    else:
        continue
    break
    
print(X,Y,H)