Problem p03240 (python)

Fixed submission:
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
cnt=0
for m in range(n):
  if x[m][2]>0:
    cnt+=1
    ii=m
    
#print(ii,cnt)

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

for i in range(101):
  for j in range(101):
    flag=0
    for k in range(n):
      if x[k][2]>0:
        if hight(i,j,x[ii][0],x[ii][1],x[ii][2])==hight(i,j,x[k][0],x[k][1],x[k][2]):
          flag+=1
      else:
        if hight(i,j,x[ii][0],x[ii][1],x[ii][2]) > hight(i,j,x[k][0],x[k][1],x[k][2]):
          flag=0
     
    if flag==cnt:
      ans1=i
      ans2=j
      ans3=hight(i,j,x[ii][0],x[ii][1],x[ii][2])
      
print(ans1,ans2,ans3)
#print(flag)

Buggy submission (verdict: Runtime Error):
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
for i in range(n):
  if x[i][2]> 0:
    y=x

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,y[0][0],y[0][1],y[0][2])==hight(k,l,y[i][0],y[i][1],y[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,y[0][0],y[0][1],y[0][2])

print(ans1,ans2,ans3)

Buggy submission (verdict: Runtime Error):
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
for i in range(n):
  if x[i][2]> 0:
    y=x

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[0][0],x[0][1],x[0][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[0][0],x[0][1],x[0][2])

print(ans1,ans2,ans3)

Buggy submission (verdict: Runtime Error):
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)

x.reverse()

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[0][0],x[0][1],x[0][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[0][0],x[0][1],x[0][2])

print(ans1,ans2,ans3)

Buggy submission (verdict: Runtime Error):
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[-1][0],x[-1][1],x[-1][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[-1][0],x[-1][1],x[-1][2])

print(ans1,ans2,ans3)

Buggy submission (verdict: Runtime Error):
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
      
#print(x)

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[0][0],x[0][1],x[0][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[0][0],x[0][1],x[0][2])

print(ans1,ans2,ans3)