AtCoder Grand Contest 034
翻译中…
Problem Statement
翻译中…
You are given a string $s$ consisting of A, B and C.
翻译中…
Snuke wants to perform the following operation on $s$ as many times as possible:
翻译中…
- Choose a contiguous substring of
$s$that readsABCand replace it withBCA.
翻译中…
Find the maximum possible number of operations.
翻译中…
Constraints
翻译中…
$1 \leq |s| \leq 200000$- Each character of
$s$isA,BandC.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
s
翻译中…
Output
翻译中…
Find the maximum possible number of operations.
翻译中…
样例
Input #1
ABCABC
Output #1
3
You can perform the operations three times as follows: `ABCABC` → `BCAABC` → `BCABCA` → `BCBCAA`. This is the maximum result.
Input #2
C
Output #2
0
Input #3
ABCACCBABCBCAABCB
Output #3
6
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。