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())
index=0
dataL = []
while index < n:
    x, y, h = map(int, input().split())
    dataL.append([h, x, y])
    index+=1
dataL.sort()
dataL.reverse()

dataI = []
max = dataL[0][0]
index2 =0
while index2 < len(dataL):
    if dataL[index2][0] == max:
        dataI.append(dataL[index2])
        index2+=1
    else:
        break

if len(dataI) == 4:
    index3=0
    sumX=0
    sumY=0
    while index3 < len(dataI):
        sumX+=dataI[index3][1]
        sumY += dataI[index3][2]
        index3+=1
    cx=sumX//4
    cy=sumY//4
    ansH=dataI[0][0]+abs(dataI[0][1]-cx)+abs(dataI[0][2]-cy)
    print(str(cx)+" "+str(cy)+" "+str(ansH))

elif len(dataI)==1:
    print(str(dataI[0][2])+" "+str(dataI[0][1])+" "+str(dataI[0][0]))

elif len(dataI)==2:
    if dataI[0][1] > dataI[1][1]:
        if [dataI[1][0]-(dataI[0][1]-dataI[1][1]), dataI[1][1], dataI[1][2]+(dataI[0][1]-dataI[1][1])] in dataL:
            print(str(dataI[1][1]+(dataI[0][1]-dataI[1][1])) +
                  " "+str(dataI[1][2])+" "+str(dataI[0][0]+(dataI[0][1]-dataI[1][1])))
        else:
            print(str(dataI[1][1]) +
                  " "+str(dataI[1][2]+(dataI[0][1]-dataI[1][1]))+" "+str(dataI[0][0]+(dataI[0][1]-dataI[1][1])))
    else:
        if [dataI[1][0]-(dataI[1][1]-dataI[0][1]), dataI[1][1], dataI[1][2]+(dataI[1][1]-dataI[0][1])] in dataL:
            print(str(dataI[1][1]+(dataI[1][1]-dataI[0][1])) +
                  " "+str(dataI[1][2])+" "+str(dataI[0][0]+(dataI[1][1]-dataI[0][1])))
        else:
            print(str(dataI[1][1]) +
                  " "+str(dataI[1][2]+(dataI[1][1]-dataI[0][1]))+" "+str(dataI[0][0]+(dataI[1][1]-dataI[0][1])))

Submission status: Wrong Answer

Solution code:
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    if hi==0:
        pass
    else:
            
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])

Submission status: Wrong Answer

Solution code:
n=int(input())
x,y,h=[],[],[]
for _ in [0]*n:
    xi,yi,hi=[int(x) for x in input().split()]
    x.append(xi)
    y.append(yi)
    h.append(hi)
diff=max(h)-min(h)
h=[i-diff for i in h]
def pattern(cx,cy,H):
    for i in range(n):
        if H-abs(x[i]-cx)-abs(y[i]-cy)!=h[i]:
            return False
    return True
from itertools import product
for H in range(1,1000):
    for cx,cy, in product(range(101),range(101)):
        if pattern(cx,cy,H):
            print(cx,cy,H+diff)
            import sys
            sys.exit()

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b


heights = []
N = getN()
xmax, ymax, xmin, ymin = (-1,0,0), (0,-1,0), (200,0,0), (0,200,0)

for i in range(N):
    data = getlist()
    x,y,h = data[0],data[1],data[2]
    heights.append(data)
    if x > xmax[0]:
        xmax = (x,y,h)
    if x < xmin[0]:
        xmin = (x,y,h)
    if y > ymax[1]:
        ymax = (x,y,h)
    if y < ymin[1]:
        ymin = (x,y,h)
ansx, ansy, ansh = 0,0,0
first = heights[0]
fx,fy,fh = first[0], first[1], first[2]
for x in range(0,101):
    for y in range(0,101):
        flag = 1
        cand_h = fh + abs(fx-x) + abs(fy-y)
        #print(cand_h, x,y)
        for i in range(1,N):
            comp = heights[i]
            if (comp[2] + abs(comp[0]-x) + abs(comp[1]-y)) != cand_h:
                #print("break",x,y)
                flag = 0

        if flag == 1:

            #print("success", x,y)
            ansx, ansy, ansh = x, y, cand_h

print(ansx,ansy,ansh)

Submission status: Wrong Answer

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

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

ans = 3*[0]

for i in range(101):
    for j in range(101):
        H = h[0] + abs(x[0] - i) + abs(y[0] - j)
        flag = 1
        for k in range(N):
            if(H != (h[k] + abs(x[k] - i) + abs(y[k] - j))):
                flag = 0
                break
        if(flag == 1):
            if(H > ans[2]):
                ans[0] = i
                ans[1] = j
                ans[2] = H

print("%d %d %d" %(ans[0], ans[1], ans[2]))

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [[int(i) for i in input().split()] for _ in range(N)]
H_pre = 0
for cx in range(101):
    for cy in range(101):
        for x, y, h in xyh:
            if h:
                if H_pre:
                    if H_pre != h + abs(x-cx) + abs(y-cy):
                        H_pre = 0
                        break
                else:
                    H_pre = h + abs(x-cx) + abs(y-cy)
        else:
            print(cx, cy, H_pre)
            exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
n  = int(input())

xs = []
ys = []
hs = []
for k in range(n):
    xx, yy, hh = list(map(int,input().split()))
    xs.append(xx)
    ys.append(yy)
    hs.append(hh)
    
x = np.array(xs)
y = np.array(ys)
h = np.array(hs)

cx_cand = range(101)
cy_cand = range(101)
end_flag = False
for cx in cx_cand:
    for cy in cy_cand:

        temp = hs + np.abs(x - cx) + np.abs(y - cy)                 
        temp2 = hs - np.abs(x - cx) - np.abs(y - cy)                 
        unuse = (temp2 < 0) * (h == 0)
#         if cx == 2:
#             if cy == 2:
#                 aaa
        temp = temp[unuse == False]

        if np.max(temp)== np.min(temp):
            end_flag = True
            break
    if end_flag:
        break
a = h>0
print(cx,cy,h[a][0] + np.abs(x[a][0] - cx) + np.abs(y[a][0] - cy))

Submission status: Wrong Answer

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

if N == 1:
    print(G[0][0],G[0][1],G[0][2])
    exit(0)

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] > 0:
                if G[k][2] + abs(Cx-G[k][0]) + abs(Cy-G[k][1]) != H:
                    f = 0
            else:
                if H - abs(Cx-G[k][0]) - abs(Cy-G[k][1]) > 0:
                    f = 0
        if f:
            print(Cx,Cy,H)
            exit(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
tmp = [int(i) for _ in range(n) for i in input().split()]

xs = tmp[0::3]
ys = tmp[1::3]
hs = tmp[2::3]

for H in range(max(hs), 10**9):
    for cx in range(101):
        for cy in range(101):
            for x,y,h in zip(xs,ys,hs):
                if not h == max(H-abs(x-cx)-abs(y-cy),0):
                    break
            else:
                print('{} {} {}'.format(cx,cy,H))
                break
        else:
            continue
        break
    else:
        continue
    break

Submission status: Wrong Answer

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


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

for cx in range(0, 101):
    for cy in range(0, 101):
        TH = set(H(cx, cy, x, y, h) for x, y, h in xyh if h > 0)
        if len(TH) == 1:
            TTH = TH.pop()
            if TTH >= 1:
                print(cx, cy, TTH)

Submission status: Wrong Answer

Solution code:
n=int(input())
e = [[int(i) for i in input().split()] for i in range(n)]
def k(t,x,y):
  return abs(e[t+1][0]-x)+abs(e[t+1][1]-y)-abs(e[t][0]-x)-abs(e[t][1]-y)
for x in range(0,101):
    for y in range(0,101):
        for i in range(0,len(e)-1):
            if k(i,x,y)!=e[i][2]-e[i+1][2]:
                break
        else:
            print(str(x)+" "+str(y)+" "+str(e[0][2]+abs(e[0][0]-x)+abs(e[0][1]-y)))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    info_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [x, y, h] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        info_list.append((x, y, h))

    for Cx in range(101):
        for Cy in range(101):
            pre_H = -1
            is_all_eq = True
            for info in info_list:
                x = info[0]
                y = info[1]
                h = info[2]
                if h == 0:
                    if pre_H - abs(Cx - x) - abs(Cy - y) > 0:
                        is_all_eq = False
                        break
                else:
                    H =  h + abs(Cx - x) + abs(Cy - y)

                    if pre_H == -1 or H == pre_H:
                        pre_H = H
                    else:
                        is_all_eq = False
                        break;
            if is_all_eq == True:
                break
        if is_all_eq == True:
                break

    print Cx, Cy, H

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XYH):
    XYH.sort(key=lambda x: x[2], reverse=True)
    MM = 101
    M = [[0] * MM for _ in range(MM)]
    for r ,(x, y, h) in enumerate(XYH):
        if h == 0:
            M[x][y] = 0
            continue
        for i in range(MM):
            for j in range(MM):
                t = abs(i-x) + abs(j - y) + h
                if r == 0:
                    M[i][j] = t
                else:
                    if M[i][j] != t:
                        M[i][j] = 0
    
    for i in range(MM):
        for j in range(MM):
            if M[i][j] != 0:
                return '%d %d %d' % (i, j, M[i][j])
    
    assert False


def main():
    N = read_int()
    XYH = [read_int_n() for _ in range(N)]
    print(slv(N, XYH))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n= int(input())
data = []
for i in range(n):
    data.append(list(map(int,input().split())))
data.sort(key=lambda x:x[2],reverse=True)
ansflg = False
for xpos in range(101):
    for ypos in range(101):
        high = data[0][2] + abs(data[0][0]-xpos)+abs(data[0][1]-ypos)
        check = True
        for k in range(1,n):
            if high != data[k][2] + abs(data[k][0]-xpos)+abs(data[k][1]-ypos):
                check = False
                break
        if check:
            print('{} {} {}'.format(xpos,ypos,high))
            ansflg = True
            break
    if ansflg:
        break

Submission status: Wrong Answer

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

INF = float('inf')
for cx in range(0,101):
    for cy in range(0,101):
        tmph = None
        maxh = INF
        for x,y,h in src:
            if h > 0:
                tmp = h + abs(x-cx) + abs(y-cy)
                if tmph is None:
                    tmph = tmp
                else:
                    if tmp != tmph:
                        break
                if tmph >= maxh:
                    break
            else:
                maxh = min(maxh, abs(x-cx) + abs(y-cy))
        else:
            print(cx,cy,tmph)
            exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XYH):
    XYH.sort(key=lambda x: x[2], reverse=True)
    MM = 101
    M = [[0] * MM for _ in range(MM)]
    for r ,(x, y, h) in enumerate(XYH):
        if h == 0:
            continue
        for i in range(MM):
            for j in range(MM):
                t = abs(i-x) + abs(j - y) + h
                if r == 0:
                    M[i][j] = t
                else:
                    if M[i][j] != t:
                        M[i][j] = 0
    
    for i in range(MM):
        for j in range(MM):
            if M[i][j] != 0:
                return '%d %d %d' % (i, j, M[i][j])
    
    assert False


def main():
    N = read_int()
    XYH = [read_int_n() for _ in range(N)]
    print(slv(N, XYH))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = []
y = []
h = []
for i in range(n):
    temp = [int(_) for _ in input().split(' ')]
    x.append(temp[0])
    y.append(temp[1])
    h.append(temp[2])

for cx in range(101):
    for cy in range(101):
        ch = -1
        correctness = True
        for i in range(n):
            if ch > 0:
                if h[i] != max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0):
                    correctness = False
            if h[i] > 0:
                ch = h[i] + abs(cx - x[i]) + abs(cy - y[i])
        if correctness:
            print(ch)

Submission status: Wrong Answer

Solution code:
N = int(input())

points = []
for i in range(0, N):
    xi, yi, hi = map(int, input().split())
    points.append((xi, yi, hi))

for CX in range(101):
    for CY in range(101):
        Hs = set()
        for x, y, h in points:
            H = h + abs(x - CX) + abs(y - CY)
            if H < 0:
                break
            Hs.add(H)
        if len(Hs) == 1:
            print('{} {} {}'.format(CX, CY, H))
            exit()

Submission status: Wrong Answer

Solution code:

from operator import itemgetter

N = int(input())

XYH = []

for i in range(N):
    tmp = list(map(int, input().split()))
    XYH.append(tmp)

XYH.sort(key=itemgetter(2))
XYH.reverse()

for i in range(101):
    for j in range(101):
        
        H = XYH[0][2]+abs(XYH[0][0]-i)+abs(XYH[0][1]-j)
        flag = 1
        
        for k in range(1, N):
            small_H = XYH[k][2]+abs(XYH[k][0]-i)+abs(XYH[k][1]-j)
            if not small_H == H:
                flag = -1
                break
        
        if flag > 0:
            break
    if flag > 0:
        break    

ans = str(i)+' '+str(j)+' '+str(H)
  
print(ans)

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

Submission status: Wrong Answer

Solution code:
import itertools as it
import collections as col
import bisect

import sys
sys.setrecursionlimit(10000)

def main():
    N = int(input())
    coords = [tuple([int(x) for x in input().split()]) for _ in range(N)]
    
    for guess in it.product(range(101), repeat=2):
        okay = True
        c = coords[0]
        prev_h = c[2] + abs(guess[1] - c[1]) + abs(guess[0] - c[0])
        for c in coords:
            h = c[2] + abs(guess[1] - c[1]) + abs(guess[0] - c[0])
            if h != prev_h:
                okay = False
                break
        
        if okay:
            return '{} {} {}'.format(guess[0], guess[1], prev_h)
    
if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

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

if N == 1:
    print(G[0][0],G[0][1],G[0][2])
    exit(0)

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 and G[k][2] != 0:
                f = 0
            elif H-abs(Cx-G[k][0])-abs(Cy-G[k][1]) <= 0 and G[k][2] != 0:
                f = 0
            elif H-abs(Cx-G[k][0])-abs(Cy-G[k][1]) > 0 and 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())
x = []
y = []
h = []
for i in range(N):
    (tmp_x, tmp_y, tmp_h) = map(int, input().split())
    x.append(tmp_x)
    y.append(tmp_y)
    h.append(tmp_h)

def CalcHigh(cx, cy, px, py, ph):
    ch = ph + abs(cx-px) + abs(cy-py)
    return ch

for i in range(101):
    for j in range(101):
        ch = 0
        for k in range(N):
            if h[k] > 0:
                ch = CalcHigh(i, j, x[k], y[k], h[k])
        if ch == 0:
            ch = CalcHigh(i, j, x[0], y[0], h[0])

        flag = True
        for k in range(N):
            if h[k] == 0:
                continue
            if CalcHigh(i, j, x[k], y[k], h[k]) != ch:
                flag = False
                break
        if flag == True:
            ans = (i, j, ch)
            break
    else:
        continue
    break

print(ans[0], ans[1], ans[2])

Submission status: Wrong Answer

Solution code:
n = int(input())
cx,cy = 0,0
list_xyh = []
for i in range(n):
    list_xyh.append(list(map(int, input().split())))
for cx in range(0,101):
    for cy in range(0,101):
        H = abs(cx - list_xyh[0][0]) + abs(cy - list_xyh[0][1]) + list_xyh[0][2]
        for i in range(n):
            if list_xyh[i][2] != 0:
                if H - list_xyh[i][2] == abs(cx - list_xyh[i][0]) + abs(cy - list_xyh[i][1]):
                    continue
                else:
                    break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, XYH):
    XYH.sort(key=lambda x: x[2], reverse=True)
    MM = 101
    M = [[0] * MM for _ in range(MM)]
    for r ,(x, y, h) in enumerate(XYH):
        if h == 0:
            M[i][j] = 0
            continue
        for i in range(MM):
            for j in range(MM):
                t = abs(i-x) + abs(j - y) + h
                if r == 0:
                    M[i][j] = t
                else:
                    if M[i][j] != t:
                        M[i][j] = 0
    
    for i in range(MM):
        for j in range(MM):
            if M[i][j] != 0:
                return '%d %d %d' % (i, j, M[i][j])
    
    return 


def main():
    N = read_int()
    XYH = [read_int_n() for _ in range(N)]
    print(slv(N, XYH))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
lists = [list(map(lambda x:int(x),input().split())) for i in range(n)]
for i in range(101):
    for j in range(101):
        H = lists[0][2] + abs(lists[0][1] - j) + abs(lists[0][0] - i)
        for k in range(1,n):
            if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) >0:
                if lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i) != H:
                    break
                else :
                    if k == n-1:
                        print(i,j,lists[k][2] + abs(lists[k][1] - j) + abs(lists[k][0] - i))

Submission status: Wrong Answer

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

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


for i in range(101):
    for j in range(101):
        H = h[0] + abs(x[0] - i) + abs(y[0] - j)
        flag = 1
        for k in range(N):
            if(H != (h[k] + abs(x[k] - i) + abs(y[k] - j))):
                flag = 0
                break
        if(flag == 1):
            print("%d %d %d" %(i, j, H))
            exit()

Submission status: Wrong Answer

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

flag = True
flag2 = True

for x in range(0,101):
    for y in range(0,101):
        flag = True
        flag2 = True
        for i in range(0,N):
            if INFO[i][2] == 0:
                continue
            if flag:
                flag = False
                elseH = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            H = abs(x-INFO[i][0]) + abs(y-INFO[i][1]) + INFO[i][2]
            if H != elseH:
                flag2 = False
                break

        if flag2:
            break
    if flag2:
        break
print(x,y,H)

Submission status: Wrong Answer

Solution code:
n = int(input())
cx,cy = 0,0
list_xyh = []
for i in range(n):
    list_xyh.append(list(map(int, input().split())))
print(list_xyh)
for cx in range(0,101):
    for cy in range(0,101):
        H = abs(cx - list_xyh[0][0]) + abs(cy - list_xyh[0][1]) + list_xyh[0][2]
        for i in range(n):
            if list_xyh[i][2] != 0:
                if H - list_xyh[i][2] == abs(cx - list_xyh[i][0]) + abs(cy - list_xyh[i][1]):
                    continue
                else:
                    break
        else:
            print(cx,cy,H)
            break
    else:
        continue
    break

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        pt = 0
        while lines[pt][2] == 0:
            pt += 1
        x0, y0, h0 = lines[pt]
        h = h0 + abs(cx - x0) + abs(cy - y0)
        flag = True
        for x0, y0, h0 in lines:
            tmp = h0 + abs(cx - x0) + abs(cy - y0)
            if h0 > 0 and tmp != h:
                flag = False
                break
        if flag:
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

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

R.sort(reverse=True)
# print(R)

def solve():
    for cx in range(101):
        for cy in range(101):
            x, y, h = R[0]
            H = h + abs(x - cx) + abs(y - cy)
            for i in range(1, N):
                x, y, h = R[i]
                if h != 0:
                    tempH = h + abs(x - cx) + abs(y - cy)
                    if tempH != H:
                        break
            else:
                print(cx, cy, H)
                return

solve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
ta = [list(map(int,input().split())) for _ in range(N)]
for cx in range(101):
    for cy in range(101):
        # もしcx,cyが決まっていた場合矛盾が起こらないか
        # H = abs(x-cx)+abs(y-cy) + h
        H = None
        for [x,y,h] in ta:
            if h == 0:
                pass
            else:
                if H is None:
                    H = h + abs(x-cx)+abs(y-cy)
                else:
                    if H != h + abs(x-cx)+abs(y-cy):
                        break
        else:
            print(cx,cy,H)

Submission status: Wrong Answer

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

import itertools


MIN_C = 0
MAX_C = 100


def validate_c(conds, c_x, c_y):
    h = None
    for x, y, z in conds:
        if z <= 0:
            continue
        h_targ = abs(x - c_x) + abs(y - c_y) + z
        if h is None:
            h = h_targ
        elif h != h_targ:
            return (False, None)
    else:
        return (True, h)    


def solve(conds):
    if all(z == 0 for _, _, z in conds):
        x_min = min(x for x, _, _ in conds)
        x_max = max(x for x, _, _ in conds)
        y_min = min(y for _, y, _ in conds)
        y_max = max(y for _, y, _ in conds)
        c_x = (x_min + x_max) // 2
        c_y = (y_min + y_max) // 2
        x, y, z = conds[0]
        h = abs(x - c_x) + abs(y - c_y) + z
        return c_x, c_y, h
    for c_x, c_y in itertools.product(range(MIN_C, MAX_C + 1), repeat=2):
        j, h = validate_c(conds, c_x, c_y)
        if j:
            return c_x, c_y, h
                


def main():
    n = (int(input()))
    conds = [tuple(int(z) for z in input().split()) for _ in range(n)]
    res = solve(conds)
    print(*res)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = int(input())

b = []

c = []

p = 0
pp = 0
ppp = 0
for i in range(a):
    b.append(list(map(int,input().split())))

for i in range(0,101):
    for j in range(0,101):
        for k in range(a):
            if k == 0:
                p = abs(b[k][0] - i) + abs(b[k][1]-j)+b[k][2]
                if p == 0:
                    pp == 1
                    break
            else:
                if max(0,p - abs(b[k][0]-i)- abs(b[k][1]-j)) != b[k][2]:
                    pp = 1
        if pp == 0:
            ppp = 1
            break
        else:
            pp = 0
    if ppp == 1:
        print(i,j,p)
        break

Submission status: Wrong Answer

Solution code:
import sys
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
x = 0
y = 0
while y <= 100:
  x = 0
  while x <= 100:
    lis = []
    for arrays in grid:
      lis.append(arrays[2]+abs(x-arrays[0])+abs(y-arrays[1]))
    if min(lis)==max(lis):
      print(x,y,arrays[2]+abs(x-arrays[0])+abs(y-arrays[1]))
      sys.exit()
    x += 1
  y += 1

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
if n>=4:
 for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]==abs(l[2][0]-x)+abs(l[2][1]-y)+l[2][2]==abs(l[3][0]-x)+abs(l[3][1]-y)+l[3][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
elif n>=3:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]==abs(l[2][0]-x)+abs(l[2][1]-y)+l[2][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])
else:
  for x in range(101):
   for y in range(101):
     if abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2]==abs(l[1][0]-x)+abs(l[1][1]-y)+l[1][2]:
       print(x,y,abs(l[0][0]-x)+abs(l[0][1]-y)+l[0][2])

Submission status: Wrong Answer

Solution code:
def big(a,b):
    if a >= b:
        return a
    else:
        return b

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

info.sort(key = lambda x: [2])
info.reverse()

check = False
for cx in range(101): 
    for cy in range(101):
        high = info[0][2] + abs(info[0][0]-cx) + abs(info[0][1]-cy)
        temp = True
        for i in range(1,len(info)):
            if info[i][2] != big(high-abs(info[i][0]-cx)-abs(info[i][1]-cy),0):
                temp = False
        if temp:
            check = True
            break
    if check:
        break
print(cx,cy,high)