Problem p03240 (python)

Fixed submission:
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())
  if h[n] > 0:
    hi = n

def g(xx, yy, height):
  for n in range(N):
    if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) != h[n]:
      return False
  return True

def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[hi])+abs(yy-y[hi])+h[hi]
      if g(xx, yy, height) is True:
        return [xx, yy, height]
print(*f())

Buggy submission (verdict: Runtime Error):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())


def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[0])+abs(yy-y[0])+h[0]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) != h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Buggy submission (verdict: Runtime Error):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())


def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[0])+abs(yy-y[0])+h[0]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) is not h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Buggy submission (verdict: Runtime Error):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
hi = 0
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())
  if h[n] > 0:
    hi = n

def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[hi])+abs(yy-y[hi])+h[hi]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) is not h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Buggy submission (verdict: Runtime Error):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())
  if h[n] > 0:
    hi = n

def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[hi])+abs(yy-y[hi])+h[hi]
      flag = 1
      for n in range(N):
        if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) is not h[n]:
          flag = 0
      if flag == 1:
        return [xx, yy, height]
print(*f())

Buggy submission (verdict: Runtime Error):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())

def f():
  for xx in range(101):
    for yy in range(101):
      height = []
      for n in range(N):
        height.append(abs(x[n]-xx)+abs(y[n]-yy)+h[n])
      if len(set(height)) == 1:
        return [xx, yy, height[0]]
print(*f())

Buggy submission (verdict: Runtime Error):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())

def f():
  for xx in range(101):
    for yy in range(101):
      height = [-1 for _ in range(N)]
      for n in range(N):
        height[n]= abs(x[n]-xx)+abs(y[n]-yy)+h[n]
        if set(height[:n+1]) == {}:
          break
      if len(set(height)) == 1:
        return [xx, yy, height[0]]
print(*f())

Buggy submission (verdict: Runtime Error):
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())

def f():
  for xx in range(101):
    for yy in range(101):
      height = [0 for _ in range(N)]
      for n in range(N):
        height[n]= abs(x[n]-xx)+abs(y[n]-yy)+h[n]
      if len(set(height)) == 1:
        return [xx, yy,height[0]]
print(*f())