View the step-by-step solution to:

# Content -&gt; Connect-the-dots is a new popular game on iPad. At the onset of the game, n random numbers of dot are placed on the screen. The ith dot...

Content： 正體->简体

Connect-the-dots is a new popular game on iPad. At the onset of the game, n random numbers of dot are placed on the screen. The ith dot has the coordinate of (xi, yi). The player must connect all the dots via straight line-segments so that no dot is isolated. The game is scored as follows:
Sum of integral length of edge(i, j) for all line-segments i-j.
The integral length of edge (i, j) is computed as |yi-yj|+|xi-xj|. Write a program to compute and output the minimum possible score.
Input：

First line contains an integer indicating the number of test cases to follow. For each test case, coordinates of random number of dots are given. The coordinate of “-1 -1” indicates the end of a test case. There are can be at most 5000 dots. The coordinates are all positive integer between 0 and 1000.
Output：

For each test case, output the minimum score possible when all the dots are inter-connected.
Sample Input：

1 1 2 2 3 3 -1 -1
0 1 1 0 1 1 0 0 -1 -1
Sample Output ：

4
3

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

### -

Educational Resources
• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents