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())
xyh=[[int(i) for i in input().split()] for j in range(n)]

for i in range(101):
    for j in range(101):
        check=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        aa =0
        for k in range(n):
            if check == abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]:
                aa+=1
            else:
                break
            if aa==n:
                
                ansx=i
                ansy=j
                ansh=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
                print(ansx,ansy,ansh)
                exit()

Submission status: Wrong Answer

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

ansx=0
ansy=0
ansh=0
for i in range(101):
    for j in range(101):
        check=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
        aa =0
        for k in range(n):
            if check == abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2]:
                aa+=1
            else:
                break
            if aa==n:
                ansx=i
                ansy=j
                ansh=abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2]
                print(ansx,ansy,ansh)

Submission status: Wrong Answer

Solution code:
N = int(input())
lst = []
for i in range(N):
    x, y, h = map(int, input().split())
    lst.append([x, y, h])
for i in range(101):
    for j in range(101):
        ans = set()
        for k in lst:
            H = k[2] + abs(i-k[0]) + abs(j-k[1])
            if H != 0:
                ans.add(H)
        if len(ans) == 1:
            print(i, j, H)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyhs = []
for i in range(N):
  x, y, h = map(int, input().split())
  xyhs.append((x, y, h))
for cx in range(0, 101):
  for cy in range(0, 101):
    Hs = set()
    for x, y, h in xyhs:
      d = abs(x-cx)+abs(y-cy)
      if h > 0:
        Hs.add(h+d)
      elif h == 0 and d == 1:
        Hs.add(1)
    if len(Hs) == 1:
      H = min(Hs)
      print(cx, cy, H)
      exit()
print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
x_y_h = []
for i in range(N):
    x_y_h.append(list(map(int, input().split())))
x_y_h.sort()
a, b, c = x_y_h[-1]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j), 0) for i, j, k in x_y_h):
            print(x, y, h)
            exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
x_y_h = []
for i in range(N):
    x_y_h.append(list(map(int, input().split())))
a, b, c = x_y_h[0]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j), 0) for i, j, k in x_y_h):
            print(x, y, h)
            exit()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xs, ys, hs = list(), list(), list()
    for i in range(n):
        x, y, h = map(int, input().split())
        xs.append(x)
        ys.append(y)
        hs.append(h)

    for cx in range(101):
        for cy in range(101):
            # In this case,
            # multiple candidates of H & 
            Hs = set()
            Hs_ub = set()
            for x, y, h in zip(xs, ys, hs):
                if h == 0:
                    H_cand = abs(x - cx) + abs(y - cy)
                    Hs_ub.add(H_cand)
                else:
                    H_cand = h + abs(x - cx) + abs(y - cy)
                    Hs.add(H_cand)
            # accept No.9, reject 10 - 15
            Hs_rm = set()
            for H in Hs:
                if all([H <= H_ub for H_ub in Hs_ub]):
                    continue
                else:
                    Hs_rm.add(H)
            Hs = Hs - Hs_rm

            Hs = {H for H in Hs if H >= 1}
            if len(Hs) == 1:
                H = Hs.pop()
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xs, ys, hs = list(), list(), list()
    for i in range(n):
        x, y, h = map(int, input().split())
        xs.append(x)
        ys.append(y)
        hs.append(h)

    for cx in range(101):
        for cy in range(101):
            Hs = set()
            Hs_ub = set()
            for x, y, h in zip(xs, ys, hs):
                H_cand = h + abs(x - cx) + abs(y - cy)
                if h == 0:
                    Hs_ub.add(H_cand)
                else:
                    Hs.add(H_cand)
            # accept No.9, reject 10 - 15
            Hs_rm = set()
            for H in Hs:
                if all([H <= H_ub for H_ub in Hs_ub]):
                    continue
                else:
                    Hs_rm.add(H)
            Hs = Hs - Hs_rm

            Hs = {H for H in Hs if H >= 1}
            if len(Hs) != 0:
                H = Hs.pop()
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xs, ys, hs = list(), list(), list()
    for i in range(n):
        x, y, h = map(int, input().split())
        xs.append(x)
        ys.append(y)
        hs.append(h)

    for cx in range(101):
        for cy in range(101):
            Hs = set()
            Hs_ub = set()
            for x, y, h in zip(xs, ys, hs):
                H_cand = h + abs(x - cx) + abs(y - cy)
                if h == 0:
                    Hs_ub.add(H_cand)
                else:
                    Hs.add(H_cand)
            # Hs_rm = set()
            # for H in Hs:
            #     if all([H <= H_ub for H_ub in Hs_ub]):
            #         continue
            #     else:
            #         Hs_rm.add(H)
            # Hs = Hs - Hs_rm
            Hs = {H for H in Hs if H >= 1}
            if len(Hs) == 1:
                H = Hs.pop()
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xs, ys, hs = list(), list(), list()
    for i in range(n):
        x, y, h = map(int, input().split())
        xs.append(x)
        ys.append(y)
        hs.append(h)

    for cx in range(101):
        for cy in range(101):
            Hs = set()
            Hs_ub = set()
            for x, y, h in zip(xs, ys, hs):
                H_cand = h + abs(x - cx) + abs(y - cy)
                if h == 0:
                    Hs_ub.add(H_cand)
                else:
                    Hs.add(H_cand)
            Hs_rm = set()
            for H in Hs:
                if all([H <= H_ub for H_ub in Hs_ub]):
                    continue
                else:
                    Hs_rm.add(H)
            Hs = Hs - Hs_rm
            Hs = {H for H in Hs if H >= 1}
            if len(Hs) == 1:
                H = Hs.pop()
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xs, ys, hs = list(), list(), list()
    for i in range(n):
        x, y, h = map(int, input().split())
        xs.append(x)
        ys.append(y)
        hs.append(h)

    for cx in range(101):
        for cy in range(101):
            Hs = set()
            Hs_ub = set()
            for x, y, h in zip(xs, ys, hs):
                H_cand = h + abs(x - cx) + abs(y - cy)
                if h == 0:
                    Hs_ub.add(H_cand)
                else:
                    Hs.add(H_cand)
            Hs_rm = set()
            for H in Hs:
                if all({H <= H_ub for H_ub in Hs_ub}):
                    continue
                else:
                    Hs_rm.add(H)
            Hs = Hs - Hs_rm
            if len(Hs) == 1:
                H = Hs.pop()
                if H >= 1:
                    print(cx, cy, H)
                    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xs, ys, hs = list(), list(), list()
    for i in range(n):
        x, y, h = map(int, input().split())
        xs.append(x)
        ys.append(y)
        hs.append(h)

    for cx in range(101):
        for cy in range(101):
            Hs = set()
            Hs_ub = set()
            for x, y, h in zip(xs, ys, hs):
                H_cand = h + abs(x - cx) + abs(y - cy)
                if h == 0:
                    Hs_ub.add(H_cand)
                else:
                    Hs.add(H_cand)
            Hs_rm = set()
            for H in Hs:
                if all({H <= H_ub for H_ub in Hs_ub}):
                    continue
                else:
                    Hs_rm.add(H)
            Hs = Hs - Hs_rm
            if len(Hs) == 1:
                H = Hs.pop()
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    xs, ys, hs = list(), list(), list()
    for i in range(n):
        x, y, h = map(int, input().split())
        xs.append(x)
        ys.append(y)
        hs.append(h)

    for cx in range(101):
        for cy in range(101):
            Hs = set()
            for x, y, h in zip(xs, ys, hs):
                if h == 0:
                    continue
                H_cand = h + abs(x - cx) + abs(y - cy)
                Hs.add(H_cand)
            if len(Hs) == 1:
                H = Hs.pop()
                print(cx, cy, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
Data = []
for _ in range(N):
    x,y,h = map(int,input().split())
    Data.append([x,y,h])

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

for cx in range(101):
    for cy in range(101):
        found = True
        ans   = -1
        for i in range(N):
            x,y,h = Data[i]
            if i == 0:
                ans = h + abs(x-cx)+abs(y-cy)
            else:
                ph = h + abs(x-cx)+abs(y-cy)
                if ans != ph:
                    found = False
                    break
        if found == True:
            print( '{} {} {}'.format(cx,cy,ans))
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
Data = []
for _ in range(N):
    x,y,h = map(int,input().split())
    if h != 0:
        Data.append([x,y,h])

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

for cx in range(101):
    for cy in range(101):
        found = True
        ans   = -1
        for i in range(len(Data)):
            x,y,h = Data[i]
            if i == 0:
                ans = h + abs(x-cx)+abs(y-cy)
            else:
                ph = h + abs(x-cx)+abs(y-cy)
                if ans != ph:
                    found = False
                    break
        if found == True:
            print( '{} {} {}'.format(cx,cy,ans))
            sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
X, Y, H = [0]*n,[0]*n,[0]*n
for i in range(n):
  X[i],Y[i],H[i] = map(int, input().split())
  
for i in range(0,101):
  for j in range(0,101):
    ansl = []
    for k in range(n):
      if H[k] == 0:
        continue
      ans = H[k] + abs(X[k]-i) + abs(Y[k]-j)
      ansl.append(ans)
    if len(set(ansl)) == 1:
      an = [i, j, ans]
      print(*an)
      exit()
an = [0, 0, 100]
print(*an)

Submission status: Wrong Answer

Solution code:
n = int(input())
X, Y, H = [0]*n,[0]*n,[0]*n
for i in range(n):
  X[i],Y[i],H[i] = map(int, input().split())
  
for i in range(0,101):
  for j in range(0,101):
    ansl = []
    for k in range(n):
      if H[k] == 0:
        continue
      ans = H[k] + abs(X[k]-i) + abs(Y[k]-j)
      ansl.append(ans)
    if len(set(ansl)) == 1:
      an = [i, j, ans]
      print(*an)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
X, Y, H = [0]*n,[0]*n,[0]*n
for i in range(n):
  X[i],Y[i],H[i] = map(int, input().split())
  
for i in range(0,101):
  for j in range(0,101):
    ansl = []
    for k in range(n):
      if H[k] == 0:
        continue
      ans = max(H[k] + abs(X[k]-i) + abs(Y[k]-j), abs(X[k]-i) + abs(Y[k]-j))
      ansl.append(ans)
    if len(set(ansl)) == 1:
      an = [i, j, ans]
      print(*an)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
X, Y, H = [0]*n,[0]*n,[0]*n
for i in range(n):
  X[i],Y[i],H[i] = map(int, input().split())
  
for i in range(0,101):
  for j in range(0,101):
    ansl = []
    for k in range(n):
      ans = max(H[k] + abs(X[k]-i) + abs(Y[k]-j), abs(X[k]-i) + abs(Y[k]-j))
      ansl.append(ans)
    else:
      if len(set(ansl)) == 1:
        an = [i, j, ans]
        print(*an)
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
X, Y, H = [0]*n,[0]*n,[0]*n
for i in range(n):
  X[i],Y[i],H[i] = map(int, input().split())
  
for i in range(0,101):
  for j in range(0,101):
    ansl = []
    for k in range(n):
      ans = max(H[k] + abs(X[k]-i) + abs(Y[k]-j),0)
      ansl.append(ans)
    else:
      if len(set(ansl)) == 1:
        an = [i, j, ans]
        print(*an)
        exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
X, Y, H = [0]*n,[0]*n,[0]*n
for i in range(n):
  X[i],Y[i],H[i] = map(int, input().split())
  
for i in range(1,101):
  for j in range(1,101):
    ansl = []
    for k in range(n):
      ans = max(H[k] + abs(X[k]-i) + abs(Y[k]-j),0)
      ansl.append(ans)
    else:
      if len(set(ansl)) == 1:
        an = [i, j, ans]
        print(*an)
        exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
xyh=[tuple(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda tup:-tup[2])
for x in range(101):
	for y in range(101):
		esth=abs(x-xyh[0][0])+abs(y-xyh[0][1])+xyh[0][2]
		for i in range(1,n):
			if esth!=abs(x-xyh[i][0])+abs(y-xyh[i][1])+xyh[i][2]:
				break
		else:
			print(x,y,esth)
			exit()
		continue

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0:
        if k == n-1 and ans_h != 0: 
          ans_x = i
          ans_y = j
          flag=1
          break
        else:
          continue
      if ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if ans_h != 0 and k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0:
        if k == n-1:
          ans_x = i
          ans_y = j
          flag=1
          break
        else:
          continue
      if ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if ans_h != 0 and k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0 and ans_h-abs(i-x[k])-abs(j-y[k]) < 0:
        if k == n-1:
          ans_x = i
          ans_y = j
          flag=1
          break
        else:
          continue
      if ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if ans_h != 0 and k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0 and ans_h-abs(i-x[k])-abs(j-y[k]) < 0:
        if k == n-1:
          ans_x = i
          ans_y = j
          flag=1
          break
        else:
          continue
      if ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0 and k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
      elif h[k] == 0:
        continue
      if ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(range(n))
y = list(range(n))
h = list(range(n))

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

flag=0
i = 0
while(flag==0 and i < 101):
  j = 0
  while(flag==0 and j < 101):
    ans_h = 0
    for k in range(n):
      if h[k] == 0 and k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
      elif h[k] == 0:
        continue
      elif ans_h == 0:
        ans_h = abs(i-x[k])+abs(j-y[k])+h[k]
      elif abs(i-x[k])+abs(j-y[k])+h[k] != ans_h:
        break
      if k == n-1:
        ans_x = i
        ans_y = j
        flag=1
        break
    j+=1
  i+=1

print(ans_x, ans_y, ans_h)

Submission status: Wrong Answer

Solution code:
import sys

def height(a, b, c, d, e):
    return abs(a-d)+abs(b-e)+c

n = int(input())
hint = []
q = 0
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([c, a, b])
hint.sort(reverse=True)

for i in range(101):
    for j in range(101):
        frag = True
        H = height(hint[0][1], hint[0][2], hint[0][0], i, j)
        for h in hint[1:]:
            if height(h[1], h[2], h[0], i, j) != H:
                frag = False
                break
        if frag:
            print(i, j, H)
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
hint = []
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([a, b, c])
frag2 = False
for i in range(101):
    for j in range(101):
        ans_h = -1
        frag = False
        for k in range(n):
            a, b, c = hint[k][0], hint[k][1], hint[k][2]
            if c != 0:
                if ans_h == -1:
                    ans_h = abs(a-i)+abs(b-j)+c
                else:
                    if ans_h != abs(a-i)+abs(b-j)+c:
                        frag = True
                        break
                    else:
                        continue
        if not frag:
            answer = [i, j, ans_h]
            for i in range(3):
                print(answer[i], end=" ")
            sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
hint = []
for i in range(n):
    a, b, c = map(int, input().split())
    hint.append([a, b, c])
frag2 = False
for i in range(101):
    for j in range(101):
        ans_h = -1
        frag = False
        for k in range(n):
            a, b, c = hint[k][0], hint[k][1], hint[k][2]
            if c != 0:
                if ans_h == -1:
                    ans_h = abs(a-i)+abs(b-j)+c
                else:
                    if ans_h != abs(a-i)+abs(b-j)+c:
                        frag = True
                        break
                    else:
                        continue
        if not frag:
            answer = [i, j, ans_h]
            frag2 = True
            break
    if frag2:
        break

for i in range(3):
    print(answer[i], end=" ")

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

datatmp = []
datatmp = copy.deepcopy(data[0])

for i in range(n-1, -1, -1):
    if data[i][2] == 0:
        data.pop(i)

if len(data) == 0 :
    data.append(datatmp[0])

ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True

        for k in range(len(data)):
            if k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                    flg = False
                    break

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(x-i) + abs(y-j)

for i in range(n-1, -1, -1):
    if data[i][2] == 0:
        data.pop(i)

ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True

        for k in range(len(data)):
            if k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                    flg = False
                    break

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

for i in range(n-1, -1, -1):
    if data[i][2] == 0:
        data.pop(i)

ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True

        for k in range(len(data)):
            if k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]):
                    flg = False
                    break

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True

        for k in range(n):
            if k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            elif data[k][2] == 0:
                continue
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]) or data[k][2] < 1:
                    flg = False
                    break

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return h + abs(i-x) + abs(j-y)

ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True

        for k in range(n):
            if k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]) or data[k][2] < 1:
                    flg = False
                    break

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)

Submission status: Wrong Answer

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, = map(int, input().split())
data = getSomeInputListInt(n)

rng = 101

def clc(i, j, h, x, y):
    return max(0, h + abs(i-x) + abs(j-y))

ansi = 0
ansj = 0
flgI = False

for i in range(rng):
    for j in range(rng):
        flg = True
        tmp = 0
        for k in range(n):
            if k == 0:
                tmp = clc(i, j, data[k][2], data[k][0], data[k][1])
            else:
                if tmp != clc(i, j, data[k][2], data[k][0], data[k][1]) :
                    flg = False
                    break

        if flg:
            ansi = i
            ansj = j
            flgI = True
            break

    if flgI:
        break

print(ansi, ansj, tmp)