Stretchy Rubber Band
Time limit1sMemory limit1024 MB
Given points with distinct x and y, repeatedly remove the leftmost, rightmost, topmost, or bottommost point and report the convex hull area before each removal.
- Level
Medium7 of 10
- Topics
- Geometry, Linked list, Simulation
- Solved
- No attempts yet
Problem
Mirko found a wooden board and nails in an old attic. He hammered the nails into the board right away. Treat the board as a coordinate plane and each nail as a point on it. No two nails share the same coordinate or the same coordinate.
To keep himself busy with his new finds, Mirko stole his sister's hair rubber band, stretched it around all the nails, and let it go. The band snapped tight around the outer nails. Mirko then repeats the following steps while more than 2 nails remain on the board:
- He writes on paper the area of the shape that the rubber band encloses.
- He chooses one of the following nails: the leftmost, the rightmost, the topmost, or the bottommost.
- He pulls the chosen nail out of the board, and the rubber band tightens again around the outer nails.
Write a program that computes the numbers Mirko writes on paper, given which nail he chose at each step.
Input
The first line contains a natural number (). Each of the next lines contains two natural numbers and , the coordinates of one nail. All coordinates are less than , and no two nails share an coordinate or a coordinate.
The last line is a string of characters, each being L, R, U, or D. They mean that Mirko chose the leftmost, rightmost, topmost, or bottommost nail, respectively.
Output
Print the areas that Mirko wrote down, in order. Each area must be printed with exactly one digit after the decimal point.
Hint
Explanation of the second test case:

The figure shows the state before each of the 6 steps.