Looks like there is an error in the task validation. I used iterative algorithm to find the optimal solution, so it is hard to make a mistake there. So let's take a look on the data of the test case #7. I found houses with the same X value and reduced the search range between Y values of the houses. In the next lines we have 2 houses with X values and the search interval from min Y to max Y, let's name variables as
(xi, yi) (xj, yj) y0 y1:
(-12.0, 37.0) (-12.0, -8.0) -8.0 37.0
( 44.0, 3.0) ( 44.0, -58.0) -8.0 3.0
(-19.0, 18.0) (-19.0, 1.0) 1.0 3.0
y0 < min(yi,yj) < y1 then we update
y0 < max(yi,yj) < y1 we update
So in the example above the search interval converges to
[1.0, 3.0]. In the whole test, final search range is
[1.0,1.0], but optimal solution is at
0, which means there are at least two houses that are connected to the main cable with a single cable.
My algorithm (without search range narrowing) passes all the IDE's test cases and all validation tests except for the last one.