#P12628. [NAC 2025] Polygon Partition
[NAC 2025] Polygon Partition
题目描述
A simple polygon is a polygon that is not self-intersecting and does not contain any holes. You are given the vertices of a simple polygon, , , , , where , and and are the -coordinate and -coordinate of the vertex, respectively. The vertices are distinct and given in counterclockwise order (so there is an edge between each pair of consecutive vertices; there is also an edge from back to ).
The polygon's boundary does not pass through any lattice points (a lattice point is a point where both coordinates are integers). In addition, none of the or values are exactly an integer.
A semi-integer point is a point where exactly one of its coordinates is an integer. Let be all of the semi-integer points that lie on the boundary of the polygon. For each semi-integer point in , let be the floor of the non-integer coordinate of . For a subset of , let be the sum of the of the points in (with ). Does there exist a partition of into two subsets and so that the ?
(Two sets and are a partition of if and . There are no other restrictions on and so long as these two conditions hold and . In particular, empty sets are allowed, and the semi-integer points in each set do not have to be contiguous around the polygon boundary.)
输入格式
The first line of input contains one integer (), the number of vertices of the polygon.
Each of the next lines contains two space-separated real numbers and (): the coordinates of the polygon vertices, in counterclockwise order. Each coordinate will have exactly digits after the decimal point and will not be exactly an integer.
It is guaranteed that the polygon does not self-intersect, that the vertices are distinct, and that the polygon boundary does not pass through any lattice points.
输出格式
If there is no solution, print and no further output.
Otherwise, print a single integer on its own line: the number of semi-integer points in one of the two subsets in a valid partition of . On the next lines of output, print the values for the points in that subset, one per line.
If there are multiple valid partitions, you may choose any of them. You may print either of its two subsets, and you may list the subset's values in any order.
4
-0.950000 -0.850000
-0.100000 0.999999
0.111000 0.555000
-0.200000 1.600000
3
0
-1
-1
3
0.500000 0.700000
0.100000 0.200000
0.800000 0.900000
0
4
-360.000001 -24.000001
-359.999999 -24.000001
-359.999999 -23.999999
-360.000001 -23.999999
2
-25
-360
提示
Sample Input 1 is shown in the image below:
The points of the vertices are labeled . The semi-integer points are marked in orange and labeled going counterclockwise around the perimeter starting from . The values of the semi-integer points are, in the same order, . Any subset of those values that sum to would be accepted as correct. Sample Output 1 shows one possible correct answer.
The boundary of the polygon in Sample Input 2 does not intersect any semi-integer points, so is empty, and it can be partitioned into two empty sets each with sum of zero.