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

ans = [1, 1, 1]

for x in range(101):
  for y in range(101):
    h = li[0][2] + abs(x - li[0][0]) + abs(y - li[0][1])
    ok = True

    for i in li:
      if h != i[2] + abs(x - i[0]) + abs(y - i[1]):
        ok = False

    if ok:
      ans = [x, y, h]

print("{} {} {}".format(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
def H(h, x, y, cx, cy):
    return h + abs(x-cx) + abs(y-cy)
    


N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        judge = True
        ml = [l for l in range(N) if x[l][2]!=0]
        m = 0
        if(len(ml)!=0):
            m = ml[0]
        H0 = H(x[m][2], x[m][0], x[m][1], cx, cy)
        for n in range(len(x)):
            Hn = H(x[n][2], x[n][0], x[n][1], cx, cy)
            #print(Hn)
            if(x[n][2] != 0):
                if(Hn == H0):
                    judge = judge and True
                else:
                    judge = judge and False
            else:
                if(Hn > H0):
                    judge = judge and True
                else:
                    judge = judge and False
        if(judge):
            print(cx, cy, H0)

Submission status: Wrong Answer

Solution code:
def H(h, x, y, cx, cy):
    return h + abs(x-cx) + abs(y-cy)
    


N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        judge = True
        m = [l for l in range(N) if x[l][2]!=0][0]
        H0 = H(x[m][2], x[m][0], x[m][1], cx, cy)
        for n in range(0, len(x)):
            Hn = H(x[n][2], x[n][0], x[n][1], cx, cy)
            #print(Hn)
            if(x[n][2] != 0):
                if(Hn == H0):
                    judge = judge and True
                else:
                    judge = judge and False
            
        if(judge):
            print(cx, cy, H0)

Submission status: Wrong Answer

Solution code:
#112
from itertools import product

N=int(input())
px,py,ph=[],[],[]

for _ in range(N):
    x,y,h=map(int,input().split())
    if h!=0:
        px.append(x)
        py.append(y)
        ph.append(h)
        
def Calc_H(Cxi,Cyj,pxi,pyj,hi):
    return hi+abs(Cxi-pxi)+abs(Cyj-pyj)

for Cxi,Cyj in product(range(101),range(101)):
    preH=Calc_H(Cxi,Cyj,px[0],py[0],ph[0])
    for i in range(len(ph)):
        nowH=Calc_H(Cxi,Cyj,px[i],py[i],ph[i])
        if nowH!=preH:
            break
        preH=nowH
    else:
        print(Cxi,Cyj,nowH)

Submission status: Wrong Answer

Solution code:
#112
from itertools import product

N=int(input())
px=[]
py=[]
ph=[]
cnt=0

for _ in range(N):
    x,y,h=map(int,input().split())
    if h!=0:
        px.append(x)
        py.append(y)
        ph.append(h)
    else:
        cnt+=1

        
def Calc_H(Cxi,Cyj,pxi,pyj,hi):
    return hi+abs(Cxi-pxi)+abs(Cyj-pyj)

    
    
for Cxi,Cyj in product(range(101),range(101)):
    preH=Calc_H(Cxi,Cyj,px[0],py[0],ph[0])
    nowH=Calc_H(Cxi,Cyj,px[0],py[0],ph[0])
    for i in range(1,N-cnt):
        nowH=Calc_H(Cxi,Cyj,px[i],py[i],ph[i])
        if preH!=nowH:
            break
        preH=nowH
    else:
        print(Cxi,Cyj,nowH)

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        height = abs(x[0][0] - cx) + abs(x[0][1] - cy) + x[0][2]
        for i in range(n):
            sub = max(height - abs(x[i][0] - cx) - abs(x[i][1] - cy), 0)
            if sub != x[i][2]:
                break
            if i == n - 1:
                print(cx, cy, height)
                exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
xyh = [input() for _ in range(n)]
#print(xyh)
for x_ in range(101):
    for y_ in range(101):
        cur_h = 0 #flga の場所をループの中に入れない
        for i in range(n):
            x = int(xyh[i].split()[0])
            y = int(xyh[i].split()[1])
            h = int(xyh[i].split()[2])
            h_ = h + (abs(x_ - x) + abs(y_ - y))
            if cur_h == 0 and h_ > 0 and h > 0:
                cur_h = h_  #決め打ちの高さ        
            else:
                if h > 0:
                    if cur_h != h_: break
                elif cur_h -(abs(x_ - x) + abs(y_ - y)) > 0: break
                #print(cur_h,i)
                if i == n-1: 
                    print(x_,y_,cur_h)
                    #print("hello")
                    exit(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
xyh = [input() for _ in range(n)]
#print(xyh)
for x_ in range(101):
    for y_ in range(101):
        cur_h = 0 #flga の場所をループの中に入れない
        for i in range(n):
            x = int(xyh[i].split()[0])
            y = int(xyh[i].split()[1])
            h = int(xyh[i].split()[2])
            h_ = h + (abs(x_ - x) + abs(y_ - y))
            if cur_h == 0 and h_ > 0:
                cur_h = h_                
            else:
                if h > 0:
                    if cur_h != h_: break
                elif cur_h -(abs(x_ - x) + abs(y_ - y)) > 0: break
                #print(cur_h,i)
                if i == n-1: 
                    print(x_,y_,cur_h)
                    #print("hello")
                    exit(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(readline())
xyh = [input() for _ in range(n)]
#print(xyh)
for x_ in range(101):
    for y_ in range(101):
        for i in range(n):
            x = int(xyh[i].split()[0])
            y = int(xyh[i].split()[1])
            h = int(xyh[i].split()[2])
            if i == 0:
                h_ = h + abs(x_ - x) + abs(y_ - y)
            else:
                if h_ != h + abs(x_ - x) + abs(y_ - y): break
                if i == n-1: 
                    print(x_,y_,h_)
                    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())

h = [0] * N
for cx in range(0,101):
    for cy in range(0,101):
        for i in range(N):
            h[i] = max(0,H[i]+abs(X[i]-cx)+abs(Y[i]-cy))
            if (H[i] == 0):
                h[i] = -1
            if i >= 1:
                if (h[i-1] != h[i] and (h[i-1] != -1 and h[i] != -1)):
                    break
            if i == N-1:
                print(cx,cy,h[i])
                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())

h = [0] * N
for cx in range(0,101):
    for cy in range(0,101):
        for i in range(N):
            h[i] = max(0,H[i]+abs(X[i]-cx)+abs(Y[i]-cy))
            if i >= 1:
                if (h[i-1] != h[i]):
                    break
            if i == N-1:
                print(cx,cy,h[i])
                exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

def main():
    N = cin.int()
    info = cin.intListList(N)
    for x in range(101):
        for y in range(101):
            h = -1
            for i in range(N):
                if info[i][2] > 0:
                    h = abs(x - info[0][0]) + abs(y - info[0][1]) + info[0][2]
                    if h > 0:
                        break
            if h > 0:
                ok = True
                for i in range(N):
                    a = max(0,h - abs(x - info[i][0]) - abs(y - info[i][1]))
                    if info[i][2] != a:
                        ok = False
                if ok:
                    print("{} {} {}".format(x,y,h))
                    return
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

def main():
    N = cin.int()
    info = cin.intListList(N)
    for x in range(101):
        for y in range(101):
            h = max(0, abs(x - info[0][0]) + abs(y - info[0][1]) + info[0][2])
            ok = True
            for i in range(N):
                a = max(0,h - abs(x - info[i][0]) - abs(y - info[i][1]))
                if info[i][2] != a:
                    ok = False
            if ok:
                print("{} {} {}".format(x,y,h))
                return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

def main():
    N = cin.int()
    info = cin.intListList(N)
    if N == 1:
        print("{} {} {}".format(info[0][0],info[0][1],info[0][2]))
        return
    for x in range(101):
        for y in range(101):
            h = max(0, abs(x - info[0][0]) + abs(y - info[0][1]) + info[0][2])
            ok = True
            for i in range(1,N):
                a = max(0,h - abs(x - info[i][0]) - abs(y - info[i][1]))
                if info[i][2] != a:
                    ok = False
            if ok:
                print("{} {} {}".format(x,y,h))
                return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

def main():
    N = cin.int()
    info = cin.intListList(N)
    for x in range(101):
        for y in range(101):
            h = abs(x - info[0][0]) + abs(y - info[0][1]) + info[0][2]
            ok = True
            for i in range(1,N):
                if info[i][2] != max(0,h - abs(x - info[i][0]) - abs(y - info[i][1])):
                    ok = False
            if ok:
                print("{} {} {}".format(x,y,h))
                return

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import _collections
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]

class Util():
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Util.round_up(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)

N = cin.int()
info = cin.intListList(N)
for x in range(101):
    for y in range(101):
        h = max(0, abs(x - info[0][0]) + abs(y - info[0][1])) + info[0][2]
        ok = True
        for i in range(1,N):
            if info[i][2] != max(0,h - abs(x - info[i][0]) - abs(y - info[i][1])):
                ok = False
        if ok:
            print("{} {} {}".format(x,y,h))
            sys.exit()

Submission status: Wrong Answer

Solution code:

N = int(input())

P = []

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

for x in range(101):
  for y in range(101):
    for p in range(N):
      (cx, cy, ch) = P[p]
      height = ch + abs(cx - x) + abs(cy - y)
    
    if height >= 1:
      for p in range(N):
        (cx, cy, ch) = P[p]
        if ch == 0:
          if height - abs(cx - x) - abs(cy - y) > 0:
            break
        elif height - abs(cx - x) - abs(cy - y) != ch:
            break
      else:
        print(x, y, height)
        exit()

Submission status: Wrong Answer

Solution code:

N = int(input())

P = []

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

for x in range(101):
  for y in range(101):
    height = -1
    for p in range(N):
      (cx, cy, ch) = P[p]
      if height == -1:
        height = ch + abs(cx - x) + abs(cy - y)
        if height < 1:
          height = -1
      elif height == -2:
        break
      else:
        tmp = ch + abs(cx - x) + abs(cy - y)
        if tmp != height:
          height = -2
    
    if height != -2:
      valid = True
      for p in range(N):
        (cx, cy, ch) = P[p]
        if ch == 0:
          if height - abs(cx - x) - abs(cy - y) > 0:
            valid = False
        else:
          if max(0, height - abs(cx - x) - abs(cy - y)) != ch:
            valid = False
      if valid:
        print(x, y, height)
        exit()

Submission status: Wrong Answer

Solution code:

N = int(input())

P = []

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

for x in range(101):
  for y in range(101):
    height = -1
    for p in range(N):
      (cx, cy, ch) = P[p]
      if height == -1:
        height = ch + abs(cx - x) + abs(cy - y)
      elif height == -2:
        break
      else:
        tmp = ch + abs(cx - x) + abs(cy - y)
        if tmp != height:
          height = -2
    
    if height != -2:
      valid = True
      for p in range(N):
        (cx, cy, ch) = P[p]
        if max(0, height - abs(cx - x) - abs(cy - y)) != ch:
          valid = False
      if valid:
        print(x, y, height)
        exit()

Submission status: Wrong Answer

Solution code:
def p_c():
    from itertools import product
    N = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(N)]
    for x, y in product(range(101), repeat=2):
        high = xyh[0][2] + abs(xyh[0][0] - x) + abs(xyh[0][1] - y)
        if all(h == max(0, high - abs(x - i) - abs(y - j)) for i, j, h in xyh):
            print(x, y, high)

p_c()

Submission status: Wrong Answer

Solution code:
def is_right(i, j):
    H = None
    for x, y, h in XYH:
        if H is None:
            if h > 0:
                H = abs(x - i) + abs(y - j) + h
        else:
            if h != max(H - abs(x - i) - abs(y - j), 0):
                return -1
    return H


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

for i in range(101):
    for j in range(101):
        res = is_right(i, j)
        if res > 0:
            print(i, j, res)
            exit()

Submission status: Wrong Answer

Solution code:
def p_c():
    from itertools import product
    N = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(N)]
    for x, y in product(range(0, 101), repeat=2):
        high = -1
        for n in range(N):
            if high == -1:
                high = xyh[n][2] + abs(xyh[n][0] - x) + abs(xyh[n][1] - y)
            if high != xyh[n][2] + abs(xyh[n][0] - x) + abs(xyh[n][1] - y):
                break
        else:
            print(x, y, max(high, 0))
            exit()
            
p_c()

Submission status: Wrong Answer

Solution code:
def p_c():
    from itertools import product
    N = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(N)]
    for x, y in product(range(0, 101), repeat=2):
        high = -1
        for n in range(N):
            if high == -1:
                high = xyh[n][2] + abs(xyh[n][0] - x) + abs(xyh[n][1] - y)
            if high != xyh[n][2] + abs(xyh[n][0] - x) + abs(xyh[n][1] - y):
                break
        else:
            print(x, y, high)
            exit()
            
p_c()

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [0] * N
Y = [0] * N
H = [0] * N

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

for cx in range(101):
    for cy in range(101):
        H_list = []
        for i in range(N):
            if H[i] == 0:
                continue
            H_list.append(H[i] + abs(X[i] - cx) + abs(Y[i] - cy))
        if len(set(H_list)) == 1:
            print(cx, cy, H_list[0])
            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, y, h = map(int, input().split())
    X[i] = x
    Y[i] = y
    H[i] = h

for cx in range(101):
    for cy in range(101):
        H_list = [0] * N
        for i in range(N):
            if H[i] == 0:
                continue
            H_list[i] = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
        if len(set(H_list)) == 1:
            print(cx, cy, H_list[0])
            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, y, h = map(int, input().split())
    X[i] = x
    Y[i] = y
    H[i] = h

for cx in range(101):
    for cy in range(101):
        H_list = [0] * N
        for i in range(N):
            H_list[i] = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
        if len(set(H_list)) == 1:
            print(cx, cy, H_list[0])
            exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xi,yi,hi=[],[],[]
for i in range(n):
    num=[int(j) for j in input().split()]
    xi+=[num[0]]
    yi+=[num[1]]
    hi+=[num[2]]
ans=[0,0,0]
for i in range(101):
    for j in range(101):
        hoge=10**9+10
        for k in range(n):
            hight=hi[k]+abs(xi[k]-i)+abs(yi[k]-j)
            if(hi[k]==0):
                continue
            if(i==xi[k] and j==yi[k]):
                hight=hi[k]
            if(hoge==10**9+10):
                hoge=hight
            elif(hoge!=hight):
                break
        else:
            flg=True
            for k in range(n):
                if(xi[k]==i and yi[k]==j):
                    if(hi[k]==hoge):
                        ans=[i,j,hoge]
                    else:
                        flg=False
                        break
            if(flg):
                ans=[i,j,hoge]
print(*ans,sep=" ")

Submission status: Wrong Answer

Solution code:
n=int(input())
xi,yi,hi=[],[],[]
for i in range(n):
    num=[int(j) for j in input().split()]
    xi+=[num[0]]
    yi+=[num[1]]
    hi+=[num[2]]
ans=[0,0,0]
for i in range(101):
    for j in range(101):
        hoge=0
        for k in range(n):
            hight=hi[k]+abs(xi[k]-(i))+abs(yi[k]-(j))
            if(hi[k]==0):
                continue
            elif(k==0):
                hoge=hight
            elif(hoge!=hight):
                break
            else:
                hoge=hight
        else:
            ans=[i,j,hoge]
print(*ans,sep=" ")

Submission status: Wrong Answer

Solution code:
n=int(input())
xi,yi,hi=[],[],[]
for i in range(n):
    num=[int(j) for j in input().split()]
    xi+=[num[0]]
    yi+=[num[1]]
    hi+=[num[2]]
ans=[0,0,0]
for i in range(101):
    for j in range(101):
        hoge=0
        for k in range(n):
            hight=hi[k]+abs(xi[k]-(i))+abs(yi[k]-(j))
            if(k==0):
                hoge=hight
            elif(hoge!=hight):
                break
            else:
                hoge=hight
        else:
            ans=[i,j,hoge]
print(*ans,sep=" ")

Submission status: Wrong Answer

Solution code:
n=int(input())
xi,yi,hi=[],[],[]
for i in range(n):
    num=[int(j) for j in input().split()]
    xi+=[num[0]]
    yi+=[num[1]]
    hi+=[num[2]]
ans=[0,0,0]
for i in range(101):
    for j in range(101):
        hoge=0
        for k in range(n):
            hight=hi[k]+abs(xi[k]-(i))+abs(yi[k]-(j))
            if(k==0):
                hoge=hight
            elif(hoge!=hight):
                break
            else:
                hoge=hight
        else:
            ans=[i,j,hoge]
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product


def solve():
    N = int(input())
    x, y, h = [], [], []
    for i in range(N):
        xi, yi, hi = map(int, input().split())
        if hi != 0:
            x.append(xi)
            y.append(yi)
            h.append(hi)
    
    for cx, cy in product(range(101), repeat=2):
        ans_h = h[0] + abs(cx - x[0]) + abs(cy - y[0])
        flg = True
        for i in range(1, len(x)):
            if ans_h != h[i] + abs(cx - x[i]) + abs(cy - y[i]):
                flg = False
                break
        if flg:
            print(cx, cy, ans_h)
            exit()


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
n=int(input())
p=[]
for i in range(n):
    p.append(tuple(map(int,input().split())))
p.sort(key=lambda x:-x[2])
for j in range(101):
    for k in range(101):
        H=None
        f=1
        for x,y,h in p:
            if h>0 and H==None:
                H=h+abs(x-j)+abs(y-k)
            else:
                if H!=h+abs(x-j)+abs(y-k):
                    f=0
        if f:
            print(j,k,H)
            exit()

Submission status: Wrong Answer

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

for j in range(101):
    for k in range(101):
        H=None
        f=1
        for x,y,h in p:
            if h>0 and H==None:
                H=h+abs(x-j)+abs(y-k)
            else:
                if H!=h+abs(x-j)+abs(y-k):
                    f=0
        if f:
            print(j,k,H)
            exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    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())
    for cx in range(101):
        for cy in range(101):
            H=-1
            for i in range(N):
                if H==-1 and h[i]>0:
                    H=h[i]+abs(x[i]-cx)+abs(y[i]-cy)
                elif H!=-1 and ((H-abs(x[i]-cx)-abs(y[i]-cy)>0 and h[i]!=H-abs(x[i]-cx)-abs(y[i]-cy)) or (H-abs(x[i]-cx)-abs(y[i]-cy)<=0 and h[i]!=0)):
                    break
            else:
                print(cx,cy,H)
                exit()
                    
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
 
N = int(input())
XYH=[]
for x in range(N):
  XYH.append(list(map(int,input().split())))
XYH = sorted(XYH,key=lambda x: x[2], reverse=True)
 
for i in range(0, 101):
    for j in range(0, 101):
        ansH = XYH[0][2] + abs(XYH[0][0]-i) + abs(XYH[0][1]-j)
        if ansH > 0:
            for k in range(N):
                if XYH[k][2] == ansH - abs(XYH[k][0]-i) - abs(XYH[k][1]-j):
                    pass
                else:
                    break
 
                if k == N-1:
                    print('{} {} {}'.format(i,j,ansH))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
 
N = int(input())
XYH=[]
for x in range(N):
  XYH.append(list(map(int,input().split())))
XYH = sorted(XYH,key=lambda x: x[2])
 
for i in range(0, 101):
    for j in range(0, 101):
        ansH = XYH[0][2] + abs(XYH[0][0]-i) + abs(XYH[0][1]-j)
        if ansH > 0:
            for k in range(N):
                if XYH[k][2] == ansH - abs(XYH[k][0]-i) - abs(XYH[k][1]-j):
                    pass
                else:
                    break
 
                if k == N-1:
                    print('{} {} {}'.format(i,j,ansH))
                    sys.exit()

Submission status: Wrong Answer

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


for i in range(0, 101):
    for j in range(0, 101):
        ansH = XYH[0][2] + abs(XYH[0][0]-i) + abs(XYH[0][1]-j)
        if ansH > 0:
            for k in range(N):
                if XYH[k][2] == ansH - abs(XYH[k][0]-i) - abs(XYH[k][1]-j):
                    pass
                else:
                    break
 
                if k == N-1:
                    print('{} {} {}'.format(i,j,ansH))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        ansH = XYH[0][2] + abs(XYH[0][0]-i) + abs(XYH[0][1]-j)
        if ansH > 0:
            for k in range(N):
                if XYH[k][2] == ansH - abs(XYH[k][0]-i) - abs(XYH[k][1]-j):
                    pass
                else:
                    break

                if k == N-1:
                    print('{} {} {}'.format(i,j,ansH))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        ansH = XYH[0][2] + abs(XYH[0][0]-i) + abs(XYH[0][1]-j)

        if N ==1:
            print('{} {} {}'.format(i,j,ansH))
            sys.exit()

        for k in range(N):
            if XYH[k][2] == ansH - abs(XYH[k][0]-i) - abs(XYH[k][1]-j):
                pass
            else:
                break

            if k == N-1:
                print('{} {} {}'.format(i,j,ansH))
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
XYH = [[int(x) for x in input().split()] for _ in range(N)]

numb = 0
for i in range(0, 101):
    for j in range(0, 101):
        ansH = XYH[0][2] + abs(XYH[0][0]-i) + abs(XYH[0][1]-j)
        for k in range(N):
            if XYH[k][2] == ansH - abs(XYH[k][0]-i) - abs(XYH[k][1]-j):
                pass
            else:
                break
            if k == N-1:
                print('{} {} {}'.format(i,j,ansH))
                sys.exit()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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