Problem p03240 (python)

Fixed submission:
n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(len(s_list)):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            if len(zero_list) > 0:
                zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
                if zero_p <= 0:
                    ttt = h + abs(x_ - x) + abs(y_ - y)
                    ans = str(x) + " " + str(y) + " " + str(ttt)
                    break
            else:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
                
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(len(s_list)):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
            if zero_p <= 0:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s_list = []
ans = 0
zero_list = []
for _ in range(n):
    x, y, s = map(int, input().split())
    if s > 0:
        s_list.append([x, y, s])
    else:
        zero_list.append([x, y, s])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(n):
            x_, y_, h = s_list[i]
            if h > 0:
                t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            zero_p = max([list(t)[0] - abs(x - x_zero) - abs(y - y_zero) for (x_zero, y_zero, s_zero) in zero_list])
            if zero_p <= 0:
                ttt = h + abs(x_ - x) + abs(y_ - y)
                ans = str(x) + " " + str(y) + " " + str(ttt)
                break
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for _ in range(n):
    s.append([int(i) for i in input().split()])
for x in range(101):
    for y in range(101):
        t = []
        for i in range(n):
            x_, y_, h = s[i]
            t.append(h + abs(x_ - x) + abs(y_ - y))
        if (len(set(t)) == 1):
            ttt = h + abs(x_ - x) + abs(y_ - y)
            ans = str(x) + " " + str(y) + " " + str(ttt)
            break
print(ans)

Buggy submission (verdict: Runtime Error):
    n = int(input())
    sols = []
    for i in range(n):
        sols.append([int(i) for i in input().split()])
    if len(sols) == 1:
        print(*sols[0])
 
    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                break

Buggy submission (verdict: Runtime Error):
    n = int(input())
    sols = []
    for i in range(n):
        sols.append([int(i) for i in input().split()])
    if len(sols) == 1:
        print(*sols[0])
        return
 
    for cx in range(0, 101):
        for cy in range(0, 101):
            lastH = None
            for x, y, h in sols:
                H = h + abs(x - cx) + abs(y - cy)
                if H < 1:
                    continue
                if lastH:
                    if H != lastH:
                        break
                lastH = H
            else:
                print(cx, cy, H)
                break

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
a_list = []
for i in range(n):
    a_list.append([int(i) for i in input().split()])
if n = 1:
    print(a_list[0])
else:
    x_range = range(101)
    y_range = range(101)
    for i in x_range:
        for j in y_range:
            h_list = [abs(a[0]-i)+abs(a[1]-j)+a[2] for a in a_list]
            if (len(set(h_list)) == 1) & (h_list[0] > 0):
                print(i, j, h_list[0])
                break