問題一覧 > 通常問題

No.345 Minimum Chihuahua Problem

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

Problem Statement

C loves Chihuahuas. So C decided to find Chihuahuas in strings as well.
According to C, a string is called a "Chihuahua string" if it contains 'c', 'w', 'w' in this order.
Since C likes small Chihuahuas, C wants to find a Chihuahua string whose length is as small as possible.

Given a string $S$, find the minimum length among its contiguous substrings that are Chihuahua strings.

Input

S

The first line contains a string $S (1 \le |S| \le 100)$.
$S$ consists only of lowercase English letters.

Output

Print as an integer the minimum length among the contiguous substrings of $S$ that are Chihuahua strings.
If $S$ does not contain a Chihuahua string, print $-1$.
Print a newline at the end.

Sample

Sample 1
Input
ilovechiwawa
Output
6

Sample 2
Input
wachiwachi
Output
-1

Sample 3
Input
chiwaaaaaaamikawayadeeeeesu
Output
16

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