Problem p03240 (python)

Fixed submission:
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
ansx = 0
ansy = 0
ansh = 0
for x in range(101):
  for y in range(101):
    hset = set()
    for i in range(N):
      xyhi = xyh[i]
      if xyhi[2] == 0:
        continue
      hset.add(abs(xyhi[0]-x) + abs(xyhi[1]-y) + xyhi[2])

    if len(hset) == 1 and list(hset)[0] != 0:
      flag = True
      for i in range(N):
        xyhi = xyh[i]
        if xyhi[2] != 0:
          continue
        elif xyhi[2] == 0 and max(list(hset)[0] - abs(xyhi[0]-x) - abs(xyhi[1]-y), 0) == 0:
          continue
        flag = False
        break
      if flag:
        ansx = x
        ansy = y
        ansh = list(hset)[0]

print(ansx, ansy, ansh)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = [0 for i in range(N)]
Y = [0 for i in range(N)]
H = [0 for i in range(N)]
tmp = []
for i in range(N):
    X[i], Y[i], H[i] = map(int, input().split())
for cx in range(0,101):
    for cy in range(0, 101):
        for i in range(N):
            if h != 0:
                ch = abs(X[i]-cx) + abs(Y[i]-cy) + H[i]
                tmp.add([cx, cy, ch])
for x, y, h in tmp:
    flag = True
    for i in range(N):
        if H[i] != max(h - abs(X[i]-x) - abs(Y[i]-y), 0)
            flag = False
            break
    if flag:
        print(x, y, h)
        break

Buggy submission (verdict: Runtime Error):
N = int(input())
X = [0 for i in range(N)]
Y = [0 for i in range(N)]
H = [0 for i in range(N)]
tmp = []
for i in range(N):
    X[i], Y[i], H[i] = map(int, input().split())
for cx in range(0,101):
    for cy in range(0, 101):
        for i in range(N):
            if h != 0:
                ch = abs(X[i]-cx) + abs(Y[i]-cy) + H[i]
                tmp.add([cx, cy, ch])
for x, y, h in tmp:
    flag = True
    for i in range(N):
        if H[i] != max(h - abs(X[i]-cx) - abs(Y[i]-cy), 0)
            flag = False
            break
    if flag:
        print(x, y, h)
        break

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = set()
for i in range(N):
    tmp = set()
    x, y, h = map(int, input().split())
    for cx in range(0,101):
        for cy in range(0, 101):
            ch = abs(x-cx) + abs(y-cy) + h
            if ch < 1 or (ch < 1 and h == 0):
                continue
            tmp.add((cx, cy, ch))
    if tmp == set():
        continue
    elif ans == set():
        ans = tmp
        continue
    ans = ans & tmp
ans = list(ans)[0]
print(ans[0], ans[1], ans[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = set()
for i in range(N):
    tmp = set()
    x, y, h = map(int, input().split())
    for cx in range(0,101):
        for cy in range(0, 101):
            ch = abs(x-cx) + abs(y-cy) + h
            if ch < 1:
                continue
            tmp.add((cx, cy, ch))
    if ans == set():
        ans = tmp
        continue
    elif tmp == set():
        continue
    ans = ans & tmp
ans = list(ans)[0]
print(ans[0], ans[1], ans[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = set()
for i in range(N):
    tmp = set()
    x, y, h = map(int, input().split())
    for cx in range(0,101):
        for cy in range(0, 101):
            ch = abs(x-cx) + abs(y-cy) + h
            if ch < 1:
                continue
            tmp.add((cx, cy, ch))
    if i == 0:
        ans = tmp
        continue
    elif tmp == set():
        continue
    ans = ans & tmp
ans = list(ans)[0]
print(ans[0], ans[1], ans[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = set()
for i in range(N):
    tmp = set()
    x, y, h = map(int, input().split())
    for cx in range(0,101):
        for cy in range(0, 101):
            ch = abs(x-cx) + abs(y-cy) + h
            if ch < 1:
                continue
            tmp.add((cx, cy, ch))
    if i == 0:
        ans = tmp
        continue
    # elif tmp == set():
    #     continue
    ans = ans & tmp
ans = list(ans)[0]
print(ans[0], ans[1], ans[2])