結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー Nagisa
提出日時 2016-02-27 02:55:49
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 1,681 ms / 2,000 ms
+ 529µs
コード長 507 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 308 ms
コンパイル使用メモリ 21,468 KB
実行使用メモリ 15,788 KB
最終ジャッジ日時 2026-09-04 01:54:51
合計ジャッジ時間 7,665 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = input()
c = []
w1 = []
w2 = []

for k in range(len(S)):
    if S[k] == "c":
        c.append(k)

for l in c:
    for m in range(l+1,len(S)):
        if S[m] == "w":
            w1.append(m)

for l in w1:
    for m in range(l+1,len(S)):
        if S[m] == "w":
            w2.append(m)

if len(c) * len(w1) * len(w2) == 0:
    print(-1)
else:
    ans = 100
    for p in c:
        for q in w1:
            for r in w2:
                if p < q < r:
                    ans = min(ans,r-p+1)
    print(ans)
0