結果

問題 No.345 最小チワワ問題
ユーザー otsuneko
提出日時 2021-05-06 11:36:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 57,856 KB
最終ジャッジ日時 2024-09-14 04:13:33
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()

ans = float("INF")
for i in range(len(S)):
    start = end = 0
    flg = 0
    if S[i] == "c":
        start = i
        flg += 1
        for j in range(i+1,len(S)):
            if flg == 1 and S[j] == "w":
                flg += 1
            elif flg == 2 and S[j] == "w":
                end = j
                ans = min(ans,end-start+1)
                break

if ans != float("INF"):
    print(ans)
else:
    print(-1)
0