407434: GYM102788 L Fence

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

Description

L. Fencetime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

In a country set among forests, there is a small village consisting of $$$N$$$ houses. The people of this village are mainly engaged in animal husbandry, raising goats and sheep. The village consists of houses of different shapes and sizes. The villagers have only one problem – wolves attacking their livestock. In order to protect their property and provide security, the residents have decided to build a single fence around the village. For the residents it is very important to minimize the length of the fence, thereby reducing the cost of construction. Nevertheless, they want the fence to be at least $$$R$$$ meters away from each house. The shape of house $$$i$$$ is defined by a set of $$$K_i$$$ vertices $$$(a_j, b_j)$$$ of a polygon with real coordinates. Write a program that will compute the minimum length of the fence.

Input

The first line of the input file contains a positive integer $$$N$$$ $$$(1 \leq N \leq 1000)$$$ – the number of houses in the village, and a real number $$$R$$$ $$$(0 \leq R \leq 10^3)$$$ – the distance from the houses to the fence. Next come $$$N$$$ blocks describing each house. In each block, the first line is the number of vertices $$$K_i$$$ $$$(3 \leq K_i \leq 10000, 3 \leq \sum K_i \leq 100000)$$$ of the polygon. The following $$$K_i$$$ rows contain pairs of real numbers $$$a_j$$$ and $$$b_j$$$ $$$(-10^3 \leq a_j, b_j \leq 10^3)$$$, specifying the coordinates of the polygon vertices.

Output

The output file must contain a real number $$$L$$$ accurate to five decimal places – the minimum length of the fence.

ExampleInput
2 1.5
3
1 1
1 2
2 1
4
2 2
2 3
3 3
3 2
Output
16.25321

加入题单

上一题 下一题 算法标签: