Problem p03240 (python)

Fixed submission:
n = int(input())
xyh_list = [list(map(int, input().split())) for _ in range(n)]
list_0_100 = [i for i in range(0, 101)]
possible_list = []
for a in range(len(xyh_list)):
    if xyh_list[a][2] != 0:
        x1 = xyh_list[a][0]
        y1 = xyh_list[a][1]
        h1 = xyh_list[a][2]
        break

for cx in list_0_100:
    for cy in list_0_100:
        H = h1 + abs(x1 - cx) + abs(y1 - cy)
        count = 0
        for i in range(n):
            x = xyh_list[i][0]
            y = xyh_list[i][1]
            h = xyh_list[i][2]
            if h == max(H - abs(x - cx) - abs(y - cy), 0):
                count += 1
        if count == n:
            ansx = cx
            ansy = cy
            ansH = H
print(ansx, ansy, ansH)

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh_list = [list(map(int, input().split())) for _ in range(n)]
list_0_100 = [i for i in range(0, 101)]
possible_list = []
for b in range(len(xyh_list)):
    if xyh_list[b][2] != 0:
        x1 = xyh_list[b][0]
        y1 = xyh_list[b][1]
        h1 = xyh_list[b][2]
        break
for a in range(b+1, len(xyh_list)):
    x2 = xyh_list[a][0]
    y2 = xyh_list[a][1]
    h2 = xyh_list[a][2]
    break

for i in list_0_100:
    for j in list_0_100:
        if (h2 + abs(x2 - i) + abs(y2 - j)) == (h1 + abs(x1 - i) + abs(y1 - j)):
            possible_list.append([i, j])   # cx, cy 候補
pos_list = []
h0_list = []
for i in range(n):
    if len(possible_list) == 1:
        break
    x = xyh_list[i][0]
    y = xyh_list[i][1]
    h = xyh_list[i][2]
    if h == 0:
        h0_list.append([x, y])
        pos_list.append([x, y])
        continue
    for j in range(len(possible_list)):
        x_ = possible_list[j][0]
        y_ = possible_list[j][1]
        if (h + abs(x - x_) + abs(y - y_)) == (h2 + abs(x2 - x_) + abs(y2 - y_)):
            pos_list.append([x_, y_])
    possible_list = pos_list
    pos_list = []

for i in range(len(h0_list)):
    h0 = h0_list[i][0]
    h1 = h0_list[i][1]
    for x_, y_ in possible_list:
        if (h2 + abs(x2 - x_) + abs(y2 - y_)) <= (abs(h0 - x_) + abs(h1 - y_)):
            possible_list = [x_, y_]
print(possible_list[0][0], possible_list[0][1], \
      h2 + abs(x2 - possible_list[0][0]) + abs(y2 - possible_list[0][1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh_list = [list(map(int, input().split())) for _ in range(n)]
list_0_100 = [i for i in range(0, 101)]
possible_list = []
for b in range(len(xyh_list)):
    if xyh_list[b][2] != 0:
        x1 = xyh_list[b][0]
        y1 = xyh_list[b][1]
        h1 = xyh_list[b][2]
        break
for a in range(b+1, len(xyh_list)):
    x2 = xyh_list[a][0]
    y2 = xyh_list[a][1]
    h2 = xyh_list[a][2]
    break

for i in list_0_100:
    for j in list_0_100:
        if (h2 + abs(x2 - i) + abs(y2 - j)) == (h1 + abs(x1 - i) + abs(y1 - j)):
            possible_list.append([i, j])   # cx, cy 候補
pos_list = []
h0_list = []
for i in range(n):
    if len(possible_list) == 1:
        break
    x = xyh_list[i][0]
    y = xyh_list[i][1]
    h = xyh_list[i][2]
    if h == 0:
        h0_list.append([x, y])
        continue
    for j in range(len(possible_list)):
        x_ = possible_list[j][0]
        y_ = possible_list[j][1]
        if (h + abs(x - x_) + abs(y - y_)) == (h2 + abs(x2 - x_) + abs(y2 - y_)):
            pos_list.append([x_, y_])
    possible_list = pos_list
    pos_list = []

for i in range(len(h0_list)):
    h0 = h0_list[i][0]
    h1 = h0_list[i][1]
    for x_, y_ in possible_list:
        if (h2 + abs(x2 - x_) + abs(y2 - y_)) <= (abs(h0 - x_) + abs(h1 - y_)):
            possible_list = [x_, y_]
print(possible_list[0][0], possible_list[0][1], \
      h2 + abs(x2 - possible_list[0][0]) + abs(y2 - possible_list[0][1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh_list = [list(map(int, input().split())) for _ in range(n)]
list_0_100 = [i for i in range(0, 101)]
possible_list = []
for i in range(len(xyh_list)):
    if xyh_list[i][2] != 0:
        x1 = xyh_list[i][0]
        y1 = xyh_list[i][1]
        h1 = xyh_list[i][2]
        break
for a in range(i+1, len(xyh_list)):
    x2 = xyh_list[a][0]
    y2 = xyh_list[a][1]
    h2 = xyh_list[a][2]
    break
    
for i in list_0_100:
    for j in list_0_100:
        if (h2 + abs(x2 - i) + abs(y2 - j)) == (h1 + abs(x1 - i) + abs(y1 - j)):
            possible_list.append([i, j])   # cx, cy 候補
pos_list = []
for i in range(a+1, n):
    if len(possible_list) == 1:
        break
    x = xyh_list[i][0]
    y = xyh_list[i][1]
    h = xyh_list[i][2]
    for j in range(len(possible_list)):  
        x_ = possible_list[j][0]
        y_ = possible_list[j][1]
        if (h + abs(x - x_) + abs(y - y_)) == (h2 + abs(x2 - x_) + abs(y2 - y_)):
            pos_list.append([x_, y_])
    possible_list = pos_list
    pos_list = []

print(possible_list[0][0], possible_list[0][1], \
      h2 + abs(x2 - possible_list[0][0]) + abs(y2 - possible_list[0][1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
xyh_list = [list(map(int, input().split())) for _ in range(n)]
list_1_100 = [i for i in range(0, 101)]
possible_list = []

x1 = xyh_list[0][0]
y1 = xyh_list[0][1]
h1 = xyh_list[0][2]
x2 = xyh_list[1][0]
y2 = xyh_list[1][1]
h2 = xyh_list[1][2]
for i in list_1_100:
    for j in list_1_100:
        if (h2 + abs(x2 - i) + abs(y2 - j)) == (h1 + abs(x1 - i) + abs(y1 - j)):
            possible_list.append([i, j])   # cx, cy 候補
pos_list = []
for i in range(2, n):
    if len(possible_list) == 1:
        break
    x = xyh_list[i][0]
    y = xyh_list[i][1]
    h = xyh_list[i][2]
    for j in range(len(possible_list)):  
        x_ = possible_list[j][0]
        y_ = possible_list[j][1]
        if (h + abs(x - x_) + abs(y - y_)) == (h2 + abs(x2 - x_) + abs(y2 - y_)):
            pos_list.append([x_, y_])
    possible_list = pos_list
    pos_list = []

print(possible_list[0][0], possible_list[0][1], h2 + abs(x2 - possible_list[0][0]) + abs(y2 - possible_list[0][1]))