Problem:


Score: 300 points

Problem Statement

In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.

The pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0).  

Aoki, an explorer, conducted a survey to identify the center coordinates and height of this pyramid. As a result, he obtained the following information:  

C_X, C_Y was integers between 0 and 100 (inclusive), and H was an integer not less than 1.  

Additionally, he obtained N pieces of information. The i-th of them is: "the altitude of point (x_i, y_i) is h_i."  

This was enough to identify the center coordinates and the height of the pyramid. Find these values with the clues above.  

Constraints

N is an integer between 1 and 100 (inclusive).

x_i and y_i are integers between 0 and 100 (inclusive).

h_i is an integer between 0 and 10^9 (inclusive).

The N coordinates (x_1, y_1), (x_2, y_2), (x_3, y_3), ..., (x_N, y_N) are all different.

The center coordinates and the height of the pyramid can be uniquely identified.

Input

Input is given from Standard Input in the following format:  

N
x_1 y_1 h_1
x_2 y_2 h_2
x_3 y_3 h_3
:
x_N y_N h_N

Output

Print values C_X, C_Y and H representing the center coordinates and the height of the pyramid in one line, with spaces in between.  

Sample Input 1

4
2 3 5
2 1 5
1 2 5
3 2 5

Sample Output 1

2 2 6

In this case, the center coordinates and the height can be identified as (2, 2) and 6.  

Sample Input 2

2
0 0 100
1 1 98

Sample Output 2

0 0 100

In this case, the center coordinates and the height can be identified as (0, 0) and 100.

Note that C_X and C_Y are known to be integers between 0 and 100.

Sample Input 3

3
99 1 191
100 1 192
99 0 192

Sample Output 3

100 0 193

In this case, the center coordinates and the height can be identified as (100, 0) and 193.  



Sample input:
4
2 3 5
2 1 5
1 2 5
3 2 5


Sample output:
2 2 6

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    def ok(cur_h, cx, cy, X, Y, H):
        for x, y, _ in zip(X, Y, H):
            if cur_h - abs(cx - x) - abs(cy - y) > 0:
                return False
        return True

    for cx in range(101):
        for cy in range(101):
            zeros = 0
            H_set = set()
            zero_x, zero_y, zero_h = [], [], []
            for x, y, h in zip(X, Y, H):
                cur_h = f(x, cx, y, cy, h)
                if h == 0:
                    zero_x.append(x)
                    zero_y.append(y)
                    zero_h.append(h)
                else:
                    H_set.add(cur_h)

            if len(H_set) > 1:
                continue

            if len(H_set) == 1:
                if not ok(cur_h, cx, cy, zero_x, zero_y, zero_h):
                    continue
                print(cx, cy, cur_h)
                return

            h_arr = []
            for x, y, h in zip(zero_x, zero_y, zero_h):
                h_arr.append(f(x, cx, y, cy, 0))
            c = min(h_arr)
            if c < 1:
                continue
            print(cx, cy, c)

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    for cx in range(101):
        for cy in range(101):
            zeros = 0
            H_set = set()
            duv_set = set()
            for x, y, h in zip(X, Y, H):
                cur_h = f(x, cx, y, cy, h)
                if h == 0:
                    duv_set.add(cur_h)
                    duv_x = cx
                    duv_y = cy
                    duv = cur_h
                else:
                    H_set.add(cur_h)
            if len(H_set) > 1:
                continue
            if len(H_set) == 1:
                if cur_h < 1:
                    continue
                print(cx, cy, cur_h)
                return
            else:
                if len(duv_set) == 1:
                    if duv == 0:
                        continue
                    print(duv_s, duv_y, duv)
                    return

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    for cx in range(101):
        for cy in range(101):
            zeros = 0
            H_set = set()
            for x, y, h in zip(X, Y, H):
                cur_h = f(x, cx, y, cy, h)
                if cur_h > 1:
                    H_set.add(cur_h)
            if len(H_set) > 1:
                continue
            if len(H_set) == 1:
                if cur_h < 1:
                    continue
                print(cx, cy, cur_h)
                return

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    for cx in range(101):
        for cy in range(101):
            zeros = 0
            H_set = set()
            for x, y, h in zip(X, Y, H):
                if h == 0:
                    zeros += 1
                    continue
                cur_h = f(x, cx, y, cy, h)
                H_set.add(cur_h)
            if len(H_set) > 1:
                continue
            if len(H_set) == 1:
                if cur_h < 1:
                    continue
                print(cx, cy, cur_h)
                return
            if zeros == N:
                H = f(x, cx, y, cy, 0)
                if H < 1:
                    continue
                print(cx, cy, H)
                return
            while 1:
                pass

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    for cx in range(101):
        for cy in range(101):
            zeros = 0
            H_set = set()
            for x, y, h in zip(X, Y, H):
                if h == 0:
                    zeros += 1
                    continue
                cur_h = f(x, cx, y, cy, h)
                H_set.add(cur_h)
            if len(H_set) > 1:
                continue
            if len(H_set) == 1:
                if cur_h < 1:
                    continue
                print(cx, cy, cur_h)
                return
            if zeros == N:
                H = f(x, cx, y, cy, 0)
                if H < 1:
                    continue
                print(cx, cy, H)
                return

main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X, Y, H = [], [], []
    for _ in range(N):
        x, y, h = LI()
        X.append(x)
        Y.append(y)
        H.append(h)
    def f(x, Cx, y, Cy, h):
        return h + abs(x - Cx) + abs(y - Cy)

    for cx in range(101):
        for cy in range(101):
            zeros = 0
            H_set = set()
            for x, y, h in zip(X, Y, H):
                if h == 0:
                    zeros += 1
                    continue
                cur_h = f(x, cx, y, cy, h)
                H_set.add(cur_h)
            if len(H_set) > 1:
                continue
            if len(H_set) == 1:
                print(cx, cy, cur_h)
                return
            if zeros == N:
                H = f(x, cx, y, cy, 0)
                print(cx, cy, H)
                return

main()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[*map(int,input().split())] for _ in range(n)]
x,y,h=l[0]
for X in range(101):
  for Y in range(101):
    H=h+abs(x-X)+abs(y-Y)
    if all(h==max(H-abs(x-X)-abs(y-Y),0) for x,y,h in l): print(X,Y,H); exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[[*map(int,input().split())] for _ in range(n)]
x,y,h=l[0]
for X in range(101):
  for Y in range(101):
    H=h+abs(x-X)+abs(y-Y)
    if all(h==max(H-abs(x-X)-abs(y-Y),0) for x,y,h in l): print(X,Y,H)

Submission status: Wrong Answer

Solution code:
f=lambda:map(int,input().split())
n=int(input())
lh,lz=[],[]
for _ in range(n):
  x,y,h=f()
  if h: lh+=[(x,y,h)]
  else: lz+=[(x,y)]
for X in range(101):
  for Y in range(101):
    x,y,h=lh[0]
    H=h+abs(x-X)+abs(y-Y)
    for x,y,h in lh:
      if H!=h+abs(x-X)+abs(y-Y): break
    else: print(X,Y,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
dat = []
for _ in range(n):
    a,b,c = map(int,input().split())
    dat.append([a,b,c])
for x in range(101):
    for y in range(101):
        h = None
        can = True
        for i in range(n):
            xx, yy, hh = dat[i]
            canh = hh + abs(xx-x) + abs(yy-y)
            if h is not None:
                if canh != h:
                    can = False
            else:
                h = canh

        if can:
            break
    if can:
        break
print(x, y, canh)

Submission status: Wrong Answer

Solution code:
n = int(input())
dat = []
for _ in range(n):
    a,b,c = map(int,input().split())
    dat.append([a,b,c])
for x in range(101):
    for y in range(101):
        h = None
        can = True
        for i in range(n):
            xx, yy, hh = dat[i]
            canh = hh + abs(xx-x) + abs(yy-y)
            if h is not None:
                if canh != h:
                    can = False
            else:
                h = canh

        if can:
            break
    if can:
        break
print(x, y, h)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
x.sort(key=lambda x:-x[2])
dp=[[0]*101 for i in range(101)]
bp=[[0]*101 for i in range(101)]
for j in range(101):
  for k in range(101):
    for i in range(N):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2]
      if i==0:
        bp[j][k]=count
      if bp[j][k]==count:
        dp[j][k]+=1
for a in range(101):
  for b in range(101):
    if dp[a][b]==N and bp[a][b]>=0:
      print(a,b,bp[a][b])

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
x.sort(key=lambda x:-x[2])
dp=[[0]*101 for i in range(101)]
bp=[[0]*101 for i in range(101)]
for j in range(101):
  for k in range(101):
    for i in range(N):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2]
      if i==0:
        bp[j][k]=count
      if bp[j][k]==count:
        dp[j][k]+=1
for a in range(101):
  for b in range(101):
    if dp[a][b]==N:
      print(a,b,bp[a][b])

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
dp=[[0]*101 for i in range(101)]
bp=[[0]*101 for i in range(101)]
for j in range(101):
  for k in range(101):
    for i in range(N):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2]
      if i==0:
        bp[j][k]=count
      if bp[j][k]==count:
        dp[j][k]+=1
for a in range(101):
  for b in range(101):
    if dp[a][b]==N:
      print(a,b,bp[a][b])

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
dp=[[0]*101 for i in range(101)]
bp=[[0]*101 for i in range(101)]
for i in range(N):
  for j in range(101):
    for k in range(101):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2]
      if i==0:
        bp[j][k]=count
      if bp[j][k]==count:
        dp[j][k]+=1
for a in range(101):
  for b in range(101):
    if dp[a][b]==N:
      print(a,b,bp[a][b])
      break

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
dp=[[0]*101 for i in range(101)]
ans=10**10
for i in range(N):
  for j in range(101):
    for k in range(101):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2]
      if dp[j][k]!=i*count:
        dp[j][k]=0
      else:
        dp[j][k]+=count
      ans=min(ans,x[i][2])
for i in range(101):
  for j in range(101):
    if dp[i][j]!=0:
      p=int(dp[i][j]//N)
      print(i,j,p)
      break

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
Cx=0
Cy=0
H=0
dp=[[0]*101 for i in range(101)]
ans=10**10
for i in range(N):
  for j in range(101):
    for k in range(101):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2]
      if dp[j][k]!=i*count:
        dp[j][k]=0
      else:
        dp[j][k]+=count
p=10**19
a=0
b=0
for i in range(101):
  for j in range(101):
    if dp[i][j]%N==0 and dp[i][j]!=0:
      if p!=min(p,dp[i][j]//N):
        a=i
        b=j
        p=min(p,dp[i][j]//N)
print(a,b,p)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
Cx=0
Cy=0
H=0
dp=[[0]*101 for i in range(101)]
ans=10**10
for i in range(N):
  for j in range(101):
    for k in range(101):
      count=abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2]
      if dp[j][k]!=i*count:
        dp[j][k]=0
      else:
        dp[j][k]+=count
      ans=min(ans,x[i][2])
p=10**19
a=0
b=0
for i in range(101):
  for j in range(101):
    if dp[i][j]%N==0 and ans*N<=dp[i][j]:
      if p!=min(p,dp[i][j]//N):
        a=i
        b=j
        p=min(p,dp[i][j]//N)
print(a,b,p)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
Cx=0
Cy=0
H=0
dp=[[0]*101 for i in range(101)]
ans=10**10
for i in range(N):
  for j in range(101):
    for k in range(101):
      dp[j][k]+=(abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2])
      ans=min(ans,x[i][2])
p=10**19
a=0
b=0
for i in range(101):
  for j in range(101):
    if dp[i][j]%N==0 and ans*N<=dp[i][j]:
      if p!=min(p,dp[i][j]//N):
        a=i
        b=j
        p=min(p,dp[i][j]//N)
print(a,b,p)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
Cx=0
Cy=0
H=0
dp=[[0]*101 for i in range(101)]
ans=0
for i in range(N):
  for j in range(101):
    for k in range(101):
      dp[j][k]+=(abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2])
      ans=max(ans,x[i][2])
p=1000000
a=0
b=0
for i in range(101):
  for j in range(101):
    if dp[i][j]%N==0 and ans*N<=dp[i][j]:
      if p!=min(p,dp[i][j]//N):
        a=i
        b=j
        p=min(p,dp[i][j]//N)
print(a,b,p)

Submission status: Wrong Answer

Solution code:
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]
Cx=0
Cy=0
H=0
dp=[[0]*101 for i in range(101)]
ans=0
for i in range(N):
  for j in range(101):
    for k in range(101):
      dp[j][k]+=(abs(x[i][0]-j)+abs(x[i][1]-k)+x[i][2])
p=1000000
a=0
b=0
for i in range(101):
  for j in range(101):
    if dp[i][j]%N==0:
      if p!=min(p,dp[i][j]//N):
        a=i
        b=j
        p=min(p,dp[i][j]//N)
print(a,b,p)

Submission status: Wrong Answer

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

end = False
for cx in range(101):
    for cy in range(101):
        H = np.zeros(n, dtype=int)
        zeros = []
        for i, a in enumerate(xyh):
            if a[2] == 0:
                zeros.append(i)
            else:
                H[i] = abs(a[0] - cx) + abs(a[1] - cy) + a[2]
        H[zeros] = H.max()
        if np.all(H == H[0]):
            end = True
            break
    if end:
        break
print(cx, cy, H[0])

Submission status: Wrong Answer

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

end = False
for cx in range(101):
    for cy in range(101):
        H = np.zeros(n, dtype=int)
        for i, a in enumerate(xyh):
            H[i] = abs(a[0] - cx) + abs(a[1] - cy) + a[2]
        if np.all(H == H[0]):
            end = True
            break
    if end:
        break
print(cx, cy, H[0])

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
    for cy in range(101):
        center = []
        for x, y, h in H:
            if h >= 1:
                center.append(h+abs(x-cx)+abs(y-cy))
        if len(list(set(center))) == 1:
            print(cx, cy, center[0])
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
    for cy in range(101):
        center = []
        for x, y, h in H:
            if h+abs(x-cx)+abs(y-cy) >= 1:
                center.append(h+abs(x-cx)+abs(y-cy))
        if len(list(set(center))) == 1:
            print(cx, cy, center[0])
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for cx in range(101):
    for cy in range(101):
        center = []
        for x, y, h in H:
            center.append(h+abs(x-cx)+abs(y-cy))
        if len(list(set(center))) == 1:
            print(cx, cy, center[0])
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
q=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        F=1
        r=[]
        x,y,h=q[0]
        if h==0:
          r.append([x,y])
          x,y,h=q[1]
        s=h+abs(x-i)+abs(y-j)
        for x,y,h in q[1:]:
            if h==0:
                r.append([x,y])
                continue
            y=h+abs(x-i)+abs(y-j)
            if s!=y:
              F=0
              break
        if r:
          for x,y in r:
            if s-abs(x-i)-abs(y-j) > 0:
              F=0
              break
        if F==1:
          print(i,j,s)
          exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    L.append((x, y, h))
for cy in range(101):
    for cx in range(101):
        d = abs(sx - cx) + abs(sy - cy)
        H = sh + d
        for x, y, h in L:
            if h == 0:
                if H > abs(x - cx) - abs(y - cy):
                    break
            else:
                if H - abs(x - cx) - abs(y - cy) != h:
                    break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    L.append((x, y, h))
for cy in range(101):
    for cx in range(101):
        d = abs(L[0][0] - cx) + abs(L[0][1] - cy)
        H = L[0][2] + d
        for x, y, h in L:
            if h == 0:
                if H > abs(x - cx) - abs(y - cy):
                    break
            else:
                if H - abs(x - cx) - abs(y - cy) != h:
                    break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    L.append((x, y, h))
for cy in range(101):
    for cx in range(101):
        d = abs(L[0][0] - cx) + abs(L[0][1] - cy)
        H = L[0][2] + d
        for x, y, h in L:
            if h == 0:
                if H - abs(x - cx) - abs(y - cy) < d:
                    break 
            else:
                if H - abs(x - cx) - abs(y - cy) != h:
                    break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    d[(x, y)] = h
    L.append((x, y, h))
for cy in range(101):
    for cx in range(101):
        if d[(cx, cy)] > 0:
            H = d[(cx, cy)]
        else:
            for x, y, h in L:
                H = h + abs(x - cx) + abs(y - cy)
                if H >= 0:
                    break
            else:
                break
        if H == 0:
            for x, y, h in L:
                if H - abs(x - cx) - abs(y - cy) != h:
                    if H - abs(x - cx) - abs(y - cy) != h - 1:
                        break
            else:
                print(cx, cy, H)
                exit()
        else:
            for x, y, h in L:
                if H - abs(x - cx) - abs(y - cy) != h:
                    break
            else:
                print(cx, cy, H)
                exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    d[(x, y)] = h
    L.append((x, y, h))
for cy in range(101):
    for cx in range(101):
        if d[(cx, cy)] > 0:
            H = d[(cx, cy)]
        else:
            for x, y, h in L:
                H = h + abs(x - cx) + abs(y - cy)
                if H > 0:
                    break
            else:
                break
        for x, y, h in L:
            if H - abs(x - cx) - abs(y - cy) != h:
                break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())
d = defaultdict(int)
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    d[(x, y)] = h
    L.append((x, y, h))
for cy in range(101):
    for cx in range(101):
        if d[(cx, cy)] > 0:
            H = d[(cx, cy)]
        else:
            for x, y, h in L:
                H = h + abs(x - cx) + abs(y - cy)
                if H > 0:
                    break
        for x, y, h in L:
            if H - abs(x - cx) - abs(y - cy) != h:
                break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
p = [[-1] * 101 for _ in range(101)]
L = []
for _ in range(n):
    x, y, h = map(int, input().split())
    L.append((x, y, h))
    p[y-1][x-1] = h
for cy in range(101):
    for cx in range(101):
        if p[y][x] > 0:
            H = p[y][x]
        else:
            H = L[0][2] + abs(L[0][0] - cx) + abs(L[0][1] - cy)
        for x, y, h in L:
            if H - abs(x - cx) - abs(y - cy) != h:
                break
        else:
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
q=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        F=1
        r=[]
        x,y,h=q[0]
        if h==0:
          r.append([x,y])
          x,y,h=q[1]
        s=h+abs(x-i)+abs(y-j)
        for x,y,h in q[1:]:
            if h==0:
                r.append([x,y])
                continue
            y=h+abs(x-i)+abs(y-j)
            if s!=y:
              F=0
              break
            if r:
              for x,y in r:
                if s-abs(x-i)-abs(y-j) > 0:
                  F=0
                  break
        if F==1:
          print(i,j,s)
          exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
q=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        F=1
        x,y,h=q[0]
        if h==0:
          x,y,h=q[1]
        s=max(h+abs(x-i)+abs(y-j),0)
        for x,y,h in q[1:]:
            if h==0:
                continue
            y=max(h+abs(x-i)+abs(y-j),0)
            if s!=y:
              F=0
              break
        if F==1:
          print(i,j,s)
          exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
q=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        F=1
        x,y,h=q[0]
        if h==0:
          x,y,h=q[1]
        s=h+abs(x-i)+abs(y-j)
        for x,y,h in q[1:]:
            if h==0:
                continue
            y=h+abs(x-i)+abs(y-j)
            if s!=y:
              F=0
              break
        if F==1:
          print(i,j,s)
          exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
q=[list(map(int,input().split())) for _ in range(N)]
for i in range(102):
    for j in range(102):
        F=1
        x,y,h=q[0]
        s=h+abs(x-i)+abs(y-j)
        for x,y,h in q[1:]:
            y=h+abs(x-i)+abs(y-j)
            if s!=y:F=0;break
        if F==1:
          print(i,j,s)
          exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort(key=lambda x: x[2], reverse=True)
for c_x in range(100):
    for c_y in range(100):
        H = -1
        H_upper = 10**9
        for i, v in enumerate(A):
            if v[2] == 0:
                H_upper = min(H_upper, abs(c_x - v[0]) + abs(c_y - v[1]))
                if H_upper < H:
                    break
            else:
                tmp_H = abs(c_x - v[0]) + abs(c_y - v[1]) + v[2]
                if H == -1:
                    H = tmp_H
                elif H != tmp_H:
                    break
            if i == N-1:
                if H == -1:
                    print(c_x, c_y, H_upper)
                else:
                    print(c_x, c_y, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort(key=lambda x: x[2], reverse=True)
for c_x in range(100):
    for c_y in range(100):
        H = -1
        H_upper = 10**9
        for i, v in enumerate(A):
            if v[2] == 0:
                H_upper = min(H_upper, abs(c_x - v[0]) + abs(c_y - v[1]))
                if H_upper < H:
                    break
            else:
                tmp_H = abs(c_x - v[0]) + abs(c_y - v[1]) + v[2]
                if H == -1:
                    H = tmp_H
                elif H != tmp_H:
                    break
            if i == N-1:
                print(c_x, c_y, H)

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)
for i in range(101):
    for j in range(101):
        H=[]
        for k in range(n):
            if h[k]!=0:
                H.append(h[k]+abs(i-x[k])+abs(j-y[k]))
        if len(list(set(H)))==1:
            print(i,j,H[0])
            break
        else:
            continue
        break
    else:
        continue
    break

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)
for i in range(101):
    for j in range(101):
        H=[]
        for k in range(n):
            H.append(h[k]+abs(i-x[k])+abs(j-y[k]))
        if len(list(set(H)))==1:
            print(i,j,H[0])
            break
        else:
            continue
        break
    else:
        continue
    break

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)
for i in range(101):
    for j in range(101):
        H=[]
        for k in range(n):
            H.append(h[k]+abs(i-x[k])+abs(j-y[k]))
        if len(list(set(H)))==1:
            print(i,j,H[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):
        a = -1
        ok = True
        for x,y,h in xyh:
            if h>0:
                if a==-1:
                    a = h+abs(x-i)+abs(y-j)
                elif h+abs(x-i)+abs(y-j)!=a:
                    ok = False
            else:
                if a!=-1 and a-abs(x-i)-abs(y-j)>0:
                    ok = False
        if ok:
            print(i,j,a)
            exit()