結果
| 問題 | 
                            No.345 最小チワワ問題
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-04-29 19:25:13 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 42 ms / 2,000 ms | 
| コード長 | 425 bytes | 
| コンパイル時間 | 302 ms | 
| コンパイル使用メモリ | 81,852 KB | 
| 実行使用メモリ | 51,968 KB | 
| 最終ジャッジ日時 | 2024-09-25 12:14:22 | 
| 合計ジャッジ時間 | 2,449 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 | 
ソースコード
string = input()
c_indices = [i for i, x in enumerate(string) if string[i] == "c"]
w_indices = [i for i, x in enumerate(string) if string[i] == "w"]
length = 1000
for c_index in c_indices:
    for i, w_index in enumerate(w_indices[:-1]):
        if c_index < w_index:
            ww_index = w_indices[i + 1]
            length = min(length, ww_index - c_index + 1)
if length == 1000:
    print(-1)
else:
    print(length)