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
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = [LI() for i in range(N)]
    
    for x in range(101):
        for y in range(101):
            max_num = float('inf')
            ans = 0
            res = True
            for xn, yn, hn in L:
                if hn == 0:
                    max_num = min(max_num, abs(x-xn)+abs(y-yn))
                    if max_num == 0:
                        res = False
                        break
                else:
                    temp = abs(x-xn)+abs(y-yn)+hn
                    if ans != 0 and ans != temp:
                        res = False
                        break
                    else:
                        ans = temp
            if max_num >= 2 and ans == 0:
                res = False

            if res:
                if ans != 0:
                    print(x,y,ans)
                else:
                    print(x,y,1)
                exit()
    
    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    L = [LI() for i in range(N)]
    
    for x in range(101):
        for y in range(101):
            max_num = float('inf')
            ans = 0
            res = True
            for xn, yn, hn in L:
                if hn == 0:
                    max_num = min(max_num, abs(x-xn)+abs(y-yn))
                    if max_num == 0:
                        res = False
                        break
                else:
                    temp = abs(x-xn)+abs(y-yn)+hn
                    if ans != 0 and ans != temp:
                        res = False
                        break
                    else:
                        ans = temp
            if res:
                if ans != 0:
                    print(x,y,ans)
                else:
                    print(x,y,1)
                exit()
    
    
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
list_XYH1, list_XYH = [ list(map(int,input().split(" "))) for _ in range(n)], []
for x, y, h in list_XYH1:
    if h != 0:
        list_XYH.append([x, y, h])

for i in range(0, 101):
    for j in range(0, 101):
        cnt = 0
        x, y, h = list_XYH[0]
        H = h + abs(i - x) + abs(j - y)
        for x, y, h in list_XYH:
            if h + abs(i - x) + abs(j - y) == H:
                cnt += 1

        if cnt == len(list_XYH) and cnt != 0:
            print(i, j, H)
            exit()

list_XYH2 = []
m = pow(10, 10)
for x, y, h in list_XYH1:
    m = min(m, h)
    list_XYH2.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH2:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
list_XYH1, list_XYH = [ list(map(int,input().split(" "))) for _ in range(n)], []
for x, y, h in list_XYH1:
    if h != 0:
        list_XYH.append([x, y, h])

for i in range(0, 101):
    for j in range(0, 101):
        cnt = 0
        x, y, h = list_XYH[0]
        H = h + abs(i - x) + abs(j - y)
        for x, y, h in list_XYH:
            if h + abs(i - x) + abs(j - y) == H:
                cnt += 1

        if cnt == len(list_XYH):
            print(i, j, H)
            exit()

list_XYH2 = []
m = pow(10, 10)
for x, y, h in list_XYH1:
    m = min(m, h)
    list_XYH2.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH2:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
list_XYH = []
m = pow(10, 10)
for _ in range(n):
    x, y, h = map(int, input().split())
    m = min(m, h)
    list_XYH.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 100):
            cnt = 0
            for x, y, h in list_XYH:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
list_XYH = []
m = pow(10, 10)
for _ in range(n):
    x, y, h = map(int, input().split())
    m = min(m, h)
    list_XYH.append([x, y, h])

for X in range(0, 101):
    for Y in range(0, 101):
        for H in range(m, m + 50):
            cnt = 0
            for x, y, h in list_XYH:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
list_XYH = []
m = pow(10, 10)
for _ in range(n):
    x, y, h = map(int, input().split())
    m = min(m, h)
    list_XYH.append([x, y, h])

for X in range(1, 101):
    for Y in range(1, 101):
        for H in range(m, m + 201):
            cnt = 0
            for x, y, h in list_XYH:
                if max(H - abs(x - X) - abs(y - Y), 0) == h:
                    cnt += 1

            if cnt == n:
                print(X, Y, H)
                exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        cnt = 0
        x, y, h = list_XYH[0]
        H = h + abs(i - x) + abs(j - y)
        for x, y, h in list_XYH:
            if h + abs(i - x) + abs(j - y) == H:
                cnt += 1

        if cnt == len(list_XYH):
            print(i, j, H)
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        H = 0
        for x, y, h in list_XYH:
            H = max(H, abs(i - x) + abs(j - y) + h)

        cnt = 0
        for x, y, h in list_XYH:
            if max(H - abs(i - x) - abs(j - y), 0) == h:
                cnt += 1

        if cnt == n:
            print(i, j, H)
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        x, y, h = list_XYH[0]
        H = max(abs(i - x) + abs(j - y) + h, 0)
        cnt = 0
        for k in range(n):
            x, y, h = list_XYH[k]
            if H == max(abs(i - x) + abs(j - y) + h, 0):
                cnt += 1
        if cnt == n:
            print(i, j, H)
            exit()

Submission status: Wrong Answer

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

for i in range(0, 101):
    for j in range(0, 101):
        x, y, h = list_XYH[0]
        H = abs(i - x) + abs(j - y) + h
        cnt = 0
        for k in range(n):
            x, y, h = list_XYH[k]
            if H == abs(i - x) + abs(j - y) + h:
                cnt += 1
        if cnt == n:
            print(i, j, H)
            exit()

Submission status: Wrong Answer

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

for i in range(1, 101):
    for j in range(1, 101):
        x, y, h = list_XYH[0]
        H = abs(i - x) + abs(j - y) + h
        cnt = 0
        for k in range(n):
            x, y, h = list_XYH[k]
            if H == abs(i - x) + abs(j - y) + h:
                cnt += 1
        if cnt == n:
            print(i, j, H)
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        hh = set([])
        hh2 = []
        for x,y,h in xyz:
            H = h + abs(x - cx) + abs(y - cy)
            if H < 1:
                # not found
                break
            
            if h > 0:
                if hh and H not in hh:
                    # not found
                    break
                hh.add(H)
            
            elif h == 0:
                hh2.append(H)
        else:
            if hh2 and not all([h2 >= H for h2 in hh2]):
                break
            
            # found
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        hh = set([])
        hh2 = []
        for x,y,h in xyz:
            H = h + abs(x - cx) + abs(y - cy)
            if H < 1:
                # not found
                break
            
            if h > 0:
                if hh and H not in hh:
                    # not found
                    break
                hh.add(H)
            
            elif h == 0:
                hh2.append(H)
        else:
            if not all([h2 >= H for h2 in hh2]):
                break
            
            # found
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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

for cx in range(101):
    for cy in range(101):
        hh = set([])
        for x,y,h in xyz:
            if h == 0:
                continue
            
            H = h + abs(x - cx) + abs(y - cy)
            if H < 1:
                # not found
                break
            if hh and H not in hh:
                # not found
                break
            hh.add(H)
        else:
            # found
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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

def check(x,y,cx,cy,h):
    H = h + abs(cx - x) + abs(cy - y)
    return H >= 1

for cx in range(101):
    for cy in range(101):
        hh = set([])
        for x,y,h in xyz:
            H = h + abs(cx - x) + abs(cy - y)
            # if H < 1:
            #     # not found
            #     break
            if hh and H not in hh:
                # not found
                break
            hh.add(H)
        else:
            # found
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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

def check(x,y,cx,cy,h):
    H = h + abs(cx - x) + abs(cy - y)
    return H >= 1

for cx in range(101):
    for cy in range(101):
        hh = set([])
        for x,y,h in xyz:
            H = h + abs(cx - x) + abs(cy - y)
            if H < 1:
                # not found
                break
            if hh and H not in hh:
                # not found
                break
            hh.add(H)
        else:
            # found
            print(cx, cy, H)
            exit()

Submission status: Wrong Answer

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


def height(x, y, H, a, b):
    return max(H-abs(x-a)-abs(y-b), 0)


for i in range(101):
    for j in range(101):
        a, b, h = Q[0]
        A = h+abs(i-a)+abs(j-b)
        B = height(a, b, h, i, j)
        f, g = True, True
        if B == 0:
            g = False
        for k in range(1, N):
            x, y, h = Q[k]
            if height(i, j, A, x, y) != h:
                f = False
            if height(i, j, B, x, y) != h:
                g = False
            if not (f or g):
                break
        else:
            if f:
                print(i, j, A)
                exit()
            else:
                print(i, j, B)
                exit()

Submission status: Wrong Answer

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


def height(x, y, H, a, b):
    return max(H-abs(x-a)-abs(y-b), 0)


for i in range(101):
    for j in range(101):
        a, b, h = Q[0]
        A = h+abs(i-a)+abs(j-b)
        B = height(a, b, h, i, j)
        f, g = True, True
        if g == 0:
            g = False
        for k in range(1, N):
            x, y, h = Q[k]
            if height(i, j, A, x, y) != h:
                f = False
            if height(i, j, B, x, y) != h:
                g = False
            if not (f or g):
                break
        else:
            if f:
                print(i, j, A)
                exit()
            else:
                print(i, j, B)
                exit()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:56:07 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h > 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            for b in box:
                if b[2]+abs(b[0]-C_x)+abs(b[1]-C_y)>0:
                    print("{} {} {}".format(b[0], b[1], b[2]))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:50:17 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h > 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) > 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-x)+abs(po[1]-y) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:42:52 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h != 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) > 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-x)+abs(po[1]-y) == po[2] or h+abs(po[0]-x)+abs(po[1]-y) == 0:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:17:29 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) >= 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-x)+abs(po[1]-y) == po[2] or h+abs(po[0]-x)+abs(po[1]-y) == 0:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    if len(H_possible) == 0:
        print('unko')
        return
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:15:11 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) >= 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-x)+abs(po[1]-y) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    if len(H_possible) == 0:
        print('unko')
        return
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:14:26 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) > 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-x)+abs(po[1]-y) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    if len(H_possible) == 0:
        print('unko')
        return
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:10:20 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h > 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) >= 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-x)+abs(po[1]-y) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:08:48 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h > 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) > 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-x)+abs(po[1]-y) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:06:43 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h > 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            if box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1]) > 0:
                H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-box[i][0])+abs(po[1]-box[i][1]) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:04:02 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h > 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])
#    if len(H_possible) == 1:
#        print("{} {} {}".format())
    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-box[i][0])+abs(po[1]-box[i][1]) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-25 00:00:57 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h != 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for po in H_possible:
            if h+abs(po[0]-box[i][0])+abs(po[1]-box[i][1]) == po[2]:
                H_new.append([po[0], po[1], po[2]])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-24 23:45:56 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h != 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for C_x in range(0, 101):
            for C_y in range(0, 101):
                if [C_x, C_y, h+abs(C_x-x)+abs(C_y-y)] in H_possible:
                    H_new.append([C_x, C_y, h+abs(C_x-x)+abs(C_y-y)])
        H_possible = H_new
        if len(H_possible) == 1:
            break
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-24 23:42:02 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h != 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for C_x in range(0, 101):
            for C_y in range(0, 101):
                if [C_x, C_y, h+abs(C_x-x)+abs(C_y-y)] in H_possible:
                    H_new.append([C_x, C_y, h+abs(C_x-x)+abs(C_y-y)])
        H_possible = H_new
    print("{} {} {}".format(H_possible[0][0], H_possible[0][1], H_possible[0][2]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-24 22:31:24 +0900
# LastModified: 2020-09-24 23:37:30 +0900
#


# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    box = []
    for _ in range(N):
        x, y, h = map(int, input().split())
        if h != 0:
            box.append([x, y, h])
    H_possible = []
    for C_x in range(0, 101):
        for C_y in range(0, 101):
            H_possible.append([C_x, C_y, box[0][2]+abs(C_x-box[0][0])+abs(C_y-box[0][1])])

    for i, (x, y, h) in enumerate(box):
        if i == 0:
            continue
        H_new = []
        for C_x in range(0, 101):
            for C_y in range(0, 101):
                if [C_x, C_y, h+abs(C_x-x)+abs(C_y-y)] in H_possible:
                    H_new.append([C_x, C_y, h+abs(C_x-x)+abs(C_y-y)])
        H_possible = H_new
    print(H_possible)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
info = []
for _ in range(n):
  x, y, h = map(int,input().split())
  info.append((x, y, h))

def check(cx, cy):
  H = None
  fin = []
  for i in info:
    x = i[0]
    y = i[1]
    h = i[2]
    if h != 0:
      tmpH = h + abs(x-cx) + abs(y-cy)
      if H:
        if H != tmpH:
          return 0
      else:
        H = tmpH
    elif h == 0:
      fin.append((x, y, h))
  for f in fin:
    if H - abs(x-cx) -abs(y-cy) > 0:
      return 0
  return H
      

for cx in range(101):
  for cy in range(101):
    h = check(cx, cy)
    if h >= 1:
      print(cx)
      print(cy)
      print(h)
      break

Submission status: Wrong Answer

Solution code:
n = int(input())
info = []
for _ in range(n):
  x, y, h = map(int,input().split())
  info.append((x, y, h))

def check(cx, cy):
  H = None
  for i in info:
    x = i[0]
    y = i[1]
    h = i[2]
    if h != 0:
      tmpH = h + abs(x-cx) + abs(y-cy)
      if H:
        if H != tmpH:
          return 0
      else:
        H = tmpH
  return H
      

for cx in range(101):
  for cy in range(101):
    h = check(cx, cy)
    if h >= 1:
      print(cx)
      print(cy)
      print(h)
      break