spoj#CAVLI. Cavli
Cavli
English | Vietnamese |
Mirko found a wooden board and N nails in his attic. Mirko hammered the nails into the board as fast as possible. The board can be modeled by a coordinate plane and the nails as points in it. No two nails have the same x or the same y coordinate.
In order to keep having fun, Mirko stole his sister's elastic hair band, spread it over all nails and then let go.The elastic, naturally, tightened around the nails.
Mirko then repeats these steps while there are at least three nails in the board:
- 1. Write down the area of the shape enclosed by the hair band.
- 2. Picks the leftmost, rightmost, topmost or bottommost nail in the board.
- 3. Remove the chosen nail from the board; the elastic tightens again around the remaining nails.
Input
The first line contains the integer N (3 ≤ N ≤ 300 000), the number of nails.
Each of the following N lines contains two integers separated by a space, the coordinates of a nail. All coordinates will be between 1 and 1 000 000 000. No two nails will share the same x or y coordinate.
The next line contains N-2 letters 'L', 'R', 'U' or 'D'. The letters represent the nails Mirko picked in order:
- 'L' for the leftmost nail (smallest x coordinate),
- 'R' for the rightmost nail (largest x coordinate),
- 'U' for the topmost nail (largest y coordinate),
- 'D' for the bottommost nail (smallest y coordinate).
Output
Output N-2 numbers, each on a separate line. The numbers are, in order, the areas that Mirko wrote down. Output numbers with one digit after the decimal point.
Example
Input: 8 1 6 2 4 3 1 4 2 5 7 6 5 7 9 8 3 URDLUU Output: 34.0 24.0 16.5 14.0 9.5 5.0