Cutting
Time limit0.5sMemory limit1024 MB
Each request cuts a V-shaped wedge upward from a lattice point, and the task is to print the remaining area after every cut.
- Level
Medium6 of 10
- Topics
- Geometry, Binary search, Implementation
- Solved
- No attempts yet
Problem
You have a rectangular sheet of paper with dimensions centimeters. The sheet is divided into a net of centimeter squares. Treat the sheet as a coordinate system whose origin is the lower left corner. Each vertex of a square has integer coordinates: between 0 and on the x axis and between 0 and on the y axis.
You receive a sequence of requests to cut the piece of paper that remains. Each request is a pair of nonnegative integers , a vertex of the net that lies in the uncut portion of the paper. Cutting works as follows. Two segments start at . One is at an angle of 45 degrees to the x axis, and the other is at an angle of 135 degrees. Both point upwards, that is, with increasing y. Both segments end at the border of the sheet. The portion of the paper above the drawn segments is cut off, and the rest remains as the new figure.

One of the segments may have length 0. This happens when the point lies on the leftmost or rightmost border of the rectangle. Each request is guaranteed to cut off a figure with positive area.
Input
The first line contains two positive integers and , the dimensions of the initial sheet.
The second line contains a positive integer , the number of cutting requests.
Each of the next lines contains two nonnegative integers and , separated by a space. These are the coordinates of the point that defines a request.
Output
For each request, print the area of the remaining figure on a separate line. Print the area with exactly two digits after the decimal point.
Constraints