Problem p03240 (python)

Fixed submission:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[]
for i in range(n):
  x,y,h=nii()
  l.append([x,y,h])
  if h!=0:
    ini_x=x
    ini_y=y
    ini_h=h

for tx in range(101):
  for ty in range(101):
    n_h=abs(tx-ini_x)+abs(ty-ini_y)+ini_h
    for x,y,h in l:
      t_h=max(n_h-(abs(tx-x)+abs(ty-y)),0)
      if h!=t_h:
        break
    else:
      print(tx,ty,n_h)
      exit()

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[]
for i in range(n):
  x,y,h=nii()
  l.append([x,y,h])
  if h!=0:
    ini_x=x
    ini_y=y
    ini_h=h

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    n_h=abs(tx-ini_x)+abs(ty-ini_y)+ini_h
    for x,y,h in l:
      t_h=max(abs(tx-x)+abs(ty-y)+h,0)
      if n_h!=t_h:
        break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      if [tx,ty,0] in l:
        ans_h.append(0)
      else:
        ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[]
for i in range(n):
  x,y,h=nii()
  l.append([x,y,h])
  if h!=0:
    ini_x=x
    ini_y=y
    ini_h=h

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    n_h=abs(tx-ini_x)+abs(ty-ini_y)+ini_h
    for x,y,h in l:
      t_h=abs(tx-x)+abs(ty-y)+h
      if n_h!=t_h:
        break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      if [tx,ty,0] in l:
        ans_h.append(0)
      else:
        ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[lnii() for i in range(n)]

if n==1:
  print(*l[0])
  exit()

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    t_h=-1
    for x,y,h in l:
      dist=abs(tx-x)+abs(ty-y)
      if t_h==-1:
        t_h=h+dist
      else:
        if t_h!=h+dist:
          break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[lnii() for i in range(n)]

if n==1:
  print(*l[0])
  exit()

ans_x=[]
ans_y=[]
ans_h=[]

for tx in range(101):
  for ty in range(101):
    t_h=0
    for x,y,h in l:
      dist=abs(tx-x)+abs(ty-y)
      if t_h==0:
        t_h=h+dist
      else:
        if t_h!=h+dist:
          break
    else:
      ans_x.append(tx)
      ans_y.append(ty)
      ans_h.append(t_h)

inx=ans_h.index(max(ans_h))
print(ans_x[inx],ans_y[inx],ans_h[inx])

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
l=[lnii() for i in range(n)]

for tx in range(101):
  for ty in range(101):
    t_h=0
    for x,y,h in l:
      dist=abs(tx-x)+abs(ty-y)
      if t_h==0:
        t_h=h+dist
      else:
        if t_h!=h+dist:
          break
    else:
      ans_x=tx
      ans_y=ty
      ans_h=t_h
      break

print(ans_x,ans_y,ans_h)