#P6425. Mirko's Rubber Band Game

    ID: 19639 Type: Default 1000ms 256MiB

Mirko's Rubber Band Game

Mirko's Rubber Band Game

Mirko found a board and n nails in his attic. He hammered the nails into the board, then scattered an elastic hairband over them. When released, the band tightened naturally around the nails, outlining the minimum convex polygon (convex hull) that encloses all of the nails.

To entertain himself, Mirko repeatedly performed the following steps while there were at least three nails on the board:

  1. Record the area enclosed by the hairband. (The area is computed by the formula \( A = \frac{1}{2} \left| \sum_{i=0}^{k-1} (x_i y_{i+1} - y_i x_{i+1}) \right| \), where the vertices \( (x_i, y_i) \) are arranged in counterclockwise order and \( x_k = x_0,\ y_k = y_0 \).)
  2. Select one of the extreme nails – the leftmost, rightmost, topmost, or bottommost nail.
  3. Remove the chosen nail from the board. The hairband then adjusts to form the new convex hull around the remaining nails.

You are given the positions of n nails on the board (with no two nails sharing the same x-coordinate or y-coordinate) and a sequence of n − 2 removal commands. Your task is to compute the convex hull area recorded immediately before each removal.

inputFormat

The first line contains an integer ( n ) (with ( n \ge 3 )). The next ( n ) lines each contain two integers, representing the x and y coordinates of a nail. It is guaranteed that no two nails have the same x or y coordinate. The following ( n − 2 ) lines each contain a single character among 'L', 'R', 'T', or 'B', indicating respectively the removal of the leftmost, rightmost, topmost, or bottommost nail.

outputFormat

Output exactly ( n − 2 ) lines. Each line should contain a floating-point number representing the area of the convex hull (with one decimal place) computed immediately before the corresponding removal.

sample

4
0 0
1 3
3 1
4 4
L
B
8.0

4.0

</p>