Logo
(追記) (追記ここまで)

13947번 - Convex Contour 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB3031419243.192%

문제

A number of geometric shapes are neatly arranged in a rectangular grid. The shapes occupy consecutive cells in a single row with each cell containing exactly one shape. Each shape is either:

  • a square perfectly aligned with the grid square,
  • a circle inscribed in the grid square,
  • or an equilateral triangle with a side corresponding to the bottom side of the grid square.

The shapes from the first example input and their convex contour.

Informally, the convex contour of an arrangement is the shortest line that encloses all the shapes. Formally, we can define it as the circumference of the convex hull of the union of all shapes.

Given an arrangement of shapes, find the length of its contour.

입력

The first line contains an integer n (1 ≤ n ≤ 20) — the number of shapes. The following line contains a string consisting of n characters that describes the shapes in the arrangement left to right. Each character is an uppercase letter “S”, “C” or “T” denoting a square, circle or a triangle respectively.

출력

Output a single floating point number — the length of the contour. The solution will be accepted if the absolute or the relative difference from the judges solution is less than 10−6 .

제한

예제 입력 1

4
TSTC

예제 출력 1

9.088434417

예제 입력 2

3
SCT

예제 출력 2

7.50914177324

힌트

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2016 C번

Contest > Open Cup > 2016/2017 Season > Stage 8: Grand Prix of Europe C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /