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:
#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 = 0
    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] = 0

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

    # answer
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 = 0
    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] = 0

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

    # answer
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(b)
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 = 0
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))
        if h > 0:
            idx = 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 g in range(N):
        x,y,h = info[g]
        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

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

    # answer
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    
    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

    initcount = 0
    while True:
        x,y,h = LMIIS()
        initcount += 1
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                b[i][j] = vtop(x,j,y,i,h)
        break

    for _ in range(N-initcount):
        x,y,h = LMIIS()
        if h == 0:
            b[y][x] = 0
        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


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

                
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    
    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

    initcount = 0
    while True:
        x,y,h = LMIIS()
        initcount += 1
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                b[i][j] = vtop(x,j,y,i,h)
        break

    for _ in range(N-initcount):
        x,y,h = LMIIS()
        if h == 0:
            b[y][x] = 0
            continue
        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
                    b[x][y] = 0

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

                
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    
    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
    h = 0
    initcount = 0
    while True:
        x,y,h = LMIIS()
        initcount += 1
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                b[i][j] = vtop(x,j,y,i,h)
        break

    for _ in range(N-initcount):
        x,y,h = LMIIS()
        if h == 0:
            b[y][x] = 0
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != 0:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

                
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c
# C - Pyramid

N = int(input().split()[0])
xyh_list = []
not_zero_h_list = []

for _ in range(N):
    x, y, h = list(map(int, input().split()))
    xyh_list.append((x, y, h))
    if h != 0:
        not_zero_h_list.append((x, y, h))

target_x, target_y, target_h = not_zero_h_list[0]

for cx in range(0, 101):
    for cy in range(0, 101):
        # cx, cy = 2, 2
        H_list = []
        H = target_h + abs(target_x-cx) + abs(target_y-cy)
        H = max(0, H)
        is_ok = True
        for x, y, h in xyh_list:
            HH = h + abs(x-cx) + abs(y-cy)
            HH = max(0, HH)
            if HH != H:
                # 一致しない
                is_ok = False
                break
        if is_ok:
            break

    if is_ok:
        break
ans = '{} {} {}'.format(cx, cy, H)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c
# C - Pyramid

N = int(input().split()[0])
xyh_list = []

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

is_ok = False
for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for x, y, h in xyh_list:
            if h == 0:
                continue
            H = h + abs(x-cx) + abs(y-cy)
            H_list.append(H)

        if len(set(H_list)) == 1 and 0 < list(set(H_list))[0] < 10**9:
            # 一意に決まる場合
            is_ok = True
            break

    if is_ok:
        break

ans = '{} {} {}'.format(cx, cy, H)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c
# C - Pyramid

N = int(input().split()[0])
xyh_list = []

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

is_ok = False
for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for x, y, h in xyh_list:
            H = h + abs(x-cx) + abs(y-cy)
            H_list.append(H)

        if len(set(H_list)) == 1 and 1 < list(set(H_list))[0] < 10**9:
            # 一意に決まる場合
            is_ok = True
            break

    if is_ok:
        break

ans = '{} {} {}'.format(cx, cy, H)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c
# C - Pyramid

N = int(input().split()[0])
xyh_list = []

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

is_ok = False
for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for x, y, h in xyh_list:
            H = h + abs(x-cx) + abs(y-cy)
            H_list.append(H)
        if len(set(H_list)) == 1 and 0 < list(set(H_list))[0] < 10**9:
            is_ok = True
            break
    if is_ok:
        break

ans = '{} {} {}'.format(cx, cy, H)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc112/tasks/abc112_c
# C - Pyramid

N = int(input().split()[0])
xyh_list = []

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

is_ok = False
for cx in range(0, 101):
    for cy in range(0, 101):
        H_list = []
        for x, y, h in xyh_list:
            H = h + abs(x-cx) + abs(y-cy)
            H_list.append(H)
        if len(set(H_list)) == 1:
            is_ok = True
            break
    if is_ok:
        break

ans = '{} {} {}'.format(cx, cy, H)
print(ans)

Submission status: Wrong Answer

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)
H = -1
ansX = -1
ansY = -1
flag = False
for x in range(101):
    for y in range(101):
        for i in range(n):
            tmp = h_li[i] + abs(x_li[i] - x) + abs(y_li[i] - y)
            if H == -1 and h_li[i] != 0:
                H = tmp
                ansX = x
                ansY = y
            elif H == tmp or h_li[i] == 0:
                if i == n - 1:
                    flag = True
                    break
            else:
                H = -1
                break
        if flag:
            break
    if flag:
        break

print(ansX, ansY, H)

Submission status: Wrong Answer

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)
H = -1
ansX = -1
ansY = -1
flag = False
for x in range(101):
    for y in range(101):
        for i in range(n):
            tmp = h_li[i] + abs(x_li[i] - x) + abs(y_li[i] - y)
            if i == 0:
                H = tmp
                ansX = x
                ansY = y
            elif H == tmp:
                if i == n - 1:
                    flag = True
                    break
            else:
                H = -1
                break
        if flag:
            break
    if flag:
        break

print(ansX, ansY, H)

Submission status: Wrong Answer

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)
minX = min(x_li)
maxX = max(x_li)
minY = min(y_li)
maxY = max(y_li)
H = -1
ansX = -1
ansY = -1
flag = False
for x in range(minX, maxX+1):
    for y in range(minY, maxY+1):
        for i in range(n):
            tmp = h_li[i] + abs(x_li[i] - x) + abs(y_li[i] - y)
            if i == 0:
                H = tmp
                ansX = x
                ansY = y
            elif H == tmp:
                if i == n - 1:
                    flag = True
                    break
            else:
                H = -1
                break
        if flag:
            break
    if flag:
        break

print(ansX, ansY, H)

Submission status: Wrong Answer

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()
    
    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
    h = 0
    initcount = 1
    while True:
        x,y,h = LMIIS()
        initcount += 1
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                b[i][j] = vtop(x,j,y,i,h)
        break

    for _ in range(N-initcount):
        x,y,h = LMIIS()
        if h == 0:
            b[y][x] = 0
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != 0 and b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = 0
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    
    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
    h = 0
    initcount = 1
    while True:
        x,y,h = LMIIS()
        initcount += 1
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                b[i][j] = vtop(x,j,y,i,h)
        break

    for _ in range(N-initcount):
        x,y,h = LMIIS()
        if h == 0:
            b[i][j] = 0
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != 0 and b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = 0
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        return h1 + abs(x1-x2) + abs(y1-y2)
    h = 0
    initcount = 1
    while True:
        x,y,h = LMIIS()
        initcount += 1
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                b[i][j] = vtop(x,j,y,i,h)
        break

    for _ in range(N-initcount):
        x,y,h = LMIIS()
        if h == 0:
            b[i][j] = 0
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != 0 and b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = 0
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != 0 and b[i][j] < 10**9:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        return h1 + abs(x1-x2) + abs(y1-y2)
    h = 0
    initcount = 1
    while True:
        x,y,h = LMIIS()
        initcount += 1
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                b[i][j] = vtop(x,j,y,i,h)
        break

    for _ in range(N-initcount):
        x,y,h = LMIIS()
        if h == 0:
            continue
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != -1 and b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = -1
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != -1 and b[i][j] < 10**9:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    x,y,h = LMIIS()
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]
    b[y][x] = h

    def vtop(x1,x2,y1,y2,h1):
        return h1 + abs(x1-x2) + abs(y1-y2)

    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)

    for _ in range(N-1):
        x,y,h = LMIIS()
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != -1 and b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = -1
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != -1 and b[i][j] < 10**9:
                print(j,i,b[i][j])
                return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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()
    x,y,h = LMIIS()
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]
    b[y][x] = h

    def vtop(x1,x2,y1,y2,h1):
        return h1 + abs(x1-x2) + abs(y1-y2)

    for i in range(MAXL):
        for j in range(MAXL):
            b[i][j] = vtop(x,j,y,i,h)

    for _ in range(N-1):
        x,y,h = LMIIS()
        for i in range(MAXL):
            for j in range(MAXL):
                if b[i][j] != -1 and b[i][j] != vtop(x,j,y,i,h):
                    b[i][j] = -1
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] != -1:
                print(j,i,b[i][j])
                return



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [[i, j] for i in range(101) for j in range(101)]

def md(x1, x2):
  return abs(x1[0]-x2[0]) + abs(x1[1]-x2[1])
        
infos = []
k = 0
for i in range(n):
  info = list(map(int, input().split()))
  infos.append(info)
  if info[2] != 0:
    k = i

ans = [0, 0]
for p in xy:
  h = infos[k][2] + md(p, infos[k][:2])
  for i in range(n):
    if h - infos[i][2] != md(p, infos[i][:2]):
      break
  else:
    ans = p
    break
    
x = ans[0]
y = ans[1]
h = md(infos[k][:2], ans) + infos[k][2]
print('{} {} {}'.format(x, y, h))

Submission status: Wrong Answer

Solution code:
n = int(input())
xy = [[i, j] for i in range(101) for j in range(101)]

def md(x1, x2):
  return abs(x1[0]-x2[0]) + abs(x1[1]-x2[1])
        
infos = []
for i in range(n):
  info = list(map(int, input().split()))
  infos.append(info)
  
  if i != 0:
    for j in range(i):
      if infos[j][0] != 0:
        dh = infos[i][2] - infos[j][2]
        xy = list(filter(lambda x: md(x, infos[j][:2]) - md(x, infos[i][:2]) == dh, xy))
      
  if len(xy) == 1:    
    break
    
if len(xy) == 0:
  print('YYYYYYY')
else:
  x = xy[0][0]
  y = xy[0][1]
  k = 0

  for i in range(n):
    if infos[i][2] > 0:
      k = i
      break
  h = md(infos[k][:2], [x, y]) + infos[k][2]
  print('{} {} {}'.format(x, y, h))

Submission status: Wrong Answer

Solution code:
import sys
import math
from operator import itemgetter

n = int(input())
lh = [0] * n

for i in range(n):
    lh[i] = list(map(int, input().split()))

for x in range(101):
    for y in range(101):
        h = 0
        for j in range(n):
            if lh[j][2] == 0:
                continue
            if h == 0:
                h = lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y)
            else:
                if h != lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y):
                    break
        else:
             print(x,end=' ')
             print(y,end=' ')
             print(h,end=' ')
             sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
import math
from operator import itemgetter

n = int(input())
lh = [0] * n

for i in range(n):
    lh[i] = list(map(int, input().split()))

for x in range(101):
    for y in range(101):
        h = 0
        for j in range(n):
            if j == 0:
                h = lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y)
            else:
                if h != lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y):
                    break
        else:
             print(x,end=' ')
             print(y,end=' ')
             print(h,end=' ')
             sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
import math
from operator import itemgetter

n = int(input())
lh = [0] * n

for i in range(n):
    lh[i] = list(map(int, input().split()))

for x in range(101):
    for y in range(101):
        h = 0
        for j in range(n):
            if j == 0:
                h = lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y)
            elif 0 < j < n - 1:
                if h != lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y):
                    break
        else:
             print(x,end=' ')
             print(y,end=' ')
             print(h,end=' ')
             sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
import math
from operator import itemgetter

n = int(input())
lh = [0] * n

for i in range(n):
    lh[i] = list(map(int, input().split()))

for x in range(101):
    for y in range(101):
        h = 0
        for j in range(n):
            if j == 0:
                h = lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y)
            elif 0 < j < n - 1:
                if h != lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y):
                    break
            elif j == n - 1:
                if h == lh[j][2] + abs(lh[j][0] - x) + abs(lh[j][1] - y):
                    print(x,end=' ')
                    print(y,end=' ')
                    print(h,end=' ')
                    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
for i in range(N):
	pira[i] = list(map(int, input().split()))
	if pira[i][2] != 0:
		k = pira[i]

for x in range(101):
	for y in range(101):
		tmp = k[2] + abs(x-k[0]) + abs(y-k[1])
		for i in range(len(pira)):
			if pira[i][2] != max(tmp-abs(x-pira[i][0]-abs(y-pira[i][1])),0):
				break
			if i == len(pira)-1:
				print(x,y,tmp)
				exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
for i in range(N):
	pira[i] = list(map(int, input().split()))
	if pira[i][2] != 0:
		k = pira[i]

for x in range(101):
	for y in range(101):
		tmp = k[2] + abs(x-k[0]) + abs(y-k[1])
		for i in range(len(pira)):
			if pira[i][2] != max(tmp,0):
				break
			if i == len(pira)-1:
				print(pira[i][0],pira[i][1],pira[i][2])
				exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
for i in range(N):
	pira[i] = list(map(int, input().split()))
	if pira[i][2] != 0:
		k = pira[i]

for x in range(101):
	for y in range(101):
		tmp = pira[i][2] + abs(x-pira[i][0]) + abs(y-pira[i][1])
		for i in range(len(pira)):
			if pira[i][2] != max(tmp,0):
				break
			if i == len(pira)-1:
				print(pira[i][0],pira[i][1],pira[i][2])
				exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
H = 0
for i in range(101):
  for j in range(101):
    for l in xyh:
      h = abs(i - l[0]) + abs(j - l[1])
      if l[2] != 0:
        if H == 0:
          H = l[2] + h
        else:
          if l[2] + h != H:
            H = 0
            break
      else:
        if H != 0:
          if H - h > 0:
            H = 0
            break
            
    if H != 0:
      print(i, j, H)
      exit(0)
for i in range(101):
  for j in range(101):
    for l in xyh:
      h = abs(i - l[0]) + abs(j - l[1])
      if l[2] != 0:
        if H == 0:
          H = l[2] + h
        else:
          if l[2] + h != H:
            H = 0
            break
      else:
        H = 1
        if 1 - h > 0:
          H = 0
          break
    if H != 0:
      print(i, j, H)
      exit(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
xyh = [list(map(int, input().split())) for _ in range(N)]
H = 0
for i in range(101):
  for j in range(101):
    for l in xyh:
      h = abs(i - l[0]) + abs(j - l[1])
      if l[2] != 0:
        if H == 0:
          H = l[2] + h
        else:
          if l[2] + h != H:
            H = 0
            break
      else:
        if H != 0:
          if H - h > 0:
            H = 0
            break
            
    if H != 0:
      print(i, j, H)
      exit(0)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = True
for i in range(N):
	pira[i] = list(map(int, input().split()))
tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(x-pira[i][0]) + abs(y-pira[i][1])
				break
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
pira = [[] for i in range(N)]
ans = [0,0,0]
a = True
for i in range(N):
	pira[i] = list(map(int, input().split()))
tmp = 0

for x in range(101):
	for y in range(101):
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			else:
				tmp = pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y)
				break
		for i in range(len(pira)):
			if pira[i][2] == 0:
				continue
			if tmp != pira[i][2] + abs(pira[i][0]-x) + abs(pira[i][1]-y):
				a = False
				break
			else:
				a = True
				ans = [x,y,tmp]
		if a:
			break
	if a:
		break

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