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:
def main():
	n = int(input())

	info = []
	for i in range(n):
		l = list(map(int, input().split()))
		info.append(l)

	for k in range(info[0][2], info[0][2] + 201):
		candidate = []

		# 最初の情報をもとに候補を決める
		deltah = k - info[0][2]
		x = info[0][0]
		y = info[0][1]
		if deltah == 0:
			candidate = [[x, y]]
		else:
			for j in range(deltah):
				candidate.append([x-j, y+deltah-j])
			for j in range(deltah):
				candidate.append([x-deltah+j, y-j])
			for j in range(deltah):
				candidate.append([x+j, y-deltah+j])
			for j in range(deltah):
				candidate.append([x+deltah-j, y+j])
		#print(candidate)

		# かぶっているものだけを採用していく
		for i in range(1, len(info)):
			x = info[i][0]
			y = info[i][1]
			h = info[i][2]
			candidate_tmp = []
			deltah = k - h
			if deltah == 0:
				candidate_tmp = [[x,y]]
			else:
				for j in range(deltah):
					candidate_tmp.append([x-j, y+deltah-j])
				for j in range(deltah):
					candidate_tmp.append([x-deltah+j, y-j])
				for j in range(deltah):
					candidate_tmp.append([x+j, y-deltah+j])
				for j in range(deltah):
					candidate_tmp.append([x+deltah-j, y+j])

			new_candidate = []
			for c in candidate_tmp:
				if c in candidate:
					new_candidate.append(c)
			candidate = new_candidate

		if len(candidate) == 1:
			print(candidate[0][0], candidate[0][1], k)
			return

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

arr = [[-1] * 101 for i in range(101)]
for xi in range(101):
  for yi in range(101):
    if ina[0][2] != 0:
      arr[xi][yi] = ina[0][2]+abs(ina[0][0]-xi)+abs(ina[0][1]-yi)

arrTF = [[True] * 101 for i in range(101)]
for i in range(1,inn):
  for xi in range(101):
    for yi in range(101):
      if arr[xi][yi] == -1 and ina[i][2] != 0:
        arr[xi][yi] = ina[i][2]+abs(ina[i][0]-xi)+abs(ina[i][1]-yi)
      elif arr[xi][yi] != ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
        arrTF[xi][yi] = False

for xi in range(101):
  for yi in range(101):
    if arrTF[xi][yi]:
      print(str(xi)+" "+str(yi)+" "+str(arr[xi][yi]))

Submission status: Wrong Answer

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

arr = [[-1] * 101 for i in range(101)]
for xi in range(101):
  for yi in range(101):
    if ina[0][2] != 0:
      arr[xi][yi] = ina[0][2]+abs(ina[0][0]-xi)+abs(ina[0][1]-yi)

arrTF = [[True] * 101 for i in range(101)]
for i in range(1,inn):
  for xi in range(101):
    for yi in range(101):
      if arr[xi][yi] == -1:
        arr[xi][yi] = ina[i][2]+abs(ina[i][0]-xi)+abs(ina[i][1]-yi)
      elif arr[xi][yi] != ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
        arrTF[xi][yi] = False

for xi in range(101):
  for yi in range(101):
    if arrTF[xi][yi]:
      print(str(xi)+" "+str(yi)+" "+str(arr[xi][yi]))

Submission status: Wrong Answer

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

arr = [[0] * 101 for i in range(101)]
for xi in range(101):
  for yi in range(101):
    arr[xi][yi] = max(ina[0][2]+abs(ina[0][0]-xi)+abs(ina[0][1]-yi),0)

arrTF = [[True] * 101 for i in range(101)]
for i in range(1,inn):
  for xi in range(101):
    for yi in range(101):
      if arr[xi][yi] != max(ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi),0):
        arrTF[xi][yi] = False

for xi in range(101):
  for yi in range(101):
    if arrTF[xi][yi]:
      print(str(xi)+" "+str(yi)+" "+str(arr[xi][yi]))

Submission status: Wrong Answer

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

arr = [[0] * 101 for i in range(101)]
for xi in range(101):
  for yi in range(101):
    arr[xi][yi] = ina[0][2]+abs(ina[0][0]-xi)+abs(ina[0][1]-yi)

arrTF = [[True] * 101 for i in range(101)]
for i in range(1,inn):
  for xi in range(101):
    for yi in range(101):
      if arr[xi][yi] != ina[i][2] + abs(ina[i][0]-xi)+abs(ina[i][1]-yi):
        arrTF[xi][yi] = False

for xi in range(101):
  for yi in range(101):
    if arrTF[xi][yi]:
      print(str(xi)+" "+str(yi)+" "+str(arr[xi][yi]))

Submission status: Wrong Answer

Solution code:
import numpy as np
def solve(n, x, y, h):
    for cx in range(101):
        for cy in range(101):
            ok = False
            for i in range(n):
                if h[i] > 0:
                    H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                    ok = True
                    break
            if ok:
                for i in range(n):
                    h_i = max(h[i] + abs(x[i] - cx) + abs(y[i] - cy), 0)
                    if h_i != H:
                        ok = False
                        break
            if ok:
                return "%d %d %d" % (cx, cy, H)

n = input()
x, y, h = np.zeros(n,int), np.zeros(n,int), np.zeros(n,int)
for i in range(n):
    x[i], y[i], h[i] = map(int, raw_input().split())
print solve(n, x, y, h)

Submission status: Wrong Answer

Solution code:
import numpy as np
def solve(n, x, y, h):
    for cx in range(0, 101):
        for cy in range(0, 101):
            S = set()
            for i in range(n):
                if h[i] > 0:
                    H = h[i] + abs(x[i] - cx) + abs(y[i] - cy)
                    S.add(H)
            if (len(S) == 1) and (H > 0):
                return "%d %d %d" % (cx, cy, H)

n = input()
x, y, h = np.zeros(n,int), np.zeros(n,int), np.zeros(n,int)
for i in range(n):
    x[i], y[i], h[i] = map(int, raw_input().split())
print solve(n, x, y, h)

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 101
num = 0
num2 = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(n):
            for Y in range(n):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + (h[i] - h[j]) != 0:
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                        num2 += 1
                elif (ground[X][Y] != -1 and h[i] == 0 and h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + h[i] - h[j] >= 0:
                        ground[X][Y] = -1
                        num += 1
                elif (ground[X][Y] != -1 and h[i] != 0 and h[j] == 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + h[i] - h[j] <= 0:
                        ground[X][Y] = -1
                        num += 1
                if num == n * n - 1 and num2 > 0:
                    break
            if num == n * n - 1 and num2 > 0:
                break
        if num == n * n - 1 and num2 > 0:
            break
    if num == n * n - 1 and num2 > 0:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 101
num = 0
num2 = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(n):
            for Y in range(n):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + (h[i] - h[j]) != 0:
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                        num2 += 1
                elif (ground[X][Y] != -1 and h[i] == 0 and h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + h[i] - h[j] > 0:
                        ground[X][Y] = -1
                        num += 1
                elif (ground[X][Y] != -1 and h[i] != 0 and h[j] == 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + h[i] - h[j] < 0:
                        ground[X][Y] = -1
                        num += 1
                if num == n * n - 1 and num2 > 0:
                    break
            if num == n * n - 1 and num2 > 0:
                break
        if num == n * n - 1 and num2 > 0:
            break
    if num == n * n - 1 and num2 > 0:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 101
num = 0
num2 = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(n):
            for Y in range(n):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + (h[i] - h[j]) != 0:
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                        num2 += 1
                elif (ground[X][Y] != -1 and h[i] * h[j] == 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                if num == n * n - 1 and num2 > 0:
                    break
            if num == n * n - 1 and num2 > 0:
                break
        if num == n * n - 1 and num2 > 0:
            break
    if num == n * n - 1 and num2 > 0:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 101
num = 0
num2 = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(n):
            for Y in range(n):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + (h[i] - h[j]) != 0:
                        ground[X][Y] = -1
                        num += 1
                        num2 += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                        num2 += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                        num2 += 1
                elif (ground[X][Y] != -1 and h[i] * h[j] == 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                        num2 += 1
                if num == n * n - 1 and num2 > n * n:
                    break
            if num == n * n - 1 and num2 > n * n:
                break
        if num == n * n - 1 and num2 > n * n:
            break
    if num == n * n - 1 and num2 > n * n:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 101
num = 0
num2 = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(n):
            for Y in range(n):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + (h[i] - h[j]) != 0:
                        ground[X][Y] = -1
                        num += 1
                        num2 += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                        num2 += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                        num2 += 1
                elif (ground[X][Y] != -1 and h[i] * h[j] == 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                        num2 += 1
                if num == n * n - 1 and num2 == n * n:
                    break
            if num == n * n - 1 and num2 == n * n:
                break
        if num == n * n - 1 and num2 == n * n:
            break
    if num == n * n - 1 and num2 == n * n:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y]) + (h[i] - h[j]) != 0:
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                elif (ground[X][Y] != -1 and h[i] * h[j] == 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                if num == n * n - 1:
                    break
            if num == n * n - 1:
                break
        if num == n * n - 1:
            break
    if num == n * n - 1:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                else:
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                if num == n * n - 1:
                    break
            if num == n * n - 1:
                break
        if num == n * n - 1:
            break
    if num == n * n - 1:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                else:
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                if num == n-1:
                    break
            if num == n-1:
                break
        if num == n-1:
            break
    if num == n-1:
        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    elif ((ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])) or h[i] + distance([x[i], y[i]], [X, Y]) > n):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                else:
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                if num == n-1:
                    break
                    break
                    break
                    break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    elif ((ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])) or h[i] + distance([x[i], y[i]], [X, Y]) > n):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                    if num == 99:
                        break
                        break
                        break
                        break
                else:
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    if num == 99:
                        break
                        break
                        break
                        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    elif ((ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])) or h[i] + distance([x[i], y[i]], [X, Y]) > n):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                    if num == 99:
                        break
                else:
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    if num == 99:
                        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                    if num == 99:
                        break
                else:
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) < abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    if num == 99:
                        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
num = 0
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                        num += 1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                        num += 1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
                    if num == 99:
                        break
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

def distance(P, Q):
    return abs(P[0] - Q[0]) + abs(P[1] - Q[1])

N = int(input())
h = []
x = []
y = []
n = 100
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    x.append(tmp[0])
    y.append(tmp[1])
    h.append(tmp[2])
for i in range(N - 1):
    for j in range(i + 1, N):
        for X in range(100):
            for Y in range(100):
                if (ground[X][Y] != -1 and h[i] * h[j] != 0):
                    if abs(distance([x[i], y[i]], [X, Y]) - distance([x[j], y[j]], [X, Y])) != abs(h[i] - h[j]):
                        ground[X][Y] = -1
                    elif (ground[X][Y] > 0 and ground[X][Y] != h[i] + distance([x[i], y[i]], [X, Y])):
                        ground[X][Y] = -1
                    else:
                        ground[X][Y] = h[i] + distance([x[i], y[i]], [X, Y])
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
h = []
x = []
y = []
n = 100
ground = np.zeros((n, n), dtype = int)
for i in range(N):
    tmp = [0, 0, 0]
    tmp[0], tmp[1], tmp[2] = map(int, input().split())
    h.append(tmp[0])
    x.append(tmp[1])
    y.append(tmp[2])
for i in range(len(h) - 1):
    for j in range(i + 1, len(h)):
        if abs(h[i] - h[j]) == abs(x[i] - x[j]) + abs(y[i] - y[j]):
            for X in range(n):
                for Y in range(n):
                    if ground[X][Y] != -1:
                        if h[i] > h[j]:
                            if ((X - x[i]) * (x[j] - x[i]) > 0 or (Y - y[i]) * (y[j] - y[i]) > 0 or h[i] + abs(X - x[i]) + abs(Y - y[i]) > n):
                                ground[X][Y] = -1
                            elif (ground[X][Y] > 0 and ground[X][Y] > h[i] + abs(X - x[i]) + abs(Y + y[i])):
                                ground[X][Y] = -1
                            else:
                                ground[X][Y] = h[i] + abs(X - x[i]) + abs(Y + y[i])
                        elif h[j] > h[i]:
                            if ((X - x[j]) * (x[i] - x[j]) > 0 or (Y - y[j]) * (y[i] - y[j]) > 0 or h[j] + abs(X - x[j]) + abs(Y - y[j]) > n):
                                ground[X][Y] = 1
                            elif (ground[X][Y] > 0 and ground[X][Y] != h[j] + abs(X - x[j]) + abs(Y + y[j])):
                                ground[X][Y] = -1
                            else:
                                ground[X][Y] = h[j] + abs(X - x[j]) + abs(Y + y[j])
ans = [-1, -1]
for i in range(n):
    for j in range(n):
        if ground[i][j] != -1:
            print('{} {} {}'.format(i, j, ground[i][j]))