Problem p03240 (python)

Fixed submission:
N = int(input())

x_list=[]
y_list=[]
h_list=[]


def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)
		
for cy in range(101):
	for cx in range(101):
		n = -1	
		for h in h_list:
			n += 1
			if h >= 1:
				H = abs(cx - x_list[n])+abs(cy - y_list[n])+h
				h_now_list=[]
				break
		for i in range(N):
			h_now = max((H-abs(cx - x_list[i])-abs(cy - y_list[i])), 0)
			h_now_list.append(h_now)
			if h_now != h_list[i]:
				break	
			else:
				if len(h_now_list)==N:
					print(str(cx)+' '+str(cy)+' '+str(H))
					break
	else:
		continue
	break

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

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)
		
for cy in range(101):
	for cx in range(101):
		i = -1	
		for h in h_list:
			i += 1
			if h >= 1:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				break
		for i in range(N):
			h = max(H-abs(cx - x_list[i])-abs(cy - y_list[i]), 0)
			H_list.append(h) 
		if all_same(H_list):
			print(str(cx)+' '+str(cy)+' '+str(H))
			break		
	else:
		continue
	break

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

x_list=[]
y_list=[]
h_list=[]

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)

i = -1	
for h in h_list:
	i += 1
	if h >= 1:
		H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
		break
		
for cy in range(101):
	for cx in range(101):
		for i in range(N):
			h = max(H-abs(cx - x_list[i])-abs(cy - y_list[i]), 0)
			H_list.append(h) 
			if h != H:
				break 
		if len(H_list) == N:
			print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
			break		
	else:
		continue
	break

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

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)
	
if h_list[0] == 0:
	h_list[0], h_list[1]=h_list[1], h_list[0]	
	x_list[0], x_list[1]=x_list[1], x_list[0]
	y_list[0], y_list[1]=y_list[1], y_list[0]		
		
for cy in range(101):
	for cx in range(101):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				h_mathematical=H_list[0]-abs(cx-x_list[i])-abs(cy-y_list[i])
				if h_mathematical > 0:
					break 
		if len(H_list) == N:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

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

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(101):
	for cx in range(101):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				h_mathematical=H_list[0]-abs(cx-x_list[i])-abs(cy-y_list[i])
				if h_mathematical > 0:
					break
		if len(H_list) == N:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

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

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(101):
	for cx in range(101):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				h_mathematical=H_list[0]-abs(cx-x)-abs(cy-y)
				if h_mathematical > 0:
					break
		if len(H_list) == N:
			if all_same(H_list):
				print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
				break		
	else:
		continue
	break

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

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(N+1):
	for cx in range(N+1):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h_list[i]
				H_list.append(H) 
			if h_list[i] == 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				if H > 0:
					break
		if all_same(H_list):
			print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
			break		
	else:
		continue
	break

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

x_list=[]
y_list=[]
h_list=[]

def all_same(items):
	return all(map(lambda x: x == items[0], items))

for i in range(N):
	x,y,h=map(int, input().split())
	x_list.append(x)
	y_list.append(y)
	h_list.append(h)	
		
for cy in range(N+1):
	for cx in range(N+1):
		H_list = []
		for i in range(N):
			if h_list[i] != 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				H_list.append(H) 
			if h_list[i] == 0:
				H = abs(cx - x_list[i])+abs(cy - y_list[i])+h
				if H > 0:
					break
		if all_same(H_list):
			print(str(cx)+' '+str(cy)+' '+str(H_list[0]))
			break