1996. Wind Passages

单点时限: 5.0 sec

内存限制: 256 MB

Wind Corridor is a covered passageway where strong wind is always blowing. It is a long corridor of width $W$, and there are several pillars in it. Each pillar is a right prism and its face is a polygon (not necessarily convex).

In this problem, we consider two-dimensional space where the positive $x$-axis points the east and the positive $y$-axis points the north. The passageway spans from the south to the north, and its length is infinity. Specifically, it covers the area $0 \le x \le W$. The outside of the passageway is filled with walls. Each pillar is expressed as a polygon, and all the pillars are located within the corridor without conflicting or touching each other.

Wind blows from the south side of the corridor to the north. For each second, $w$ unit volume of air can be flowed at most if the minimum width of the path of the wind is $w$. Note that the path may fork and merge, but never overlaps with pillars and walls.

Your task in this problem is to write a program that calculates the maximum amount of air that can be flowed through the corridor per second.

输入格式

The first line of the input contains two integers $W$ and $N$. $W$ is the width of the corridor, and $N$ is the number of pillars. $W$ and $N$ satisfy the following condition: $2 \le W \le 10^4$ and $0 \le N \le 200$.

Then, $N$ specifications of each pillar follow. Each specification starts with a line that contains a single integer $M$, which is the number of the vertices of a polygon ($3 \le M \le 40$). The following $M$ lines describe the shape of the polygon. The $i$-th line ($1 \le i \le M$) contains two integers $x_i$ and $y_i$ that denote the coordinate of the $i$-th vertex ($0 < x_i < W, 0 < y_i < 10^4$).

输出格式

Your program should print a line that contains the maximum amount of air flow per second, in unit volume. The output may contain arbitrary number of digits after the decimal point, but the absolute error must not exceed $10^{-6}$.

样例

Input
5 2
4
1 1
1 2
2 2
2 1
4
3 3
3 4
4 4
4 3
Output
3.41421356

2 人解决,2 人已尝试。

2 份提交通过,共有 26 份提交。

8.5 EMB 奖励。

创建: 14 年前.

修改: 6 年,4 月前.

最后提交: 3 年,5 月前.

来源: Japan

题目标签