結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー otsuneko
提出日時 2021-05-06 11:36:25
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 456 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 151 ms
コンパイル使用メモリ 85,300 KB
実行使用メモリ 58,368 KB
最終ジャッジ日時 2026-04-04 10:05:09
合計ジャッジ時間 1,810 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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