No.1292 Flipping Triangle
問題文最終更新日: 2020-11-20 21:08:12
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 275
(順位表)
の他の問題:
Problem Statement
There is an equilateral triangle of area 1 on a plane. Let us call its 3 sides side a, side b, and side c.
You will perform an operation $|S|$ times.
The $i$-th operation is described as follows, using the $i$-th character $s_i$ of the string $S$ given as input.
- Reflect the triangle across side $s_i$.
Then, you
decide to paint every region where the triangle was located at any of the following moments: before performing the operations, immediately after the 1st operation, immediately after the 2nd operation, ..., immediately after the $|S|$-th operation.
That is, the regions occupied by the triangle at those moments get painted.
Find the area of the painted part.
(It can be shown that the answer is an integer. Output it as an integer value.)
Input
$S$
- $1 \le |S| \le 2 \times 10^5$
- Each character in $S$ is one of
a,b,c
Output
Output the answer.
Print a newline at the end.
Sample
Sample 1
Input
abcc
Output
4
Sample 2
Input
cbacbbab
Output
8
Sample 3
Input
a
Output
2
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
沙耶花
SSRS