P2745 [USACO5.3] Window Area

Description

You have just taken over a window system project. The window system is fairly simple, and fortunately, you do not have to display the actual windows. There are $5$ basic operations: - Create a new window. - Bring a window to the top. - Send a window to the bottom. - Delete a window. - Output the percentage of the window that is visible (i.e., not covered by other windows).

Input Format

In the input file, operations (no more than $600$ of them) appear one per line in the following formats: - Create a new window: `w(I,x,y,X,Y)`. - Bring a window to the top: `t(I)`. - Send a window to the bottom: `b(I)`. - Delete a window: `d(I)`. - Output the percentage of the window that is visible: `s(I)`. $I$ is the unique identifier of each window. An identifier is a letter (uppercase or lowercase) or a single digit. There are no extra spaces in the input file. $(x,y)$ and $(X,Y)$ are opposite corners of the window. When you create a window, it is automatically placed on the top. You cannot create a window using an existing identifier, but after deleting a window you may reuse its identifier. Coordinates are positive integers, and every window has nonzero area (i.e., $x \ne X$ and $y \ne Y$). The $x$- and $y$-coordinates are in the range $[1,2^{15}-1]$. Stop processing at end of file.

Output Format

Produce output only for the `s(I)` commands. There may be many `s(I)` commands (no more than $500$). Output a sequence of percentages, one per line, each being the percentage of the window that is visible. Percentages must be rounded to three decimal places (do not print the percent sign `%`).

Explanation/Hint

Translation from NOCOW. USACO Training Section 5.3. Translated by ChatGPT 5