結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー y_nakamura_CC2
提出日時 2018-03-15 02:00:46
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 21 ms / 2,000 ms
+ 946µs
コード長 546 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 64 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-10 22:02:58
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = input()
min_cww = 200
cww_size = 200

def search_ww(i, start, c):
    
    if i < len(S):
        
        if S[i] == "w" and c == 0:
            c += 1
            return search_ww(i + 1, start, c)

        if S[i] == "w" and c == 1:
            return i - start + 1

        return search_ww(i + 1, start, c)

    else:
        return 1000

for x in range(len(S) - 2):
    if S[x] == "c":
        cww_size = search_ww(x, x, 0)
        
    if min_cww > cww_size:
        min_cww = cww_size
        
print(min_cww if min_cww != 200 else -1)
0