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())
list1=[]
for i in range(N):
  x1=list(map(int,input().split()))
  list1.append(x1)
flag=0
for i in range(101):
  for j in range(101):
    list2=[]
    for k in range(N):
      Hx=list1[k][2]+abs(list1[k][0]-i)+abs(list1[k][1]-j)
      if Hx-abs(list1[k][0]-i)-abs(list1[k][1]-j)<0:
        break
      else:
        list2.append(Hx)
    if len(set(list2))==1 and Hx>=1:
      print(i,j,Hx)
      flag=1
    else:
        pass
    if flag==1:
      break
  if flag==1:
    break

Submission status: Wrong Answer

Solution code:
n = int(input())
zahyou1 = []
zahyou2 = []
zahyou3 = []
zahyou4 = []
# for i in range(n):
#     x,y,z = map(int,input().split())
#     zahyou1.append(x+y+z)
#     zahyou2.append(x-y+z)
#     zahyou3.append(y-x+z)
#     zahyou4.append(z-x-y)
# print(zahyou1)
# print(zahyou2)
# print(zahyou3)
# print(zahyou4)

zahyou = []
test_z = n
for i in range(n):
    x,y,z = map(int,input().split())
    zahyou.append([x,y,z])
    test_z += z
h = round(test_z/n)
# print(h)
for j in range(n):
    zahyou1.append(x+y+z)
    zahyou2.append(x-y+z)
    zahyou3.append(y-x+z)
    zahyou4.append(z-x-y)
# print(zahyou1)
# print(zahyou2)
# print(zahyou3)
# print(zahyou4)
xplusy = max((zahyou1[0] - h),0)
xminusy = max((zahyou2[0] - h),0)
# print(xplusy)
# print(xminusy)
y = (xplusy + xminusy)/2
x = xplusy - y
print(str(int(x)) + ' ' + str(int(y)) + ' ' + str(h))

Submission status: Wrong Answer

Solution code:
N = int(input())
H = 1
Cx = 0
Cy = 0
xs = []
ys = []
hs = []
u_Cx = []
u_Cy = []

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

	xs.append(x)
	ys.append(y)
	hs.append(h)
	if(x not in u_Cx):
		u_Cx.append(x)
	if(y not in u_Cy):
		u_Cy.append(y)

	if(H<h):
		H = h
		Cx = x
		Cy = y

max_h = max(hs)
if(hs.count(max_h)>=2):
	H = max_h+1
	if(sum(xs)%len(xs)==0):
		Cx = sum(xs)//len(xs)
	else:
		if(sum(xs)%len(xs)<(len(xs)/2)):
			Cx = sum(xs)//len(xs) + 1
		else:
			Cx = sum(xs)//len(xs)


	if(sum(ys)%len(ys)==0):
		Cy = sum(ys)//len(ys)
	else:
		if(sum(ys)%len(ys)<(len(ys)/2)):
			Cy = sum(ys)//len(ys) + 1
		else:
			Cy = sum(ys)//len(ys)

print(Cx,Cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)
    
end = 0
if n >=3:
    for x in range(101):
        for y in range(101):
            H = info[0][2] + abs(x-info[0][0]) + abs(y-info[0][1])
            if H <= 10**9:
                for i in range(1,n):
                    if info[i][2] != H - abs(x-info[i][0]) - abs(y- info[i][1]):
                        break
                else:
                    print(x,y,H)
                    end = 1
                
                if end == 1:
                    break
            if end == 1:
                break
elif n ==2:
    info = sorted(info, key = lambda x:x[2])
    if info[0][0] > info[1][0]:
        h = info[1][2] + info[1][0]
        x = 0
    else:
        h = info[1][2] + 100- info[1][0]
        x = 100
    if info[0][1] > info[1][1]:
        h += info[1][1]
        y = 0
    else:
        h += 100 - info[1][1]
        y =100
    ans = list(map(str,(x,y,h)))
    print(" ".join(ans))

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):
        ans = 1
        H = 1
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            H = max(H, abs(x - CX) + abs(y - CY) + h)
            #print(CX, CY)
            
        for j in xyh:
            x = j[0]
            y = j[1]
            h = j[2]
            if h != max(H - abs(x - CX) - abs(y - CY), 0):
                ans = -1
                break

        if ans == 1:
            print(CX, CY, H)
            break
    if ans == 1:
        break

Submission status: Wrong Answer

Solution code:
def cal(X,Y,H):

    for i in range(0,101): #C_x
        for j in range(0,101): #C_y
            temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
            for l in range(1,N):
                if(H[l]!=0):
                    s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                    if(temp==s):
                        temp=s
                    else:
                        break
                else:
                    if(temp-abs(X[l]-i)-abs(Y[l]-j)>0):
                        break
            else:    
                return print("{} {} {}".format(i,j,temp))

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

Submission status: Wrong Answer

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

x_s = 0
x_e = 100
y_s = 0
y_e = 100

for x, y, z in X:
    for x2, y2, z2 in X:
        if (x, y) == (x2, y2):
            continue
        d = abs(x-x2) + abs(y-y2)
        if d == z - z2:
            if x != x2:
                if x <= x2:
                    x_e = min(x_e, x) #左側
                else:
                    x_s = max(x_s, x) #右側
            if y != y2:
                if y <= y2:
                    y_e = min(y_e, y) #上川
                else:
                    y_s = max(y_s, y) #下側

        else:
            if x != x2:
                if x <= x2:
                    x_s = max(x_s, x) #左側
                else:
                    x_e = min(x_e, x) #右側
            if y != y2:
                if y <= y2:
                    y_s = max(y_s, y) #上川
                else:
                    y_e = min(y_e, y) #下側

x, y, z = X[0]
print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))

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(0,N):
            comp = heights[i]
            if (cand_h - abs(comp[0]-x) - abs(comp[1]-y)) >= 0:
                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
if N == 1:
    print(fx, fy, fh)
else:
    print(ansx,ansy,ansh)

Submission status: Wrong Answer

Solution code:
n = int(input())
P = [0] * n
for i in range(n):
    P[i] = list(map(int, input().split()))
P = sorted(P, key=lambda x: x[2], reverse=True)

x, y, h = P[-1]
max_h = max(100-x, x, 100-y, y) + h

P2 = []
for i in range(101):
    for j in range(101):
        P2.append((i, j))
P2 = set(P2)
for hh in range(max_h, P[-1][2]-1, -1):
    P3 = P2.copy()
    for x, y, h in P:
        for xx, yy in P2:
            dh = hh - h
            dx = abs(xx - x)
            dy = abs(yy - y)
            if hh - dx - dy != h:
                if (xx, yy) in P3:
                    P3.remove((xx, yy))
    if len(P3) == 1:
        xx, yy = P3.pop()
        print('%d %d %d' % (xx, yy, hh))

Submission status: Wrong Answer

Solution code:
import sys
import itertools


def height(x, y, Cx, Cy, H):
    return max([H - abs(x - Cx) - abs(y - Cy), 0])


N = int(sys.stdin.readline().strip())

set_list = []
for line in sys.stdin.readlines():
    x, y, h = list(map(int, line.strip().split()))
    ans_set = set()
    for Cx, Cy in itertools.product(range(101), range(101)):
        dx = abs(x - Cx)
        dy = abs(y - Cy)
        d = dx + dy
        H = h + d
        if H >= d:
            ans_set.add((Cx, Cy, H))
    set_list.append(ans_set)

ans_set = set_list[0]
for s in set_list[1:]:
    ans_set = ans_set & s

if len(ans_set) == 1:
    Cx, Cy, H = list(ans_set)[0]
    print(Cx, Cy, H)
else:
    print("error,", ans_set)

Submission status: Wrong Answer

Solution code:
N = int(input())

X = [None] * N
Y = [None] * N
H = [None] * N

x_max = 0
y_max = 0
h_max = 0
R = []

for n in range(N):
    X[n], Y[n], H[n] = map(int, input().split())
    if h_max <= H[n]:
        x_max, y_max, h_max = X[n], Y[n], H[n]

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True
        for n in range(N):
            if n == 0:
                ch = H[n] + abs(X[n] - cx) + abs(Y[n] - cy)
            if max(ch - abs(X[n] - cx) - abs(Y[n] - cy), 0) != H[n]:
                flag = False
                break
        if flag == True:
            R.append([cx, cy, ch])

if len(R) == 1:
    print(R[0][0], R[0][1], R[0][2])
elif len(R) == 0:
    print(x_max, y_max, h_max)
else:
    print(R[-1][0], R[-1][1], R[-1][2])

Submission status: Wrong Answer

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = 0
H_temp = None

x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H_temp = abs(c_x - x) + abs(c_y - y) + h
                elif H_temp != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if H < H_temp:
                    Cx = c_x
                    Cy = c_y
                    H = H_temp

print("{0} {1} {2}".format(Cx, Cy, H))

Submission status: Wrong Answer

Solution code:
n = int(input())
zahyou1 = []
zahyou2 = []
zahyou3 = []
zahyou4 = []
# for i in range(n):
#     x,y,z = map(int,input().split())
#     zahyou1.append(x+y+z)
#     zahyou2.append(x-y+z)
#     zahyou3.append(y-x+z)
#     zahyou4.append(z-x-y)
# print(zahyou1)
# print(zahyou2)
# print(zahyou3)
# print(zahyou4)

zahyou = []
test_z = n
for i in range(n):
    x,y,z = map(int,input().split())
    zahyou.append([x,y,z])
    test_z += z
h = round(test_z/n)
print(h)
for j in range(n):
    zahyou1.append(x+y+z)
    zahyou2.append(x-y+z)
    zahyou3.append(y-x+z)
    zahyou4.append(z-x-y)
print(zahyou1)
print(zahyou2)
print(zahyou3)
print(zahyou4)
xplusy = max((zahyou4[0] - h),0)
xminusy = max((zahyou2[0] - h),0)
print(xplusy)
print(xminusy)
y = (xplusy + xminusy)/2
x = xplusy - y
print(str(int(x)) + ' ' + str(int(y)) + ' ' + str(h))

Submission status: Wrong Answer

Solution code:

def main():
    buf = input()
    N = int(buf)
    x = []
    y = []
    h = []
    for i in range(N):
        buf = input()
        buflist = buf.split()
        x.append(int(buflist[0]))
        y.append(int(buflist[1]))
        h.append(int(buflist[2]))
    for cx in range(101):
        for cy in range(101):
            H = h[0] + dist(cx, cy, x[0], y[0])
            correct = True
            for i in range(1, N):
                if h[i] + dist(cx, cy, x[i], y[i]) != H:
                    if dist(cx, cy, x[i], y[i]) <= H:
                        correct = False
                        break
                    else:
                        if h[i] != 0:
                            correct = False
                            break
            if correct == True:
                print(cx, cy, H)
                return


def dist(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

X=0
Y=0
H=0

for _ in range(N):
    x,y,h = map(int,input().split())
    X+=x
    Y+=y

X=round(X/N)
Y=round(Y/N)
#max(H−|X−CX|−|Y−CY|,0)
H = max(h+abs(x-X)+abs(y-Y),0)

print(X,Y,H)

Submission status: Wrong Answer

Solution code:
N = int(input())

info_list = []

def abs(x):
    if x < 0:
        return -x
    else:
        return x

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

def solve():
    for Cx in range(0, 101):
        for Cy in range(0, 101):
            flag = True
            H = -1
            for x, y, h in info_list:
                #print(x, y, h)
                if h > 0:
                    if H == -1:
                        H = h + abs(x - Cx) + abs(y - Cy)
                    else:
                        if H != h + abs(x - Cx) + abs(y - Cy):
                            flag = False
                            break
                else:
                    if H != -1:
                        if H < abs(x - Cx) + abs(y - Cy):
                            flag = False
                            break

            if flag:
                print(Cx, Cy, H)
                return

solve()

Submission status: Wrong Answer

Solution code:
n = int(input())

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)
    
end = 0
if n >=3:
    for x in range(101):
        for y in range(101):
            H = info[0][2] + abs(x-info[0][0]) + abs(y-info[0][1])
            for i in range(1,n):
                if info[i][2] != max(0,H - abs(x-info[i][0]) - abs(y- info[i][1])):
                    break
            else:
                print(x,y,H)
                end = 1
            
            if end == 1:
                break
        if end == 1:
            break
elif n ==2:
    info = sorted(info, key = lambda x:x[2])
    if info[0][0] > info[1][0]:
        h = info[1][2] + info[1][0]
        x = 0
    else:
        h = info[1][2] + 100- info[1][0]
        x = 100
    if info[0][1] > info[1][1]:
        h += info[1][1]
        y = 0
    else:
        h += 100 - info[1][1]
        y =100
    ans = list(map(str,(x,y,h)))
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:

n = int(input())
card = []

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

def check(cx,cy):
    for i in range(n):
        x,y,h = card[i]
        if h == 100:
            print("{} {} {}".format(x,y,h))
            exit()
        if i == 0:
            H = abs(x-cx)+abs(y-cy)+h  

        if h == max((H-abs(x-cx)-abs(y-cy)),0):
            H = abs(x-cx)+abs(y-cy)+h 
            continue
        else:
            return False
    else:
        return True
    
for i in range(101):
    for j in range(101):
        if check(i,j):
            ax = i
            ay = j
            
            x1,y1,h1 = card[0]
            ah = abs(x1-i)+abs(y1-j)+h1

            print("{} {} {}".format(ax,ay,ah))
            exit()

Submission status: Wrong Answer

Solution code:
import sys
import itertools


def height(x, y, Cx, Cy, H):
    return max([H - abs(x - Cx) - abs(y - Cy), 0])


N = int(sys.stdin.readline().strip())

set_list = []
for line in sys.stdin.readlines():
    x, y, h = list(map(int, line.strip().split()))
    ans_set = set()
    for Cx, Cy in itertools.product(range(101), range(101)):
        dx = abs(x - Cx)
        dy = abs(y - Cy)
        d = dx + dy
        H = h + d
        if H > d:
            ans_set.add((Cx, Cy, H))
    set_list.append(ans_set)

ans_set = set_list[0]
for s in set_list[1:]:
    ans_set = ans_set & s

if len(ans_set) == 1:
    Cx, Cy, H = list(ans_set)[0]
    print(Cx, Cy, H)
else:
    print("error,", ans_set)

Submission status: Wrong Answer

Solution code:
N = int(input())

X = [None] * N
Y = [None] * N
H = [None] * N

x_max = 0
y_max = 0
h_max = 0
R = []

for n in range(N):
    X[n], Y[n], H[n] = map(int, input().split())
    if h_max <= H[n]:
        x_max, y_max, h_max = X[n], Y[n], H[n]

for cx in range(0, 101):
    for cy in range(0, 101):
        flag = True
        for n in range(N):
            if n == 0:
                ch = H[n] + abs(X[n] - cx) + abs(Y[n] - cy)
            if max(ch - abs(X[n] - cx) - abs(Y[n] - cy), 0) != H[n]:
                flag = False
                break
        if flag == True:
            R.append([cx, cy, ch])

if len(R) == 1:
    print(R[0][0], R[0][1], R[0][2])
else:
    pass

Submission status: Wrong Answer

Solution code:
"""
C - Pyramid
高さ0以下が正しくないが、とりあえずチェック
"""

n = int(input())

points = []
points_diff = []
diff = 0
for i in range(n):
    part = list(map(int, input().split()))
    points.append(part)
    if i != 0:
        points_diff.append(part[2] - diff)
    diff = part[2]

#print(points_diff)


# 100 * 100 を走査する
for cx in range(101):
    for cy in range(101):

        #print("cx", cx, "cy", cy)
        
        find = True

        diff = 0
        # 各点についてチェックする
        for point_n in range(len(points)):
            point = points[point_n]
            temp_h =  - abs(point[0] - cx) - abs(point[1] - cy)
            #print("temp_h", temp_h)
            if point_n != 0:
                point_diff = temp_h - diff
                if point_diff != points_diff[point_n - 1]:
                    #print("ちがう")
                    find = False
                    break

            diff = temp_h
        
        if find is True:
            #print("みつけた？")
            h = abs(points[0][0] - cx) + abs(points[0][1] - cy) + points[0][2]
            #print(points[0][0], points[0][1], points[0][2])
            #print(abs(points[0][0] - cx), abs(points[0][1] - cy), points[0][2])
            print(cx, cy, h)
            exit()

Submission status: Wrong Answer

Solution code:
def cal(X,Y,H):

    zerolist=[]
    for i in range(0,101): #C_x
        for j in range(0,101): #C_y
            temp=H[0]+abs(X[0]-i)+abs(Y[0]-j)
            for l in range(1,N):
                if(H[l]!=0):
                    s=H[l]+abs(X[l]-i)+abs(Y[l]-j)
                    if(temp==s):
                        temp=s
                    else:
                        break
                else:
                    zerolist.append(l)
            else:
                for k in zerolist:
                    if(temp-abs(X[k]-i)-abs(Y[k]-j)>=0):
                        break
                else:    
                    return print("{} {} {}".format(i,j,temp))

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
xyh = []
for _ in range(n):
    xyh.append(tuple(list(li())))
    

# 中心になりうる点を全探索
def search_cent(xyh: list):
    n = len(xyh)
    for x_cent in range(101):
        for y_cent in range(101):
            
            # 各点と中心との距離
            dist = []
            is_cent = True
            for x,y,_ in xyh:
                dist.append((abs(x-x_cent), abs(y-y_cent)))
                
            # 中心との距離と高さの差に矛盾が無いかチェック
            for i in range(n):
                for j in range(n):
                    if xyh[i][2] == 0 or xyh[j][2] == 0:
                        continue
                    
                    if (xyh[i][2]-xyh[j][2]) != -(sum(dist[i]) - sum(dist[j])):
                        is_cent = False
                        break
                if not is_cent:
                    break

            if is_cent:
                return x_cent, y_cent

                
x_cent, y_cent = search_cent(xyh)
h_cent = xyh[0][2] + abs(xyh[0][0] - x_cent) + abs(xyh[0][1] - y_cent)

print(x_cent, y_cent, h_cent)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
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 = 0
if max(h)-min(h)==0 and min(h)>=100:
    diff=min(h)-5
h=[i-diff for i in h]
# print(h)
def pattern(cx,cy,H):
    for i in range(n):
        # print(cx,x[i],cy,y[i],H,h[i],max(H-abs(x[i]-cx)-abs(y[i]-cy),0))
        if max(H-abs(x[i]-cx)-abs(y[i]-cy),0)!=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:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
x = []
y = []
h = []
for i in range(n):
    xi, yi, hi = list(map(int, input().split()))
    x.append(xi)
    y.append(yi)
    h.append(hi)


for cx, cy in itr.product(range(101),range(101)):
    hh = set([])  
    for i in range(n):
        if h[i] >= 0:
            hh.add(abs(x[i]-cx)+abs(y[i]-cy)+h[i])
            #print(cx, cy, i, hh)
            if  len(hh) > 1:
                break
    else:
        if len(hh) == 1:
            print(cx, cy, hh.pop())
            break

Submission status: Wrong Answer

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = None

x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H = abs(c_x - x) + abs(c_y - y) + h
                elif H != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if len(x_y_h_tmp) == len([xyh for xyh in x_y_h if abs(c_x - xyh[0]) + abs(c_y - xyh[1]) + xyh[2] > 0]):
                    Cx = c_x
                    Cy = c_y
                    print("{0} {1} {2}".format(Cx, Cy, H))
                    sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())

info = []
for i in range(n):
    pre = list(map(int,input().split(" ")))
    info.append(pre)
    
end = 0
if n >=3:
    for x in range(101):
        for y in range(101):
            H = info[0][2] + abs(x-info[0][0]) + abs(y-info[0][1])
            for i in range(1,n):
                if info[i][2] != H - abs(x-info[i][0]) - abs(y- info[i][1]):
                    break
            else:
                print(x,y,H)
                end = 1
            
            if end == 1:
                break
        if end == 1:
            break
elif n ==2:
    info = sorted(info, key = lambda x:x[2])
    if info[0][0] > info[1][0]:
        h = info[1][2] + info[1][0]
        x = 0
    else:
        h = info[1][2] + 100- info[1][0]
        x = 100
    if info[0][1] > info[1][1]:
        h += info[1][1]
        y = 0
    else:
        h += 100 - info[1][1]
        y =100
    ans = list(map(str,(x,y,h)))
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
for i in range(N):
  x1=list(map(int,input().split()))
  list1.append(x1)
flag=0
for i in range(101):
  for j in range(101):
    list2=[]
    for k in range(N):
      Hx=list1[k][2]+abs(list1[k][0]-i)+abs(list1[k][1]-j)
      if Hx-abs(list1[k][0]-i)-abs(list1[k][1]-j)<0:
        continue
      else:
        list2.append(Hx)
    if len(set(list2))==1 and Hx>=1:
      print(i,j,Hx)
      flag=1
    else:
        pass
    if flag==1:
      break
  if flag==1:
    break

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        tl = []
        for l in xyh:
            h = abs(l[0] - i) + abs(l[1] - j) + l[2]
            tl.append(h)
        
        ts = set(tl)
        if len(ts) == 1 and tl[0] != 0:
            print("{} {} {}".format(i, j, tl[0]))
            exit(0)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
li = [list(map(int,input().split())) for i in range(n)]
h = 0
flag = False
for i in range(101):
    if flag == True:
        break
    for j in range(101):
        co = 0
        h = 0
        if flag == True:
            break
        for k in li:
            h1 = k[2] + abs(i-k[0]) + abs(j-k[1])
            if co == 0:
                h = h1
            if h != h1:
                break
            co +=1
            if co == n:
                flag = True
                print(str(i)+" "+str(j)+" "+str(h1))

Submission status: Wrong Answer

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

x_s = 0
x_e = 100
y_s = 0
y_e = 100

for x, y, z in X:
    for x2, y2, z2 in X:
        if (x, y) == (x2, y2):
            continue
        d = abs(x-x2) + abs(y-y2)
        if d == z - z2:
            if x != x2:
                if x <= x2:
                    x_e = min(x_e, x) #左側
                else:
                    x_s = max(x_s, x) #右側
            if y != y2:
                if y <= y2:
                    y_e = min(y_e, y) #上川
                else:
                    y_s = max(y_e, y) #下側

        else:
            if x != x2:
                if x <= x2:
                    x_s = max(x_s, x) #左側
                else:
                    x_e = min(x_e, x) #右側
            if y != y2:
                if y <= y2:
                    y_s = max(y_e, y) #上川
                else:
                    y_e = min(y_e, y) #下側

x, y, z = X[0]
print(x_e, y_e, z + abs(x_e - x) + abs(y_e - y))

Submission status: Wrong Answer

Solution code:

def main():
    n = int(input())

    lst = [0 for i in range(n)]
    for i in range(n):
        lst[i] = list(map(int,input().split()))

    zero = False
    for i in range(n):
        if lst[i][2] != 0:
            break
        if i == n-1:
            zero = True

    if zero == True:
        for i in range(101):
            for j in range(101):
                for k in range(n):
                    if k == 0:
                        h = lst[k][2] + abs(lst[k][0] - i) + abs(lst[k][1] - j)
                        continue

                    if h == abs(lst[k][0] - i) + abs(lst[k][1] - j) + lst[k][2]:
                        if k == n-1:
                            print(str(i)+ " " + str(j) + " " + str(h))
                        else:
                            continue
                    else:
                        break


    for i in range(101):
        for j in range(101):
            remain = []
            remain_flag = False
            for k in range(n):
                if k == 0 or remain_flag:
                    if lst[k][2] == 0:
                        remain.append(lst[k])
                        remain_flag = True
                        continue

                    h = lst[k][2] + abs(lst[k][0] - i) + abs(lst[k][1] - j)
                    remain_flag = False
                    continue

                if max(h - abs(lst[k][0] - i) - abs(lst[k][1] - j),0) == lst[k][2]:
                    if k == n-1:
                        for remain in remain:
                            if max(h - abs(remain[0] - i) - abs(remain[1] - j),0) != remain[2]:
                                break

                        print(str(i)+ " " + str(j) + " " + str(h))
                        exit()
                    continue
                else:
                    break


if __name__ == "__main__":
        main()

Submission status: Wrong Answer

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

n = int(input())
arr=[]
for i in range(n):
    arr.append(list(map(int, input().split())))
isSame = True
for cx in range(0,101):
    for cy in range(0,101):
        h_prev=-1
        for a in arr:
            if a[2]>=0:
                h= H(a[2],cx,cy,a[0],a[1])
                if h_prev==-1:
                    h_prev=h
                if h!=h_prev:
                    isSame=False
                    break
                else:
                    h_prev=h
        if isSame==True:
            print("{} {} {}".format(cx,cy,h))
            exit

Submission status: Wrong Answer

Solution code:
n = int(input())

if n == 1:
    Cx, Cy, H = map(int, input().split())
    print(Cx, Cy, H)
elif n == 2:
    x_1, y_1, h_1 = map(int, input().split())
    x_2, y_2, h_2 = map(int, input().split())
    if h_1 >= h_2:
        print(x_1, y_1, h_1)
    else:
        print(x_2, y_2, h_2)

Submission status: Wrong Answer

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

N = int(Input())
x_y_h = [list(map(int, Input().split())) for _ in range(N)]
Cx = None
Cy = None
H = None

x_y_h_tmp = [xyh for xyh in x_y_h if xyh[2] > 0]
if N == 1:
    print("{0} {1} {2}".format(x_y_h[0][0], x_y_h[0][1], x_y_h[0][2]))
else:
    for c_x in range(0, 100+1):
        for c_y in range(0, 100+1):
            for i, (x, y, h) in enumerate(x_y_h_tmp):
                if i == 0:
                    H = abs(c_x - x) + abs(c_y - y) + h
                elif H != abs(c_x - x) + abs(c_y - y) + h:
                    break
            else:
                if len(x_y_h_tmp) == len([xyh for xyh in x_y_h if abs(c_x - xyh[0]) + abs(c_y - xyh[1]) + xyh[2] >= 0]):
                    Cx = c_x
                    Cy = c_y
                    print("{0} {1} {2}".format(Cx, Cy, H))
                    sys.exit()