4th Balkan Olympiad in Informatics
Nicosia, Cyprus, 19-25 October 1997


Day 2 - Problem 3 (Windows in a graphical user interface)



A common operation in graphical environments is the handling of overlapping windows. Only the exposed portions of a window are displayed, with special routines written to determine what portions of a window are exposed, and should be dealt with. Your task is to take a list of windows, do the appropriate manipulations, and, upon request, indicate the exposed area of a given window.


Input:
The program reads the input file INPUT.TXT as a series of one instruction per line in the following format:
w(I,X,Y,x,y)
t(I)
b(I)
e(I)
s(I)
In the above input 'w', 't', 'b', 'e', 's' are the commands manipulating the windows. The rest of the information represent the following data:

  • I is a windows id. The windows identifiers will be single characters in the range: abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+ As the identifiers are unique, it will not be possible to have two windows with the same id, open at the same moment. There will be no more than 64 windows opened at any one time.
  • X and Y are the upper left-hand coordinates of the window.
  • x and y are the lower right-hand coordinates of the window. It is assumed that in order to perform an operation on a given window, this specific window must have been created before with the 'w' command.


Explanation of window-commands :

  • 'w': creates a window with the appropriate id, size and location. A newly created window is created on top of all existing windows.
  • 't': brings the indicated window on the top of all other windows.
  • 'e': erases the indicated window from the screen.
  • 'b': puts the indicated window below all other windows.
  • 's': shows the percentage of indicated window's exposed area, printed as a real number followed by a new line.



Output:
The output file of the program OUTPUT.TXT will simply be responses to the 's' commands. For each 's' command found and processed in the input file, one output line is generated that shows in a percentage the exposed area of the indicated window.

Example:

  • Input:
    w(a,10,132,20,12)
    w(c,12,120,22,16)
    w(b,8,16,124,15)
    t(a)
    w(d,18,93,102,20)
    b(b)
    b(a)
    s(a)
    s(b)
    s(c)
    s(d)
    e(d)
    e(c)
    s(a)
    s(b)
  • Output:
    29.83%
    100.00%
    71.92%
    100.00%
    99.17%
    100.00%


Limits
The screen that all windows will be displayed on will not exceed 250x250. The thickness of windows boundaries is negligible (i.e. w(a,0,4,4,0) is a window of area 16).

Note:
Correct output values will be considered those with 0.02% deviation from the indicate value in the output (i.e. for 29.83% the percentages 29.81%, 29.82%, 29.84% and 29.85% will be consider correct).




Time limit per test : 5 seconds
Maximum Score : 30