Build a Boat
Time limit2sMemory limit512 MB
Split a simple polygon into the largest number of equal-area vertical sections, each of area at least C, and print the bulkhead x-coordinates.
- Level
Medium7 of 10
- Topics
- Geometry, Prefix sum, Binary search
- Solved
- No attempts yet
Problem
A modern ship survives a collision because of its bulkheads, reinforced vertical walls inside the hull that keep water that has come in from spreading to other sections.
A design team finished the outline of the cross section of a new ship and left the bulkheads out. Placing them is your job.
The cross section is a simple polygon. A bulkhead is a vertical segment that cuts the whole cross section at one x-coordinate, so a set of bulkheads splits the cross section into vertical sections. Every section must have the same area, and that area must be at least .
Find the largest number of sections that can be made this way, then report where the bulkheads go.
Input
The first line has an integer (), the minimum area of one section.
The second line has an integer (), the number of vertices of the outline.
Each of the next lines has two integers and (), the coordinates of one vertex of the hull. The vertices come in counter-clockwise order.
The outline never doubles back on itself horizontally. A vertical line drawn anywhere passes through the cross section exactly once, never twice.
One section of area always fits, and the number of sections is between 1 and 100.
Output
On the first line print , the largest number of sections of equal area whose common area is at least .
Then print lines. Line holds the x-coordinate of the -th bulkhead, placed so that all sections have the same area. Print the coordinates in increasing order, each with exactly six digits after the decimal point.