#P2745. [USACO5.3] 窗体面积Window Area

[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 55 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 600600 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).

II 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)(x,y) and (X,Y)(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., xXx \ne X and yYy \ne Y). The xx- and yy-coordinates are in the range [1,2151][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 500500). 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 %).

w(a,10,132,20,12)
w(b,8,76,124,15)
s(a)
49.167

Hint

Translation from NOCOW.

USACO Training Section 5.3.

Translated by ChatGPT 5