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

建议使用的浏览器:

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

3788:Interior Points of Lattice Polygons

题目描述
A lattice point is a point with integer coordinates. A lattice polygon is a polygon with all vertices lattice points.



The lattice points on the boundary of the polygon are boundary points (open dots in the figure above) and the points inside and not on the polygon are interior points (filled in dots in the figure above).

A polygon is convex if any line segment between two points of the polygon is inside (or on the boundary of) the polygon. Equivalently, the interior angle at each polygon vertex is less than 180 degrees. Note that any line between two points inside (and not on the boundary of) the polygon is entirely inside (and not on the boundary of) the polygon.

The interior points of a convex lattice polygon on any horizontal line form a single segment from a leftmost point to a rightmost point (which may be the same). Note that there may be no interior points (A), or only one (B), or isolated points (C) as shown in the figures below.



Write a program that reads the vertices of a convex lattice polygon in standard order and outputs the interior points as a list of horizontal line segments. The vertices of a lattice polygon are in standard order if:
a) The first vertex is the one with the largest y value. If two vertices have the same y value, the one with the smaller x value is the first.
b) Vertices are given in clockwise order around the polygon.
输入解释
The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. The first line of each data set contains the data set number, followed by a space, followed by a decimal integer giving the number vertices N, (3 ≤ N ≤ 50), of the polygon. The remaining lines in the data set contain the vertices, one per line in standard order. Each line contains the decimal integer x coordinate, a space and the decimal integer y coordinate.
输出解释
For each data set there are multiple lines of output. The first line contains a decimal integer giving the data set number followed by a single space, followed by a decimal integer giving the number of horizontal lines which contain interior points (this may be zero (0) or more). The lines of interior points, if any, follow, one per line in order of decreasing y value. Each line contains the decimal integer y coordinate, a single space and the decimal integer x coordinate of the left most point, a single space and the decimal integer x coordinate of the right most point.
输入样例
6 
1 8 
5 10 
8 9 
11 6 
10 2 
6 0 
1 1 
0 4 
2 8 
2 4 
3 10 
13 7 
10 -3 
0 0 
3 3 
1 3 
3 1 
1 1 
4 3 
1 4 
4 1 
1 1 
5 4 
0 6 
2 3 
3 0 
1 3 
6 6 
1 3 
3 3 
4 2 
3 1 
1 1 
0 2
输出样例
1 9
9 4 7
8 3 8
7 2 9 
6 2 10 
5 1 10 
4 1 10 
3 1 10 
2 1 9 
1 2 7 
2 12 
9 3 6 
8 3 9 
7 3 12 
6 2 12 
5 2 12 
4 2 12 
3 1 11 
2 1 11 
1 1 11 
0 1 10 
-1 4 10 
-2 7 10 
3 0 
4 1 
2 2 2 
5 2 
4 1 1 
2 2 2 
6 1 
2 1 3

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

源链接: POJ-3788

最后修改于 2020-10-29T07:11:23+00:00 由爬虫自动更新

共提交 0

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