結果

問題 No.345 最小チワワ問題
ユーザー gorugo30
提出日時 2021-02-22 23:45:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 70,112 KB
最終ジャッジ日時 2024-09-21 19:05:38
合計ジャッジ時間 3,416 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

def iscww(S):
    N = len(S)
    cww = "cww"
    cnt = 0
    for i in range(N):
        if S[i] == cww[cnt]:
            cnt += 1
            if cnt == 3:
                break
    return cnt == 3

S = input()
ans = 1000
for l in range(len(S)):
    for r in range(l + 1, len(S) + 1):
        if iscww(S[l:r]):
            ans = min(ans, r - l)
if ans == 1000:
    print(-1)
else:
    print(ans)
0