402844: GYM100917 K Krotek

Memory Limit:256 MB Time Limit:6 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

K. Krotektime limit per test6 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Mole Krotek from famous Czech animation movie lives underground on 2D-plane on the depth ε .

Soon Krotek dug N tunnels for his new home. Each tunnel is the segment, given by coordinates of the endpoints. Tunnels can intersect each other only in the endpoint they share. No three endpoints are collinear.

Now Krotek wants to link all tunnels to the one network, connecting some of the existing endpoints by the new tunnels. New tunnels can intersect other new tunnels or the existing ones only in the endpoint they share.

Find out minimal total length of the new tunnels.

Input

First line of the input contains one integer N (1 ≤ N ≤ 1000) — number of existing tunnels.

Each of the next N lines contain four integers (x1, y1, x2, y2) — coordinates of the endpoints of the one existing tunnel. Coordinates does not exceed 104 by absolute value.

You may assume that tunnels does not intersect (except for case when they share a endpoint) and that no three endpoints are collinear.

Output

Print the minimum total length of the additional tunnels with absolute or relative error 10 - 6 or less.

ExampleInput
2
0 0 3 0
0 1 1 2
Output
1.0000000000

加入题单

上一题 下一题 算法标签: