Hasan and Points Pairing

4.2

34 votes
Basic Programming, Medium, Ready
Problem

Hasan is feeling bored since he has been studying for his physics exam all day, that's why he started to do random stuff, he drew 2*N points on piece of paper, coordinates of i-th point is (Xi, Yi) and now he is wondering how to connect the points with N segments of minimum possible sum of lengths such that:

  • No two segments intersect.
  • And each point is an endpoint of exactly one segment .

(Yes, studying for exams made Hasan bored enough to wonder about weird questions) Help Hasan by answering his question so that he can continue to study for his exam.

Input format:

First line contain one integer N.
Next 2*N lines contains two integers each, i-th line contains coordinates of i-th point Xi and Yi.

Output format:

Output one number, the minimum sum of lengths of non-intersecting segments rounded to exactly 6 digits after floating point.

Constraints:

  • 1<= N <= 8
  • 0 <= Xi, Yi <= 1,000
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?