Algorithm title: UVA 10911 Forming quiz Teams (DP + set optimal pairing problem)

Source: Internet
Author: User

You are have been given the job of forming quiz teams for the next ' MCA CPCI quiz '. There Are2*n students interested to participate and your have to form N teams, the each team consisting the two members. Since the members of the have to practice together and all the students want the their member's house as near. Let X1 is the distance between the houses of group 1, x2 be the distance between the houses of Group 2 and. You are X2 have to make sure the summation (x1 + x3 + xn + ... + minimized) is.

Input

There is many cases in the input file. Each case is starts with an integer N (n≤8). The next 2*nlines would given the information of the students. Each line starts with the student ' s name, followed by Thex coordinate and then the Y coordinate. Both x, y are integers in the range 0 to 1000. Students name would consist of lowercase letters only and the length would be at most 20.

The Input is terminated by a case where N is equal to 0.

Output

For each case, output is followed by the summation of the distances and rounded to 2 decimal places. Follow the sample for exact format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.