P3680 [CERC2016] Convex Contour
Description
Some geometric figures are arranged neatly from left to right in a single row on a square grid. They occupy a consecutive segment of one row, with exactly one figure in each cell. Each figure is one of the following three:
1. A square that exactly fills a single cell.
2. A circle inscribed in a single cell.
3. An equilateral triangle whose base coincides with the bottom edge of the cell.

The side length of each cell is $1$. Compute the perimeter of the convex hull of these figures.
Input Format
The first line contains a positive integer $n$, the number of figures.
The second line contains $n$ characters, describing each figure from left to right: `S` denotes a square, `C` denotes a circle, and `T` denotes an equilateral triangle.
Output Format
Output a single real number, the perimeter of the convex hull. Your answer will be accepted if the absolute or relative error does not exceed $10^{-6}$.
Explanation/Hint
For $100\%$ of the testdata, $1 \le n \le 20$.
Translated by ChatGPT 5