結果

問題 No.345 最小チワワ問題
ユーザー object1234
提出日時 2022-02-22 13:38:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-06-30 14:32:30
合計ジャッジ時間 1,996 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

def count_chiwawa(str):
    str_len = len(str)
    count = 0
    w_count = 0
    res = 999
    i = 0
    j = 0
    for i in range(str_len):
        if str[i] == "c":
            j = i + 1
            count = 1
            w_count = 0
            for k in range(j,str_len):
                count += 1
                if str[k] == "w":
                    w_count += 1
                if w_count == 2:
                    if count < res:
                        res = count
                    break
    if res == 999:
        return -1
    else:
        return res
print(count_chiwawa(input()))
0