Mirko found a wooden board and
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:
- Write down the area of the shape enclosed by the hair band.
- Picks the leftmost, rightmost, topmost or bottommost nail in the board.
- Remove the chosen nail from the board; the elastic tightens again around the remaining nails.
Write a program that calculates the numbers written in step 1 of each iteration, if we know the nail Mirko picks in step
Input Specification
The first line contains the integer
Each of the following
The next line contains L
, R
, U
or D
. The letters represent the nails Mirko picked in order:
L
for the leftmost nail (smallest coordinate),R
for the rightmost nail (largest coordinate),U
for the topmost nail (largest coordinate),D
for the bottommost nail (smallest coordinate).
Output Specification
Output
Scoring
In test cases worth
Sample Input 1
5
1 4
2 2
4 1
3 5
5 3
LUR
Sample Output 1
9.0
6.5
2.5
Sample Input 2
8
1 6
2 4
3 1
4 2
5 7
6 5
7 9
8 3
URDLUU
Sample Output 2
34.0
24.0
16.5
14.0
9.5
5.0
The images below illustrate the state before each of the
Comments