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:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(string_to_int, inputs))
    points = [p for p in points if p[2] != 0]
    for top_x in range(101):
        for top_y in range(101):
            is_correct = True
            p = points[0]
            prev_h = max(p[2] + abs(p[0] - top_x) + abs(p[1] - top_y), 0)
            for [px, py, ph] in points:
                top_h = max(ph + abs(px - top_x) + abs(py - top_y), 0)
                if top_h != prev_h:
                    is_correct = False
                    break
            if is_correct:
                return "{} {} {}".format(top_x, top_y, prev_h)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(string_to_int, inputs))
    for top_x in range(101):
        for top_y in range(101):
            prev_h = -1
            is_correct = True
            for [px, py, ph] in points:
                if ph == 0:
                    continue
                top_h = ph + abs(px - top_x) + abs(py - top_y)
                if prev_h == -1 or top_h == prev_h:
                    prev_h = top_h
                else:
                    is_correct = False
                    break
            if is_correct:
                return "{} {} {}".format(top_x, top_y, prev_h)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(string_to_int, inputs))
    for top_x in range(101):
        for top_y in range(101):
            prev_h = -1
            is_correct = True
            for [px, py, ph] in points:
                if ph == 0:
                    continue
                top_h = ph + abs(px - top_x) + abs(py - top_y)
                if prev_h == -1 or top_h == prev_h:
                    prev_h = top_h
                else:
                    is_correct = False
                    break
            if is_correct:
                return "{} {} {}".format(top_x, top_y, prev_h)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(string_to_int, inputs))
    if len(points) == 1:
        return "{} {} {}".format(points[0][0], points[0][1], points[0][2])
    for top_x in range(101):
        for top_y in range(101):
            prev_h = -1
            is_correct = True
            for [px, py, ph] in points:
                top_h = ph + abs(px - top_x) + abs(py - top_y)
                if prev_h == -1 or top_h == prev_h:
                    prev_h = top_h
                else:
                    is_correct = False
                    break
            if is_correct:
                return "{} {} {}".format(top_x, top_y, prev_h)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(string_to_int, inputs))
    for top_x in range(0, 101):
        for top_y in range(0, 101):
            candidates = []
            for [px, py, ph] in points:
                top_h = ph + abs(px - top_x) + abs(py - top_y)
                candidates.append(top_h)
            if candidates.count(candidates[0]) == len(candidates):
                return "{} {} {}".format(top_x, top_y, candidates[0])


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    points = list(map(string_to_int, inputs))
    for top_x in range(0, 101):
        for top_y in range(0, 101):
            prev_h = -1
            is_correct = True
            for [px, py, ph] in points:
                top_h = ph + abs(px - top_x) + abs(py - top_y)
                if prev_h == -1 or top_h == prev_h:
                    prev_h = top_h
                else:
                    is_correct = False
                    break
            if is_correct:
                return "{} {} {}".format(top_x, top_y, prev_h)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
H=0
flag=0
XX=0
YY=0
for i in range(N):
    a,b,c=map(int,input().split())
    A.append([a,b,c])
flag2=0
for i in range(N):
    if A[i][2] != 0:
        flag2=1

if flag2==0:
    for i in range(N):
        XX+=A[i][0]
        YY+=A[i][1]
    print(str(XX) + " " + str(YY) + " " + str(1))
    exit(0)

for x in range(101):
    for y in range(101):
        for i in range(N):
            if A[i][2]!=0:
                H=A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
                flag=0
                break
        for n in range(1,N):
            if A[n][2]!=0:
                if H != A[n][2] + abs(A[n][0] - x) + abs(A[n][1] - y):
                    flag=1
        if flag==0:
            print(str(x)+" "+str(y)+" "+str(H))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
H=0
flag=0
for i in range(N):
    a,b,c=map(int,input().split())
    A.append([a,b,c])



for x in range(101):
    for y in range(101):
        for i in range(N):
            if A[i][2]!=0:
                H=A[i][2]+abs(A[i][0]-x)+abs(A[i][1]-y)
                flag=0
                break
        for n in range(1,N):
            if A[n][2]!=0:
                if H != A[n][2] + abs(A[n][0] - x) + abs(A[n][1] - y):
                    flag=1
        if flag==0:
            print(str(x)+" "+str(y)+" "+str(H))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
H=0
flag=0
for i in range(N):
    a,b,c=map(int,input().split())
    A.append([a,b,c])

for x in range(101):
    for y in range(101):
        H=A[0][2]+abs(A[0][0]-x)+abs(A[0][1]-y)
        flag=0
        for n in range(1,N):
            if A[n][2]!=0:
                if H != A[n][2] + abs(A[n][0] - x) + abs(A[n][1] - y):
                    flag=1
        if flag==0:
            print(str(x)+" "+str(y)+" "+str(H))

Submission status: Wrong Answer

Solution code:
l_bound = [[1]*101 for _ in range(101)]
u_bound = [[10**9]*101 for _ in range(101)]

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

    if h==0:
        for r in range(101):
            for c in range(101):
                u_bound[r][c] = min(u_bound[r][c], abs(c-x) + abs(r-y))
    else:
        for r in range(101):
            for c in range(101):
                l_bound[r][c] = max(l_bound[r][c], h + abs(c-x) + abs(r-y))
                u_bound[r][c] = min(u_bound[r][c], h + abs(c-x) + abs(r-y))

for r in range(101):
    for c in range(101):
        if l_bound[r][c] == u_bound[r][c]:
            print(c, r, l_bound[r][c])

Submission status: Wrong Answer

Solution code:
l_bound = [[0]*101 for _ in range(101)]
u_bound = [[10**9]*101 for _ in range(101)]

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

    if h==0:
        for r in range(101):
            for c in range(101):
                u_bound[r][c] = min(u_bound[r][c], abs(c-x) + abs(r-y))
    else:
        for r in range(101):
            for c in range(101):
                l_bound[r][c] = max(l_bound[r][c], h + abs(c-x) + abs(r-y))
                u_bound[r][c] = min(u_bound[r][c], h + abs(c-x) + abs(r-y))

for r in range(101):
    for c in range(101):
        if l_bound[r][c] == u_bound[r][c]:
            print(c, r, l_bound[r][c])

Submission status: Wrong Answer

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

xyh.sort(key=lambda x: -x[2])

for x in range(101):
  for y in range(101):
    for i in range(N):
      if i == 0:
        ansh = xyh[i][2] + (abs(xyh[i][0] - x) + abs(xyh[i][1] - y))
        ansx = x
        ansy = y
      else:
        kouhoh = xyh[i][2] + (abs(xyh[i][0] - x) + abs(xyh[i][1] - y))
        if ansh != kouhoh:
          break
    else:
      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)]

#print(xyh[0][2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            if xyh[k][2] == 0:
                if H <= 0 and k == n-1:
                    print(cx,cy,H)
                    exit()
                elif H <= 0:
                    continue
                else:
                    break
            
            flag += 1
            
            if flag == 1:
                #print(cx,cy,H)
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            #print(i,j,k,H,n-1)
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        """
        if k == n-1:
            break
    if k == n-1:
        break
    """

#print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

#print(xyh[0][2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            if xyh[k][2] == 0:
                if k == n-1:
                    print(cx,cy,H)
                    exit()
                continue
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            #print(i,j,k,H,n-1)
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        """
        if k == n-1:
            break
    if k == n-1:
        break
    """

#print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

#print(xyh[0][2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            if xyh[k][2] == 0:
                if H <= 0 and k == n-1:
                    print(cx,cy,H)
                    exit()
                elif H <= 0:
                    continue
                else:
                    break
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            #print(i,j,k,H,n-1)
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        """
        if k == n-1:
            break
    if k == n-1:
        break
    """

#print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

#print(xyh[0][2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            if xyh[k][2] == 0:
                if k == n-1:
                    print(cx,cy,H)
                    exit()
                else:
                    continue
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            #print(i,j,k,H,n-1)
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        """
        if k == n-1:
            break
    if k == n-1:
        break
    """

#print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

#print(xyh[0][2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            if xyh[k][2] == 0:
                continue
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            #print(i,j,k,H,n-1)
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        
        if k == n-1:
            break
    if k == n-1:
        break
    

print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

#print(xyh[0][2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            if xyh[k][2] == 0:
                continue
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            cx = i
            cy = j
            
            #print(i,j,k,H,n-1)
            
            if k == n-1:
                print(cx,cy,H)
                exit()
                break
        """
        if k == n-1:
            break
    if k == n-1:
        break
    """

#print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

#print(xyh[0][2])

cxy = 101

flag = 0

H = 0
cx = 0
cy = 0

for i in range(cxy):
    for j in range(cxy):
        flag = 0
        for k in range(n):
            if xyh[k][2] == 0:
                continue
            H = xyh[k][2] + abs(xyh[k][0] - i ) + abs(xyh[k][1] - j )
            
            cx = i
            cy = j
            
            flag += 1
            
            if flag == 1:
                H_old = H
            
            if flag > 1:
                if H != H_old:
                    break
            
            #print(i,j,k,H)
            
            if k == n-1:
                #print(i,j,k,H)
                break
        if k == n-1:
            break
    if k == n-1:
        break

print(cx,cy,H)

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
if xyh[0][2]==0:
  total=0
  for i in range(n):
    total+=xyh[i][0]
  cx=total//n
  total=0
  for i in range(n):
    total+=xyh[i][1]
  cy=total//n
  ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)
  print(cx,cy,ch)
  sys.exit()  
for cx in range(101):
  for cy in range(101):
    ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    flg=0
    for i in range(n):
      if xyh[i][2]!=0 and ch !=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]:
        flg=1
        break
    if flg==0:
      print(cx,cy,ch)
      sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
xyh.sort(key=lambda x:x[2],reverse=True)
for cx in range(101):
  for cy in range(101):
    ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    flg=0
    for i in range(n):
      if xyh[i][2]!=0 and ch !=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]:
        flg=1
        break
    if flg==0:
      print(cx,cy,ch)
      sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
for cx in range(101):
  for cy in range(101):
    ch=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
    flg=0
    for i in range(n):
      if ch !=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2]:
        flg=1
        break
    if flg==0:
      print(cx,cy,ch)
      sys.exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=[]
for i in range(n):
  x,y,z=map(int,input().split())
  if(z!=0):
    hoge.append([x,y,z])
  
for i in range(101):
  for j in range(101):
    h=[]
    for k in range(len(hoge)):
      h.append(hoge[k][2]+abs(hoge[k][0]-i)+abs(hoge[k][1]-j))
      
    if(h.count(h[0])==len(h)):
      print(i,j,h[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=[]
for i in range(n):
  x,y,z=map(int,input().split())
  hoge.append([x,y,z])
  
for i in range(101):
  for j in range(101):
    h=[]
    for k in range(n):
      h.append(hoge[k][2]+abs(hoge[k][0]-i)+abs(hoge[k][1]-j))
      
    if(h.count(h[0])==len(h) and h[0]!=0):
      print(i,j,h[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
hoge=[]
for i in range(n):
  x,y,z=map(int,input().split())
  hoge.append([x,y,z])
  
for i in range(101):
  for j in range(101):
    h=[]
    for k in range(n):
      h.append(hoge[k][2]+abs(hoge[k][0]-i)+abs(hoge[k][1]-j))
      
    if(h.count(h[0])==len(h)):
      print(i,j,h[0])
      exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
old_dl = [list(map(int,input().split())) for _ in range(N)]
dl = []
for k in old_dl:
    if k[2] != 0:
        dl.append(k)
if len(dl) == 1:
    print(dl[0][2])
else:
    for x in range(101):
        for y in range(101):
            ndl = [l[2]+abs(l[0]-x)+abs(l[1]-y) for l in dl]
            if max(ndl) == min(ndl):
                #print(ndl)
                print(x,y,max(ndl))
                exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
old_dl = [list(map(int,input().split())) for _ in range(N)]
dl = []
for k in old_dl:
    if k[2] != 0:
        dl.append(k)

for x in range(101):
    for y in range(101):
        ndl = [l[2]+abs(l[0]-x)+abs(l[1]-y) for l in dl]
        if max(ndl) == min(ndl):
            #print(ndl)
            print(x,y,max(ndl))
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
dl = [list(map(int,input().split())) for _ in range(N)]
for x in range(101):
    for y in range(101):
        ndl = [l[2]+abs(l[0]-x)+abs(l[1]-y) for l in dl]
        if max(ndl) == min(ndl):
            print(x,y,max(ndl))
            exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

flag = False
for cx in range(101):
    for cy in range(101):
        needH = -1
        for i in range(N-1, -1, -1):
            H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
            if needH == -1:
                needH = H
            else:
                if h[i] > 0:
                    if needH != H:
                        needH = -2
                        break
                else:
                    if needH > H:
                        needH = -2
                        break
        if needH == -2:
            continue
        else:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

flag = False
for cx in range(101):
    for cy in range(101):
        needH = -1
        for i in range(N-1, -1, -1):
            H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
            if needH == -1:
                needH = H
            if h[i] > 0:
                if needH != H:
                    needH = -2
                    break
            else:
                if needH > H:
                    needH = -2
                    break
        if needH == -2:
            continue
        else:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2])
x = [0] * N
y = [0] * N
h = [0] * N
for i in range(N):
    x[i], y[i], h[i] = xyh[i][0], xyh[i][1], xyh[i][2]

flag = False
for cx in range(101):
    for cy in range(101):
        needH = -1
        for i in range(N-1, -1, -1):
            H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
            if needH == -1:
                needH = H
            else:
                if needH != H:
                    needH = -2
                    break                    
        if needH != -2:
            flag = True
        if flag:
            break
    if flag:
        break

print(cx, cy, H)

Submission status: Wrong Answer

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

flag = False
for cx in range(101):
    for cy in range(101):
        H = abs(x[i] - cx) + abs(y[i] - cy) + h[i]
        for i in range(N):
            if H != abs(x[i] - cx) + abs(y[i] - cy) + h[i]:
                break
            if i == N - 1:
                flag = True
        if flag:
            break
    if flag:
        break


print(cx, cy, H)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    P = [None] * N
    x0, y0, h0 = 0, 0, 0
    for i in range(N):
        x, y, h = map(int, input().split())
        if h != 0 and h0 == 0:
            x0, y0, h0 = x, y, h
        P[i] = (x, y, h)
    for i in range(101):
        for j in range(101):
            H = h0 + abs(i-x0) + abs(j-y0)
            for x, y, h in P:
                dist = abs(i-x) + abs(j-y)
                if (h > 0 and dist != H-h) or (h == 0 and dist <= H):
                    break
            else:
                print(i, j, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    P = [None] * N
    x0, y0, h0 = 0, 0, 0
    for i in range(N):
        x, y, h = map(int, input().split())
        if h != 0 and h0 == 0:
            x0, y0, h0 = x, y, h
        P[i] = (x, y, h)
    for i in range(101):
        for j in range(101):
            H = h0 + abs(i-x0) + abs(j-y0)
            for x, y, h in P[1:]:
                dist = abs(i-x) + abs(j-y)
                if (h > 0 and dist != H-h) or (h == 0 and dist <= H):
                    break
            else:
                print(i, j, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    P = [None] * N
    for i in range(N):
        P[i] = tuple(map(int, input().split()))
    for i in range(101):
        for j in range(101):
            x0, y0, h0 = P[0]
            H = h0 + abs(i-x0) + abs(j-y0)
            for x, y, h in P[1:]:
                if abs(i-x) + abs(j-y) != H-h:
                    break
            else:
                print(i, j, H)
                return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

x = [0]*n
y = [0]*n
h = [0]*n
H = [0]*n

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  
for cx in range(101):
  for cy in range(101):
    for i in range(n):
      H[i] = max(h[i] + abs(x[i]-cx) + abs(y[i]-cy), 0)
    c = collections.Counter(H)
    if len(c) == 1 and H[0] >= max(h):
      print(cx, cy, H[0])
      exit()

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

x = [0]*n
y = [0]*n
h = [0]*n
H = [0]*n

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  
for cx in range(101):
  for cy in range(101):
    for i in range(n):
      H[i] = max(h[i] + abs(x[i]-cx) + abs(y[i]-cy), 0)
    c = collections.Counter(H)
    if len(c) == 1:
      print(cx, cy, H[0])
      exit()

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

x = [0]*n
y = [0]*n
h = [0]*n
H = [0]*n

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  
for cx in range(101):
  for cy in range(101):
    for i in range(n):
      H[i] = max(h[i] + abs(x[i]-cx) + abs(y[i]-cy), 0)
    c = collections.Counter(H)
    if len(c) == 1 and H[0] >= max(h):
      print(cx, cy, H[0])

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

x = [0]*n
y = [0]*n
h = [0]*n
H = [0]*n

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  
for cx in range(101):
  for cy in range(101):
    for i in range(n):
      H[i] = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
    c = collections.Counter(H)
    if len(c) == 1 and H[0] >= max(h):
      print(cx, cy, H[0])

Submission status: Wrong Answer

Solution code:
import collections

n = int(input())

x = [0]*n
y = [0]*n
h = [0]*n
H = [0]*n

for i in range(n):
  x[i], y[i], h[i] = map(int, input().split())
  
for cx in range(101):
  for cy in range(101):
    for i in range(n):
      H[i] = h[i] + abs(x[i]-cx) + abs(y[i]-cy)
    c = collections.Counter(H)
    if len(c) == 1:
      print(cx, cy, H[0])

Submission status: Wrong Answer

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


def solve(N: int, x: "List[int]", y: "List[int]", h: "List[int]"):
    X = 0
    Y = 0
    hh = 0
    for i in range(0, 101):
        for j in range(0, 101):
            H =  []
            for k in range(N):
                if h[k] > 0:
                    H.append(h[k] + abs(x[k] - i) + abs(y[k] - j))
            if len(list(set(H))) == 1:
                X, Y, hh = i, j, H[-1]
    print(X, Y, hh)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    y = [int()] * (N)  # type: "List[int]" 
    h = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
        h[i] = int(next(tokens))
    solve(N, x, y, h)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def find_xyh(xyh,n):
  for xi in range(100+1):
    for yi in range(100+1):      
      x,y,h = xyh[0]
      if h==0:
        continue
      H = h + abs(xi-x) + abs(yi-y)      
      is_fill = True

      for x,y,h in xyh[1:]:
        if h != max(H -abs(xi-x) -abs(yi-y), 0):
          is_fill = False
          break
                
      if is_fill:
        print(xi,yi,H)
        return

find_xyh(xyh,n)

Submission status: Wrong Answer

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

def find_xyh(xyh,n):
  for xi in range(100+1):
    for yi in range(100+1):
      x,y,h = xyh[0]
      H = h + abs(xi-x) + abs(yi-y)      
      is_fill = True

      for x,y,h in xyh[1:]:
        if h != max(H -abs(xi-x) -abs(yi-y), 0):
          is_fill = False
          break
                
      if is_fill:
        print(xi,yi,H)
        return

find_xyh(xyh,n)

Submission status: Wrong Answer

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

def find_xyh(xyh,n):
  for xi in range(100+1):
    for yi in range(100+1):
      x,y,h = xyh[0]
      H = h + abs(xi-x) + abs(yi-y)      
      is_fill = True

      for x,y,h in xyh[1:]:
        if h != max(H -abs(xi-x) -abs(yi-y), 0):
          is_fill = False
          break
                
      if is_fill:
        print(xi,yi,H)        

find_xyh(xyh,n)