Vacuum-Bot
A large room with dusty floor is represented as a 2-D plane. You have a disc-shaped robot (the vacuum-bot) that traverses the floor while vacuuming the dust underneath. Given the trajectory of the vacuum-bot from the instant it is powered-on to the instant it is powered-off, your task is to calculate the total area of dust-free floor at the end of vacuum-bot operation.
The vacuum-bot is represented as a circle with diameter 1. Initially the entire floor is dusty and the vacuum-bot faces east. The trajectory of the vacuum-bot is encoded as a string whose characters sequentially describe one of four actions:
s: The vacuum-bot steps forward by 1 (and vacuums portions of the floor it sweeps over).
r: The vacuum-bot turns clockwise by 90°.
l: The vacuum-bot turns counter-clockwise by 90°.
x: The vacuum-bot is turned off.
For example, the string
ssrslsx
encodes the following vacuum-bot trajectory:
Dust-free floor is shown in blue. Its total area is 3.5 + 0.375 π ≈ 4.6781. You may assume that the vacuum-bot never encounters any obstacle (walls, humans, giant dust bunnies), and no new dust will appear. Note that there are multiple, independent test cases.
Input
The first input line contains the number of test cases N, 1 ≤ N ≤ 100.
Each test case consists of a string s on a single line, representing the trajectory of the vacuum-bot.
1 ≤ length(s) ≤ 100.
s consists of characters 's', 'r', 'l', until the last character, which is always 'x'.
Output
For each test case, print the total area of dust-free floor after vacuum-bot operation, to 4 decimal places, on a single line.c