#P2745. Window Manager Simulation

    ID: 16008 Type: Default 1000ms 256MiB

Window Manager Simulation

Window Manager Simulation

You are given a series of operations on windows in a 2D coordinate system. Each window is a rectangle, and the operations simulate window creation, reordering, deletion and querying the visible area percentage of a window. A window is defined by its two diagonal corners (x,y) and (X,Y) (with positive integer coordinates in the range 1 to 32767). The area of each window is nonzero (i.e. x ≠ X and y ≠ Y). Windows have unique identifiers which can be any character from the set {a-z, A-Z, 0-9}. When a window is created it is automatically placed on top.

There are 5 types of operations, provided in the input file with no extra spaces:

  • 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 visible area percentage of a window: s(I)

Here, I is the unique identifier for each window. For a query s(I), the visible area percentage is defined as follows:

$$\text{Visible Percentage} = \frac{\text{Visible Area of window } I}{\text{Total Area of window } I} \times 100 $$

The visible area of a window is the area not covered by any windows that are above it in the stacking order. The stacking order is maintained as windows are created or reordered.

inputFormat

The input contains a series of operations (at most 600), one per line. The operations are one of the following:

  • w(I,x,y,X,Y): Create a new window with identifier I and diagonal coordinates (x,y) and (X,Y).
  • t(I): Bring window I to the top.
  • b(I): Send window I to the bottom.
  • d(I): Delete window I.
  • s(I): Output the visible area percentage of window I.

There are no extra spaces in the input.

outputFormat

For each s(I) operation in the input, print a line containing the visible percentage of window I, rounded to 3 decimal places.

sample

w(a,1,1,11,11)
s(a)
100.000