当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2747:Shy Polygons

Special Judge 特殊评判
题目描述
You are given two solid polygons and their positions on the xy-plane. You can move one of the two along the x-axis (they can overlap during the move). You cannot move it in other directions. The goal is to place them as compactly as possible, subject to the following condition: the distance between any point in one polygon and any point in the other must not be smaller than a given minimum distance L.
We define the width of a placement as the difference between the maximum and the minimum x-coordinates of all points in the two polygons.
Your job is to write a program to calculate the minimum width of placements satisfying the above condition.
Let's see an example. If the polygons in Figure 13 are placed with L = 10.0, the result will be 100. Figure 14 shows one of the optimal placements.
输入解释
The input consists of multiple datasets. Each dataset is given in the following format.
L
Polygon1
Polygon2

L is a decimal fraction, which means the required distance of two polygons. L is greater than 0.1 and less than 50.0.
The format of each polygon is as follows.
n
x1 y1
x2 y2
...
xn yn
n is a positive integer, which represents the number of vertices of the polygon. n is greater than 2 and less than 15.
Remaining lines represent the vertices of the polygon. A vertex data line has a pair of nonnegative integers which represent the x- and y-coordinates of a vertex. x- and y-coordinates are separated by a single space, and y-coordinate is immediately followed by a newline. x and y are less than 500.
Edges of the polygon connect vertices given in two adjacent vertex data lines, and vertices given in the last and the first vertex data lines. You may assume that the vertices are given in the counterclockwise order, and the contours of polygons are simple, i.e. they do not cross nor touch themselves.
Also, you may assume that the result is not sensitive to errors. In concrete terms, for a given pair of polygons, the minimum width is a function of the given minimum distance l. Let us denote the function w(l). Then you can assume that |w(L±10-7)-w(L)| < 10-4.
The end of the input is indicated by a line that only contains a zero. It is not a part of a dataset.
输出解释
The output should consist of a series of lines each containing a single decimal fraction. Each number should indicate the minimum width for the corresponding dataset. The answer should not have an error greater than 0.0001. You may output any number of digits after the decimal point, provided that the above accuracy condition is satisfied.
输入样例
10.5235
3
0 0
100 100
0 100
4
0 50
20 50
20 80
0 80
10.0
4
120 45
140 35
140 65
120 55
8
0 0
100 0
100 100
0 100
0 55
80 90
80 10
0 45
10.0
3
0 0
1 0
0 1
3
0 100
1 101
0 101
10.0
3
0 0
1 0
0 100
3
0 50
100 50
0 51
0
输出样例
114.882476
100
1
110.5005

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Japan 2005

源链接: POJ-2747

最后修改于 2020-10-29T06:41:32+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536