問題一覧 > 通常問題

No.436 ccw

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 551
作問者 : 🍡yurahuna / テスター : moti
お気に入りにしたユーザー ProblemId : 1098 / 自分の提出
問題文最終更新日: 2026-06-25 01:34:06
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 152 (順位表) の他の問題:

Problem Statement

C has a string S.
The string S has the form "c...ccw...w". That is, from the left, two or more c's are lined up, followed by one or more w's.
C wants S not to contain the substring "ccw" (not "cww"). To achieve this, C repeats the following operation.

Operation: Delete one character at the left end or the right end of S.

What is the minimum number of operations C must perform?

Input

S

The input consists of the string $S$ on a single line.
The length of the string $S$ is at least 3 and at most 100000 characters.
The string $S$ consists of two or more c's from the left, followed by one or more w's.

Output

Output on a single line the minimum number of operations C must perform.
Print a newline at the end.

Sample

Sample 1
Input
cccwwwwww
Output
2

Deleting the left end twice gives "cwwwwww", which no longer contains "ccw".

Sample 2
Input
ccccccccwww
Output
3

Deleting the right end three times gives "cccccccc", which no longer contains "ccw".

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。