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:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    idxes = []

    for i in range(N):
        X[i], Y[i], H[i] = MI()
        idxes.append((H[i], i))

    idxes.sort(reverse=True)

    for cx in range(101):
        for cy in range(101):
            ans = None
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            counter = 1
            for _, i in idxes:
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and tmp < ans:
                        break
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                if ans is None:
                    a = X[0] + Y[0]
                    for i in range(1, N):
                        a = min(a, X[i] + Y[i])
                    print(cx, cy, a)
                else:
                    print(cx, cy, ans)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N
    idxes = []

    for i in range(N):
        X[i], Y[i], H[i] = MI()
        idxes.append((H[i], i))

    idxes.sort(reverse=True)

    for cx in range(101):
        for cy in range(101):
            ans = None
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            counter = 1
            for _, i in idxes:
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and tmp < ans:
                        break
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                print(cx, cy, ans)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N

    for i in range(N):
        X[i], Y[i], H[i] = MI()

    for cx in range(101):
        for cy in range(101):
            ans = None
            if H[0] != 0:
                ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            counter = 1
            for i in range(1, N):
                if H[i] == 0:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and tmp < ans:
                        break
                else:
                    tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                    if ans is not None and ans != tmp:
                        break
                    ans = tmp
                counter += 1

            if counter >= N:
                print(cx, cy, ans)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N = int(input())
    X = [0] * N
    Y = [0] * N
    H = [0] * N

    for i in range(N):
        X[i], Y[i], H[i] = MI()

    for cx in range(101):
        for cy in range(101):
            ans = H[0] + abs(X[0] - cx) + abs(Y[0] - cy)
            counter = 1
            for i in range(1, N):
                tmp = H[i] + abs(X[i] - cx) + abs(Y[i] - cy)
                if ans != tmp:
                    break
                ans = tmp
                counter += 1

            if counter >= N:
                print(cx, cy, ans)
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[0]*N
Y=[0]*N
H=[0]*N
import sys
for i in range(N):
    X[i],Y[i],H[i]=map(int,input().split())
for x in range(100+1):
    for y in range(100+1):
        assume_h = max(H[0] + abs(x-X[0]) + abs(y-Y[0]),0)
        for i in range(min(N,10)):
            #print(x,y,i)
            #print(H[i] + abs(x-X[i]) + abs(y-Y[i]))
            if max(H[i] + abs(x-X[i]) + abs(y-Y[i]),0) != assume_h:
                break
        else:
            print(x,y,assume_h)
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[0]*N
Y=[0]*N
H=[0]*N
import sys
for i in range(N):
    X[i],Y[i],H[i]=map(int,input().split())
for x in range(100+1):
    for y in range(100+1):
        assume_h = H[0] + abs(x-X[0]) + abs(y-Y[0])
        for i in range(min(N,10)):
            #print(x,y,i)
            #print(H[i] + abs(x-X[i]) + abs(y-Y[i]))
            if H[i] + abs(x-X[i]) + abs(y-Y[i]) != assume_h:
                break
        else:
            print(*[x,y,assume_h])
            sys.exit()

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[0]*N
Y=[0]*N
H=[0]*N
import sys
for i in range(N):
    X[i],Y[i],H[i]=map(int,input().split())
for x in range(100+1):
    for y in range(100+1):
        assume_h = H[0] + abs(x-X[0]) + abs(y-Y[0])
        for i in range(N):
            #print(x,y,i)
            #print(H[i] + abs(x-X[i]) + abs(y-Y[i]))
            if H[i] + abs(x-X[i]) + abs(y-Y[i]) != assume_h:
                break
        else:
            print(*[x,y,assume_h])
            sys.exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for _ in [0]*n]
xyh = sorted(xyh,key=lambda x:x[2])
# H-|x-Cx|-|y-Cy| = h

#全探索で良さそう
for i in range(101):
  for j in range(101):
    Cx,Cy=i,j
    print(Cx,Cy)
    x,y,h = xyh[-1][0],xyh[-1][1],xyh[-1][2]
    H = max( h+ abs(x-Cx)+ abs(y-Cy), 0)
    if all([h==max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in xyh]):
      print(Cx,Cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
xyh = [list(map(int,input().split())) for _ in [0]*n]
xyh = sorted(xyh,key=lambda x:x[2])
# H-|x-Cx|-|y-Cy| = h

#全探索で良さそう
for i in range(101):
  for j in range(101):
    Cx,Cy=i,j
    x0,y0,h0 = xyh[0][0],xyh[0][1],xyh[0][2]
    H = max(h0 + abs(x0-Cx) + abs(y0-Cy),0)
    if all([h==max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in xyh]):
      print(Cx,Cy,H)
      exit()

Submission status: Wrong Answer

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

# H-|x-Cx|-|y-Cy| = h

#全探索で良さそう
for i in range(101):
  for j in range(101):
    Cx=i;Cy=j
    x0,y0,h0 = xyh[0][0],xyh[0][1],xyh[0][2]
    H = max(h0 + abs(x0-Cx) + abs(y0-Cy),0)
    if all([h==max(H-abs(x-Cx)-abs(y-Cy),0) for x,y,h in xyh]):
      print(Cx,Cy,H)
      exit()

Submission status: Wrong Answer

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

# H-|x-Cx|-|y-Cy| = h

#全探索で良さそう
for i in range(101):
  for j in range(101):
    Cx=i;Cy=j
    x0,y0,h0 = xyh[0][0],xyh[0][1],xyh[0][2]
    H = max(h0 + abs(x0-Cx) + abs(y0-Cy),0)
    tf = "true"
    for k in range(1,n):
      x,y,h = xyh[k][0],xyh[k][1],xyh[k][2]
      #print(x,y,h)
      if H != max(h + abs(x-Cx) + abs(y-Cy),0):
        #print(Cx,Cy,H)
        tf = "false"
        break
    if tf == "true" and H >=1:
      print(Cx,Cy,H)
      exit()

Submission status: Wrong Answer

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

# H-|x-Cx|-|y-Cy| = h

#全探索で良さそう
for i in range(101):
  for j in range(101):
    Cx=i;Cy=j
    x0,y0,h0 = xyh[0][0],xyh[0][1],xyh[0][2]
    H = h0 + abs(x0-Cx) + abs(y0-Cy)
    tf = "true"
    for k in range(1,n):
      x,y,h = xyh[k][0],xyh[k][1],xyh[k][2]
      #print(x,y,h)
      if H != h + abs(x-Cx) + abs(y-Cy):
        #print(Cx,Cy,H)
        tf = "false"
        break
    if tf == "true" and H >=1:
      print(Cx,Cy,H)
      exit()

Submission status: Wrong Answer

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

# H-|x-Cx|-|y-Cy| = h

#全探索で良さそう
for i in range(101):
  for j in range(101):
    Cx=i;Cy=j
    x0,y0,h0 = xyh[0][0],xyh[0][1],xyh[0][2]
    H = h0 + abs(x0-Cx) + abs(y0-Cy)
    tf = "true"
    for k in range(1,n):
      x,y,h = xyh[k][0],xyh[k][1],xyh[k][2]
      #print(x,y,h)
      if H != h + abs(x-Cx) + abs(y-Cy):
        #print(Cx,Cy,H)
        tf = "false"
        break
    if tf == "true":
      print(Cx,Cy,H)
      exit()

Submission status: Wrong Answer

Solution code:
#C
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]

CX = 0
CY = 0
flag = 0
for CX in range(101):
    for CY in range(101):
        H = 0
        hmax = 0
        for i in range(N):
            x,y,h = XYH[i]
            if H == 0:
                if h != 0:
                    H = abs(CX-x)+abs(CY-y)+h
                    if H > hmax and hmax > 0:
                        H = 0
                        break
                else:
                    hmax = max(hmax,abs(CX-x)+abs(CY-y)+h)
            else:
                if h != 0:
                    if H != abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
                else:
                    if H > abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
        if H >= 1:
            print(CX,CY,H)
            flag = 1
            break
    if flag == 1:
        break

Submission status: Wrong Answer

Solution code:
#C
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]

CX = 0
CY = 0
flag = 0
for CX in range(101):
    for CY in range(101):
        H = 0
        hmax = 0
        for i in range(N):
            x,y,h = XYH[i]
            if H == 0:
                if h != 0:
                    H = abs(CX-x)+abs(CY-y)+h
                    if H > hmax:
                        H = 0
                        break
                else:
                    hmax = max(hmax,abs(CX-x)+abs(CY-y)+h)
            else:
                if h != 0:
                    if H != abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
                else:
                    if H > abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
        if H >= 1:
            print(CX,CY,H)
            flag = 1
            break
    if flag == 1:
        break

Submission status: Wrong Answer

Solution code:
#C
N = int(input())
XYH = [list(map(int,input().split())) for i in range(N)]

CX = 0
CY = 0
flag = 0
for CX in range(101):
    for CY in range(101):
        H = 0
        for i in range(N):
            x,y,h = XYH[i]
            if H == 0:
                if h != 0:
                    H = abs(CX-x)+abs(CY-y)+h
            else:
                if h != 0:
                    if H != abs(CX-x)+abs(CY-y)+h:
                        H = 0
                        break
        if H >= 1:
            print(CX,CY,H)
            flag = 1
            break
    if flag == 1:
        break

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
d=[0,0]
f=0
if n==1:
  a=1  
else:
    n=len(XYH)
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
d=[0,0]
f=0
if n==1:
    print()
else:
    n=len(XYH)
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
d=[0,0]
f=0
for i in range(101):
    for j in range(101):
        l=abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2]
        for k in range(n):
            if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                break
        else:
            f=1
            d=[i,j]

        if f==1:
            break

    if f==1:
        break
if f==1:
    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
else:
    k
print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
d=[0,0]
f=0
for i in range(101):
    for j in range(101):
        l=abs(XYH[-1][0]-i)+abs(XYH[-1][1]-j)+XYH[-1][2]
        for k in range(n):
            if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                break
        else:
            f=1
            d=[i,j]

        if f==1:
            break

    if f==1:
        break

d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
if n==1:
    #この時どうなるか
    d=[0,0,xyh[0][0]+xyh[0][1]]
    print(" ".join(map(str,d)))
else:
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[-1][0]-i)+abs(XYH[-1][1]-j)+XYH[-1][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
if n==1:
    d=[xyh[0][0],xyh[0][1],xyh[0][0]+xyh[0][1]+xyh[0][2]]
    print(" ".join(map(str,d)))
else:
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[-1][0]-i)+abs(XYH[-1][1]-j)+XYH[-1][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
XYH=[i for i in xyh if i[2]!=0]
n=len(XYH)
if n==1:
    d=[xyh[0][0],xyh[0][1],xyh[0][2]]
    print(" ".join(map(str,d)))
else:
    d=[0,0]
    f=0
    for i in range(101):
        for j in range(101):
            l=abs(XYH[-1][0]-i)+abs(XYH[-1][1]-j)+XYH[-1][2]
            for k in range(n):
                if l!=abs(XYH[k][0]-i)+abs(XYH[k][1]-j)+XYH[k][2]:
                    break
            else:
                f=1
                d=[i,j]

            if f==1:
                break

        if f==1:
            break

    d.append(abs(XYH[0][0]-i)+abs(XYH[0][1]-j)+XYH[0][2])
    print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
#高さは後から決まりそう、中心を決める
#x,y,nで動かす三重ループ

n=int(input())
xyh=[list(map(int,input().split())) for i in range(n)]
d=[0,0]
f=0
for i in range(101):
    for j in range(101):
        l=abs(xyh[-1][0]-i)+abs(xyh[-1][1]-j)+xyh[-1][2]
        for k in range(n):
            if l!=abs(xyh[k][0]-i)+abs(xyh[k][1]-j)+xyh[k][2] and xyh[k][2]!=0:
                break
        else:
            f=1
            d=[i,j]

        if f==1:
            break

    if f==1:
        break

d.append(abs(xyh[0][0]-i)+abs(xyh[0][1]-j)+xyh[0][2])
print(" ".join(map(str,d)))

Submission status: Wrong Answer

Solution code:
n=int(input())
li=[]
cnt=[]
for i in range(n):
    x,y,h=map(int,input().split())
    li.append([x,y,h])
for j in range(0,101):
    for k in range(0,101):
        for l in range(n):
            if li[l][2]!=0:
                cnt.append(li[l][2]+abs(li[l][0]-j)+abs(li[l][1]-k))
        if len(set(cnt))==1:
            ans=[j,k,cnt[0]]
            break
        else:
            cnt=[]

print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
n=int(input())
li=[]
cnt=[]
for i in range(n):
    x,y,h=map(int,input().split())
    li.append([x,y,h])
for j in range(0,101):
    for k in range(0,101):
        for l in range(1,n):
            if li[l][2]!=0:
                cnt.append(li[l][2]+abs(li[l][0]-j)+abs(li[l][1]-k))
        if len(set(cnt))==1:
            ans=[j,k,cnt[0]]
            break
        else:
            cnt=[]

print(ans[0],ans[1],ans[2])

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    xyh=[]
    for _ in range(n):
        x,y,h=inpm()
        xyh.append([x,y,h])
    xyh.sort(key=lambda x: x[2], reverse=True)
    for xc in range(101):
        for yc in range(101):
            x=xyh[0][0]
            y=xyh[0][1]
            h=xyh[0][2]
            d=abs(xc-x)+abs(yc-y)
            H=h+d
            for i in range(1,n):
                x=xyh[i][0]
                y=xyh[i][1]
                h=xyh[i][2]
                d = abs(xc-x) + abs(yc-y)
                H1=h+d
                if H1!=d and H1!=H:
                    break
                if i == n-1:
                    print(xc,yc,H)
                    return
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    x=[]
    y=[]
    h=[]
    ans=[0,0,0]
    for _ in range(n):
        xx,yy,hh=inpm()
        x.append(xx)
        y.append(yy)
        h.append(hh)
    for xc in range(101):
        for yc in range(101):
            a=[]
            H=0
            for i in range(n):
                if i==n-1:
                    if h[i]==0:
                        if len(a)==0:
                            break
                        ans=[str(xc),str(yc),str(a[0])]
                        print(' '.join(ans))
                        return
                    d = abs(xc-x[i]) + abs(yc-y[i])
                    H = h[i]+d
                    if len(a)>0:
                        if H!=a[0]:
                            break
                        else:
                            ans=[str(xc),str(yc),str(a[0])]
                            print(' '.join(ans))
                            return
                    else:
                        ans=[str(xc),str(yc),str(H)]
                        print(' '.join(ans))
                        return
                if h[i]==0:
                    continue
                d = abs(xc-x[i]) + abs(yc-y[i])
                H=h[i]+d
                if len(a)>=1:
                    if H!=a[0]:
                        break
                else:
                    a.append(H)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    x=[]
    y=[]
    h=[]
    ans=[0,0,0]
    for _ in range(n):
        xx,yy,hh=inpm()
        x.append(xx)
        y.append(yy)
        h.append(hh)
    for xc in range(101):
        for yc in range(101):
            a=[]
            H=0
            for i in range(n):
                if h[i]==0:
                    if i==n-1:
                        ans=[str(xc),str(yc),str(H)]
                    continue
                d = abs(xc-x[i]) + abs(yc-y[i])
                H=h[i]+d
                if len(a)>=1:
                    if H!=a[0]:
                        break
                    elif i==n-1:
                        ans=[str(xc),str(yc),str(H)]
                        break
                else:
                    a.append(H)
                    if i==n-1:
                        ans=[str(xc),str(yc),str(H)]
    print(' '.join(ans))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    x=[]
    y=[]
    h=[]
    ans=[0,0,0]
    for _ in range(n):
        xx,yy,hh=inpm()
        x.append(xx)
        y.append(yy)
        h.append(hh)
    for xc in range(101):
        for yc in range(101):
            a=[]
            H=0
            for i in range(n):
                d = abs(xc-x[i]) + abs(yc-y[i])
                if h[i]==0:
                    if i==n-1:
                        ans=[str(xc),str(yc),str(H)]
                    continue
                H=h[i]+d
                if len(a)>=1:
                    if H!=a[0]:
                        break
                    elif i==n-1:
                        ans=[str(xc),str(yc),str(H)]
                        break
                else:
                    a.append(H) 
    print(' '.join(ans))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])

    
def main():
    n=int(input())
    x=[]
    y=[]
    h=[]
    for _ in range(n):
        xx,yy,hh=inpm()
        x.append(xx)
        y.append(yy)
        h.append(hh)
    for xc in range(101):
        for yc in range(101):
            a=[]
            for i in range(n):
                d = abs(xc-x[i]) + abs(yc-y[i])
                if h[i]==0:
                    continue
                H=h[i]+d
                if len(a)>=1:
                    if H!=a[0]:
                        break
                    elif i==n-1:
                        print(xc,yc,H)
                        return
                else:
                    a.append(H)
if __name__ == "__main__":
    main()