結果

問題 No.345 最小チワワ問題
ユーザー foumi
提出日時 2019-04-04 11:48:23
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 306 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-10-01 05:16:06
合計ジャッジ時間 1,698 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()

w = 0
ww = 0
cww = 101

for c in range(len(s)):
    if s[c] == 'c' and s[c:].count('w') >= 2:
        w = s[c:].index('w') + c
        ww = s[w+1:].index('w') + w + 1
        if cww > ww - c + 1:
            cww = ww - c + 1

if cww == 101:
    print(-1)
else:
    print(cww)
0