Distinct Distances: Difference between revisions

From programming_contest
Jump to navigation Jump to search
imported>Kmk21
Created page with "This problem gives us a set of points and asks for the point such that the number of unique distances between the point and any in the original set is minimized. The input si..."
 
imported>Kmk21
No edit summary
 
Line 20: Line 20:
[[Category:Geometry]]
[[Category:Geometry]]
[[Category:Brute Force]]
[[Category:Brute Force]]
[[Category:Rational Math]]

Latest revision as of 22:39, 29 December 2017

This problem gives us a set of points and asks for the point such that the number of unique distances between the point and any in the original set is minimized.

The input size of 40 indicates there is likely some brute force component.

Intuitively, between any 2 points, the points that are equidistant are located on perpendicular bisector on the segment between the two points.

We only have 40 points, so 40^2 lines, so 40^4=2.5 million intersections. Evaluate each intersection point against all points and count the unique distances.

Note: corner case if two lines are colinear, can select any point on the two lines, but easier to just add midpoint between any two points to candidate set Note: Can't simply find "point with most line intersections" since would have to do a lot of math to figure out if distances were the same and if points were shared between the two lines. May be possible....but harder and same runtime complexity.

The "challenge" here is they expect exact arithmetic....so you have to store every value as a/b and do the math accordingly.