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: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    MAXL = 101
    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0
 
    N = II()
    b = [[0] * MAXL for _ in range(MAXL)]
 
    
    # get info
    info =[]
    info0 = []
    for _ in range(N):
        x,y,h = LMIIS()
        if h == 0:
            info0.append((x,y,h))
        else:
            info.append((x,y,h))
    if len(info) + len(info0) < N:
        raise

    # init candidates
    x,y,h = info[0]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)



    # check
    # for x,y,h in info0:
    #     for i in range(MAXL):
    #         for j in range(MAXL):
    #             if b[i][j] > vtop(x,j,y,i,h):
    #                 b[i][j] = 0
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = 0



    # answer
    ansl = []

    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    x,y,h = ansl.pop()
    print(x,y,h)
    # for x0,y0,h0 in ansl:
    #     f = True
    #     for x1,y1,h1 in info + info0:
    #         if h1 != max(h0-abs(x0-x1)-abs(y0-y1),0):
    #             f = False
    #             break
    #     if f:
    #         print(x0,y0,h0)
    #         return
    # raise




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    MAXL = 101
    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 10**9
 
    N = II()
    b = [[0] * MAXL for _ in range(MAXL)]
 
    
    # get info
    info =[]
    info0 = []
    for _ in range(N):
        x,y,h = LMIIS()
        if h == 0:
            info0.append((x,y,h))
        else:
            info.append((x,y,h))
    if len(info) + len(info0) < N:
        raise

    # init candidates
    x,y,h = info[0]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)



    # check
    # for x,y,h in info0:
    #     for i in range(MAXL):
    #         for j in range(MAXL):
    #             if b[i][j] > vtop(x,j,y,i,h):
    #                 b[i][j] = 0
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = 0



    # answer
    ansl = []

    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info + info0:
            if h1 != max(h0-abs(x0-x1)-abs(y0-y1),0):
                f = False
                break
        if f:
            print(x0,y0,h0)
            return
    raise




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    MAXL = 101
    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0
 
    N = II()
    b = [[0] * MAXL for _ in range(MAXL)]
 
    
    # get info
    info =[]
    info0 = []
    for _ in range(N):
        x,y,h = LMIIS()
        if h == 0:
            info0.append((x,y,h))
        else:
            info.append((x,y,h))
    if len(info) + len(info0) < N:
        raise

    # init candidates
    x,y,h = info[0]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)



    # check
    # for x,y,h in info0:
    #     for i in range(MAXL):
    #         for j in range(MAXL):
    #             if b[i][j] > vtop(x,j,y,i,h):
    #                 b[i][j] = 0
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = 0



    # answer
    ansl = []

    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info + info0:
            if h1 != max(h0-abs(x0-x1)-abs(y0-y1),0):
                f = False
                break
        if f:
            print(x0,y0,h0)
            return
    raise




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    MAXL = 101
    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0
 
    N = II()
    b = [[0] * MAXL for _ in range(MAXL)]
 
    
    # get info
    info =[]
    info0 = []
    for _ in range(N):
        x,y,h = LMIIS()
        if h == 0:
            info0.append((x,y,h))
        else:
            info.append((x,y,h))
    if len(info) + len(info0) < N:
        raise

    # init candidates
    x,y,h = info[0]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)



    # check
    for x,y,h in info0:
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] > vtop(x,j,y,i,h):
                    b[i][j] = 0
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = 0



    # answer
    ansl = []
    if N == 1:
        x,y,h = (info + info0)[0]
        print(x,y,h)
        return
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info + info0:
            if h1 != max(h0-abs(x0-x1)-abs(y0-y1),0):
                f = False
                break
        if f:
            print(x0,y0,h0)
            return
    raise




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
 
    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]
 
    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0
 
    # get info
    initidx = -1000
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))
        if h > 0:
            initidx = i

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    # input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    #XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))

    # info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    # input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    #XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    for _ in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))

    # info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    # input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    info = []
    for _ in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))

    # info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    # input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    info = []
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))

    # info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    info = []
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))

    # info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    # for i in range(N):
    #     x,y,h = LMIIS()
    #     info.append((x,y,h))
    #     if h > 0:
    #         initidx = i
    info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    NLMIIS = lambda N : [LMIIS() for _ in range(N)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    # for i in range(N):
    #     x,y,h = LMIIS()
    #     info.append((x,y,h))
    #     if h > 0:
    #         initidx = i
    info = NLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    initidx = -1000
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))
        if h > 0:
            initidx = i
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    x,y,h = info[initidx]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    initidx = -1000
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))
        if h > 0:
            initidx = i
    if len(info) != N:
        return

    # init candidates
    x,y,h = info[initidx]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    initidx = -1000
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))
        if h > 0:
            initidx = i

    # init candidates
    x,y,h = info[initidx]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = -1

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = -1

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    if len(ansl) == 2:
        while True:
            pass
    elif len(ansl) > 2:
        raise Exception()
    else:
        x,y,h = ansl[0]
        print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    initidx = -1000
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))
        if h > 0:
            initidx = i

    # init candidates
    x,y,h = info[initidx]
    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = -1

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = -1

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    if len(ansl) > 1:
        raise Exception()
    else:
        x,y,h = ansl[0]
        print(x,y,h)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
x_li = []
y_li = []
h_li = []
for i in range(n):
    x, y, h = na()
    x_li.append(x)
    y_li.append(y)
    h_li.append(h)
ans = []
flag = False
for x in range(101):
    for y in range(101):
        H = h_li[0] + abs(x_li[0] - x) + abs(y_li[0] - y)
        for i in range(n):
            if h_li[i] == max(H - abs(x_li[i] - x) - abs(y_li[i] - y), 0):
                if i == n - 1:
                    flag = True
                    ans.append([x, y, H])
                    break
            else:
                break
        if flag:
            break
    if flag:
        break
print(*ans[0])