結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー otsuneko
提出日時 2021-05-06 11:36:25
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 27 ms / 2,000 ms
+ 722µs
コード長 456 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 85 ms
コンパイル使用メモリ 80,944 KB
実行使用メモリ 61,664 KB
最終ジャッジ日時 2026-10-10 23:33:21
合計ジャッジ時間 2,842 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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