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:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 17:56:47 2018
ABC112C
@author: maezawa
"""
import itertools as itr
n = int(input())
xyh = []
for i in range(n):
    xyhi = list(map(int, input().split()))
    xyh.append(xyhi)
xyh.sort(key=lambda x:x[2], reverse=True)

for cx, cy in itr.product(range(101),range(101)):
    hres = abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    ok = 0
    for i in range(1,n):
        if xyh[i][2] > 0:
            htemp = abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]
            #print(cx, cy, i, hh)
            if  htemp != hres:
                ok = -1
                break    
        else:
            if abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy) <= hres:
                continue
            else:
                ok = -1
                break
    if ok == 0:
        break
print(cx, cy, hres)

Submission status: Wrong Answer

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

W = 101

cs = [[0] * W for i in range(W)]

h = XYH[0][2]
sx, sy = XYH[0][0:2]
for x in range(W):
    for y in range(W):
        cs[y][x] = h + abs(x - sx) + abs(y - sy)

for i in range(1, N):
    h = XYH[i][2]
    sx, sy = XYH[i][0:2]
    for x in range(W):
        for y in range(W):
            h1 = h + abs(x - sx) + abs(y - sy)
            if cs[y][x] != h1:
                cs[y][x] = 0

cx, cy, ch = 0, 0, 0

for x in range(W):
    for y in range(W):
        h = cs[y][x]
        if h > 0:
            cx, cy, ch = x, y, h

print(cx, cy, ch)

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([]) 
    ok = 0
    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:
                ok = -1
                break
    if ok != -1:
        if len(hh) == 0:
            continue
        else:
            hres = hh.pop()
            for i in range(n):      
                if h[i]==0:
                    if abs(x[i]-cx)+abs(y[i]-cy) <= hres:
                        continue
                    else:
                        ok = -1
                        break
    if ok == 0:
        break
print(cx, cy, hres)

Submission status: Wrong Answer

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
values = []
for i in range(N):
    [x, y, h] = list(map(int, input().split()))
    if h != 0:
        values.append([x, y, h])

H_matrix = np.empty([101, 101, len(values)])
for i, [x, y, h] in enumerate(values):
    H_matrix[:, :, i] = h + np.abs(cx - x).reshape(-1, 1) + np.abs(cy - y).reshape(1, -1)
H = (H_matrix.max(axis=-1) - H_matrix.min(axis=-1)) == 0
X = np.argmax(H, axis=0).max()
Y = np.argmax(H, axis=1).max()
H = int(max(H_matrix[X, Y]))
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
values = []
for i in range(N):
    [x, y, h] = list(map(int, input().split()))
    if h != 0:
        values.append([x, y, h])

H_matrix = np.empty([101, 101, len(values)])
for i, [x, y, h] in enumerate(values):
    H_matrix[:, :, i] = h + np.abs(cx - x).reshape(1, -1) + np.abs(cy - y).reshape(-1, 1)
H_matrix[H_matrix<0] = 0
H = (H_matrix.max(axis=-1) - H_matrix.min(axis=-1)) == 0
Y = np.argmax(H, axis=0).max()
X = np.argmax(H, axis=1).max()
H = int(H_matrix[Y, X, 0])
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
border = 101


def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)


def judge_center(Cx, Cy, cords):
    for x, y, h in cords:
        if h > 0:
            H = abs(cords[0][0] - Cx) + abs(cords[0][1] - Cy) + cords[0][2]
            break
    for x, y, h in cords:
        tmp = manhattan_distance(Cx, Cy, H, x, y)
        if (h > 0 and H != tmp) or (h == 0 and H > tmp):
            return -1
    return H


def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
border = 101


def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)


def judge_center(Cx, Cy, cords):
    for x, y, h in cords:
        if h > 0:
            H = abs(cords[0][0] - Cx) + abs(cords[0][1] - Cy) + cords[0][2]
            break
    for x, y, h in cords:
        tmp = manhattan_distance(Cx, Cy, H, x, y)
        if (h > 0 and h != tmp) or (h == 0 and h > tmp):
            return -1
    return H


def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
border = 101


def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)


def judge_center(Cx, Cy, cords):
    for x, y, h in cords:
        if h > 0:
            H = abs(cords[0][0] - Cx) + abs(cords[0][1] - Cy) + cords[0][2]
            break
    for x, y, h in cords:
        if h != manhattan_distance(Cx, Cy, H, x, y):
            return -1
    return H


def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n + 1):
            if j == n:
                break
            if max(H[0] - abs(x[j] - cx) - abs(y[j] - cy), 0) != h[j]:
                break
        if j == 1:
            break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
x = []
y = []
h = []
for i in range(n):
    X, Y, H = map(int, input().split())
    x.append(X)
    y.append(Y)
    h.append(H)
for cx, cy in itertools.product(range(101), range(101)):
    H = []
    for i in range(n):
        if h[i] == 0:
            continue
        H.append(h[i] + abs(x[i] - cx) + abs(y[i] - cy))
    if len(set(H)) == 1 and H[0] >= 1:
        for j in range(n + 1):
            if j == n:
                break
            if max(H[0] - abs(x[j] - cx) - abs(y[j] - cy), 0) != h[j]:
                break
        if n == 1:
            break
print("{} {} {}".format(cx, cy, H[0]))

Submission status: Wrong Answer

Solution code:
MAX = 101

def judge_center(Cx, Cy, cords):
    H = -1
    for x, y, h in cords:
        if h > 0:
            tmpH = abs(x - Cx) + abs(y - Cy) + h
            if H == -1:
                H = tmpH
            else:
                if tmpH != H:
                    return -1
    for x, y, h in cords:
        if h == 0:
            tmpH = abs(x - Cx) + abs(y - Cy) + h
            if H != tmpH:
                return -1
    return H

def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(MAX):
        for tmp_Cy in range(MAX):
            H = judge_center(tmp_Cx, tmp_Cy, cords)
            if H != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, H))
                return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = [LGIS() for _ in range(GI())]

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                #if h == 0:
                #    continue
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return

main()

Submission status: Wrong Answer

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
H_matrix = np.empty([101, 101, N])
for i in range(N):
    [x, y, h] = [int(i) for i in input().split()]
    H_matrix[:, :, i] = h + np.abs(cx - x).reshape(1, -1) + np.abs(cy - y).reshape(-1, 1)
H_matrix[H_matrix<0] = 0
H = (H_matrix.max(axis=-1) - H_matrix.min(axis=-1)) == 0
Y = np.argmax(H, axis=0).max()
X = np.argmax(H, axis=1).max()
H = int(H_matrix[Y, X, 0])
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
H_matrix = np.empty([101, 101, N])
for i in range(N):
    [x, y, h] = [int(i) for i in input().split()]
    H_matrix[:, :, i] = h + np.abs(cx - x).reshape(1, -1) + np.abs(cy - y).reshape(-1, 1)
H_matrix[H_matrix<0] = 0
H = (H_matrix.max(axis=-1) - H_matrix.min(axis=-1)) == 0
Y = np.argmax(H, axis=0).max()
X = np.argmax(H, axis=1).max()
H = int(H_matrix[X, Y, 0])
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            #Cx, Cy, h = tuple(Xs[0])
            #H = h + abs(x - Cx) + abs(y - Cy)
            for Cx, Cy, h in Xs:
                H = h + abs(x - Cx) + abs(y - Cy)
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    break
            else:
                return (x, y, H)


print("%d %d %d" % solv(Xs))

Submission status: Wrong Answer

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
H_matrix = np.empty([101, 101, N])
for i in range(N):
    [x, y, h] = [int(i) for i in input().split()]
    H_matrix[:, :, i] = h + np.abs(cx - x).reshape(1, -1) + np.abs(cy - y).reshape(-1, 1)
H_matrix[H_matrix<0] = 0
H = (H_matrix.max(axis=-1) - H_matrix.min(axis=-1)) == 0
X = np.argmax(H, axis=0).max()
Y = np.argmax(H, axis=1).max()
H = int(H_matrix[X, Y, 0])
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
H_matrix = np.empty([101, 101, N])
for i in range(N):
    [x, y, h] = [int(i) for i in input().split()]
    H_matrix[:, :, i] = h + np.abs(cx - x).reshape(1, -1) + np.abs(cy - y).reshape(-1, 1)
H_matrix[H_matrix<0] = 0
H = (H_matrix.max(axis=-1) - H_matrix.min(axis=-1)) == 0
X = np.argmax(H, axis=0).max()
Y = np.argmax(H, axis=1).max()
H = int(H_matrix[0, 100, 0])
print(X, Y, H)

Submission status: Wrong Answer

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


for cx in range(101): 
    for cy in range(101):
        H = -1
        for i in range(N):
            tmp = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
            if H == -1:
                H = tmp
            elif H != tmp:
                H = -2
            if H == -2:
                break
        if H == -2:
            continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i]-cx)+abs(y[i]-cy)
                if H > dist:
                    H = -2
                    break
        if H == -2:
            continue
        print(cx,cy,H)
        break
    break

Submission status: Wrong Answer

Solution code:
"""
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]

Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            Cx, Cy, h = tuple(Xs[0])
            H = h + abs(x - Cx) + abs(y - Cy)
            for Cx, Cy, h in Xs:
                if max(H - abs(x - Cx) - abs(y - Cy), 0) != h:
                    break
            else:
                return (x, y, H)


print("%d %d %d" % solv(Xs))

Submission status: Wrong Answer

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

H=-1

for cx in range(101):
    for cy in range(101):
        for i in range(N):
            tmp = h[i]+abs(x[i]-cx)+abs(y[i]-cy)
            if H == -1:
                H = tmp
            elif H != tmp:
                H = -2
            if H == -2:
                break
        if H == -2:
            continue
        for i in range(N):
            if h[i] == 0:
                dist = abs(x[i]-cx)+abs(y[i]-cy)
                if H > dist:
                    H = -2
                    break
        if H == -2:
            continue
        print(cx,cy,H)
        break
    break

Submission status: Wrong Answer

Solution code:
import numpy as np

cx = np.arange(101)    
cy = np.arange(101)    

N = int(input())
H = np.empty([101, 101, N])
for i in range(N):
    [x, y, h] = [int(i) for i in input().split()]
    H[:, :, i] = h + np.abs(cx - x).reshape(1, -1) + np.abs(cy - y).reshape(-1, 1)
H[H<0] = 0
H = (H.max(axis=-1) - H.min(axis=-1)) == 0
X = np.argmax(H, axis=0).max()
Y = np.argmax(H, axis=1).max()
H = h + np.abs(X - x) + np.abs(Y - y)
print(X, Y, H)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 21:05:02 2018

@author: ogura

"""

N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2])
a, b, c = l[0]

maxnum = 101
is_valid = False
f = 0

maxnum = 101
is_valid = False
for cx in range(maxnum):
    for cy in range(maxnum):
        h = c + abs(a - cx) + abs(b - cy)
        if all(k == max(h - abs(i -cx) - abs(j -cy), 0)for i,j,k in l): f = 1
        if f: break
    if f: break
print(cx,cy,h)

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            h= Xs[0][2]
            Cx = Xs[0][0]
            Cy = Xs[0][1]
            H = h + abs(x - Cx) + abs(y - Cy)
            if H > 0:
                for i in range(len(Xs)):
                    if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                        break
                    if i == len(Xs)-1:
                        print("%d %d %d" % (x, y, H))
                        exit(0)


solv(Xs)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Oct  6 21:05:02 2018

@author: ogura

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

"""

N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
a, b, c = l[0]

maxnum = 101
is_valid = False
f = 0

maxnum = 101
is_valid = False
for cx in range(maxnum):
    for cy in range(maxnum):
        h = c + abs(a - cx) + abs(b - cy)
        if all(k == max(h - abs(i -cx) - abs(j -cy), 0)for i,j,k in l): f = 1
        if f: break
    if f: break
print(cx,cy,h)

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""

Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            h= Xs[0][2]
            Cx = Xs[0][0]
            Cy = Xs[0][1]
            H = h + abs(x - Cx) + abs(y - Cy)
            if H > 0:
                for i in range(1, len(Xs)):
                    if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                        break
                    if i == len(Xs)-1:
                        print("%d %d %d" % (x, y, H))
                        exit(0)


solv(Xs)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    ex,ey,eh = map(int,input().split())
    if eh != 0:
        l.append([ex,ey,eh])

def func2(cx,cy,l):
    ans = l[2] + abs(l[0]-cx) +  abs(l[1]-cy)
    return ans

for i in range(101):
    for j in range(101):
        for k in range(len(l)-1):
            if func2(i,j,l[k]) == func2(i,j,l[k+1]):
                if k == len(l)-2:
                    print(i, j, func2(i,j,l[k]))
                    exit()
            else:
                break

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""
Xs.sort(key=lambda x:x[2], reverse=True)


def solv(Xs):
    for x in range(101):
        for y in range(101):
            h= Xs[0][2]
            Cx = Xs[0][0]
            Cy = Xs[0][1]
            H = h + abs(x - Cx) + abs(y - Cy)
            for i in range(len(Xs)):
                if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                    break
                if i == len(Xs)-1:
                    if H > 0:
                        print("%d %d %d" % (x, y, H))
                        exit(0)


solv(Xs)

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""
Xs.sort(key=lambda x:x[2], reverse=True)

for x in range(101):
    for y in range(101):
        h= Xs[0][2]
        Cx = Xs[0][0]
        Cy = Xs[0][1]
        H = h + abs(x - Cx) + abs(y - Cy)
        for i in range(len(Xs)):
            if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                break
            if i == len(Xs)-1 and H > 0:
                print("%d %d %d" % (x, y, H))

Submission status: Wrong Answer

Solution code:
GI = lambda: int(input()); GIS = lambda: map(int, input().split()); LGIS = lambda: list(GIS())

def main():
    sols = [LGIS() for _ in range(GI())]

    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                if h == 0:
                    continue
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                return

main()

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = [list(map(int, input().split(" "))) for _ in range(N)]
"""
input = ["2 3 5","2 1 5","1 2 5","3 2 5"]
input = ["0 0 100", "1 1 98"]
input = ["99 1 191", "100 1 192", "99 0 192"]
Xs = [list(map(int, x.split(" "))) for x in input]
"""
Xs.sort(key=lambda x:x[2], reverse=True)

for x in range(101):
    for y in range(101):
        h= Xs[0][2]
        Cx = Xs[0][0]
        Cy = Xs[0][1]
        H = h + abs(x - Cx) + abs(y - Cy)
        for i in range(len(Xs)):
            if H - abs(x - Xs[i][0]) - abs(y - Xs[i][1]) != Xs[i][2]:
                break
            if i == len(Xs)-1:
                print("%d %d %d" % (x, y, H))

Submission status: Wrong Answer

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

flg = False
cx, cy, ch = ss[0]
if len(ss) == 1:
    print(cx, cy, ch)
else:
    for a in range(101):
        for b in range(101):
            H = ch + abs(cx-a) + abs(cy - b)
            for x, y, h in ss[1:]:
                if h != max(H - abs(x-a) - abs(y - b), 0):
                    break
            else:
                print(a, b, H)
                flg = True
            if flg:
                break
        if flg:
            break

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):
    needH = -1
    for i in range(n):
        x,y,h = card[i]

        if h>0:
            H = abs(x-cx)+abs(y-cy)+h
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    return False
    
    for i in range(n):
        x,y,h = card[i]

        if h==0:
            dist = abs(x-cx)+abs(y-cy)
            if H > dist:
                return False
    else:
        return True

    
for i in range(101):
    for j in range(101):
        if check(i,j):

            x1,y1,h1 = card[0]
            ah = abs(x1-i)+abs(y1-j)+h1

            print("{} {} {}".format(i,j,ah))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

N = int(input())
xN, yN, hN = [0] * N, [0] * N, [0] * N
for i in range(N):
    xN[i], yN[i], hN[i] = map(int, input().split())

# 頂上としてありうる座標101*101を全検索
for y in range(101):
    for x in range(101):
        # 仮の頂上の高さを保持する
        tmpH = 0
        # 実施回数と一致回数の比較用
        cnt1, cnt2 = 0, 0
        # 任意の座標について、N個の情報との矛盾がないかを確認していく
        for i in range(N):
            # 高さ0の座標は比較対象として相応しくないので無視
            if hN[i] == 0:
                continue
            cnt1 += 1
            # 頂上座標を仮固定しているので、仮の頂上の高さが定まる
            h = hN[i] + abs(x - xN[i]) + abs(y - yN[i])
            # 初回は値を保持
            if tmpH == 0:
                tmpH = h
                cnt2 += 1
            # 2回目以降は保持した初回の値と今回を比較
            else:
                # 一致しなければ矛盾しているので、その座標は終了
                if tmpH != h:
                    break
                else:
                    cnt2 += 1
        # 実施回数と一致回数が一致していれば正しい情報として出力
        if cnt1 == cnt2:
            print(str(x) + ' ' + str(y) + ' ' + str(tmpH))
            exit()

Submission status: Wrong Answer

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

cx, cy, ch = ss[0]
if len(ss) == 1:
    print(cx, cy, ch)
else:
    for a in range(101):
        for b in range(101):
            H = ch + abs(cx-a) + abs(cy - b)
            for x, y, h in ss[1:]:
                if h != max(H - abs(x-a) - abs(y - b), 0):
                    break
            else:
                print(a, b, H)

Submission status: Wrong Answer

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

cx, cy, ch = ss[0]
if len(ss) == 1:
    print(cx, cy, ch)
else:
    for a in range(101):
        for b in range(101):
            H = max(ch + abs(cx-a) + abs(cy - b), 0)
            for x, y, h in ss[1:]:
                if h != max(H - abs(x-a) - abs(y - b), 0):
                    break
            else:
                print(a, b, H)

Submission status: Wrong Answer

Solution code:
border = 101

def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)

def judge_center(Cx, Cy, cords):
    H = max(abs(cords[0][0] - Cx) + abs(cords[0][1] - Cy) + cords[0][2], 1)
    for x, y, h in cords:
        if h != manhattan_distance(Cx, Cy, H, x, y):
            return -1
    return H

def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            H = judge_center(tmp_Cx, tmp_Cy, cords)
            if H != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, H))
                return 0


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for a in range(101):
    for b in range(101):
        x, y, h = ss[0]
        H = max(h + abs(x-a) + abs(y - b), 0)
        for x, y, h in ss[1:]:
            if h != max(H - abs(x-a) - abs(y - b), 0):
                break
        else:
            print(a, b, H)

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
res=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
l2.sort(key=lambda x:x[2])
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if k<l:
                break
            else:
                n-=1
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
            else: break
        if n==0:
            m=(i[0],i[1],l)
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
res=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    res.append([[0],i[1],l])
                    if len(res)>1:
                        m=res[1]
                    else: m=res[0]
            else: break
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    m=(i[0],i[1],l)
            else: break
print('{} {} {}'.format(m[0],m[1],m[2]))

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    m=(i[0],i[1],l)
            else: break
print(m)

Submission status: Wrong Answer

Solution code:
N=int(input())
lis=[]
for i in range(101):
    for j in range(101):
        lis.append([i,j])
l2=[]
for i in range(N):
    l2.append(list(map(int, input().split())))
for i in lis:
    n=N
    l=0
    for j in l2:
        if j[2]==0:
            n-=1
            if n==0:
                m=(i[0],i[1],l)
        else:
            k=abs(i[0]-j[0])+abs(i[1]-j[1])+j[2]
            if l==k or l==0:
                l=k
                n-=1
                if n==0:
                    m=(i[0],i[1],l)
            else: break
    try:
        print('{} {} {}'.format(m[0],m[1],m[2]))
        break
    except NameError:
        continue

Submission status: Wrong Answer

Solution code:
border = 101

def manhattan_distance(Cx, Cy, H, X, Y):
    return max(H - abs(X - Cx) - abs(Y - Cy), 0)

def judge_center(Cx, Cy, cords):
    H = abs(cords[0][0] - Cx) + abs(cords[0][1] - Cy) + cords[0][2]
    for x, y, h in cords:
        if h != manhattan_distance(Cx, Cy, H, x, y):
            return -1
    return H

def main():
    N = int(input())
    cords = [list(map(int, input().split(' '))) for _ in range(N)]

    for tmp_Cx in range(border):
        for tmp_Cy in range(border):
            h = judge_center(tmp_Cx, tmp_Cy, cords)
            if h != -1:
                print('{} {} {}'.format(tmp_Cx, tmp_Cy, h))
                return 0


if __name__ == '__main__':
    main()