結果

問題 No.345 最小チワワ問題
ユーザー YU Hirose
提出日時 2024-07-11 14:41:22
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 601 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-11 14:41:26
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import re
s = input()
"""
p = re.search(r"c.*?w+?.*?w", s)
if p:
    print(len(p.group()))
else:
    print(-1)
"""
cnt = 0
i = 0
res = []
flag_c, flag_w = False, False
for i in s:
    if i == "c" and not flag_c:
        flag_c = True
    #elif i == "c" and flag_c:
    #    cnt = 0

    if i == "w" and flag_c and not flag_w:
        flag_w = True
    elif i == "w" and flag_c and flag_w:
        res.append(cnt)
        flag_c = False
        flag_w = False
        cnt = 0

    if flag_c or flag_w:
        cnt += 1


if len(res) == 0:
    print(-1)
else:
    max_res = max(res)
    print(max_res+1)
0