結果

問題 No.345 最小チワワ問題
ユーザー NagisaNagisa
提出日時 2019-07-26 14:34:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 76,584 KB
最終ジャッジ日時 2023-09-15 00:20:18
合計ジャッジ時間 4,310 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,556 KB
testcase_01 AC 71 ms
71,480 KB
testcase_02 AC 84 ms
76,152 KB
testcase_03 AC 84 ms
75,944 KB
testcase_04 AC 72 ms
71,416 KB
testcase_05 AC 71 ms
71,248 KB
testcase_06 AC 72 ms
71,356 KB
testcase_07 AC 70 ms
71,364 KB
testcase_08 AC 71 ms
71,100 KB
testcase_09 AC 71 ms
71,368 KB
testcase_10 AC 71 ms
71,448 KB
testcase_11 AC 72 ms
71,496 KB
testcase_12 AC 74 ms
75,608 KB
testcase_13 AC 71 ms
71,484 KB
testcase_14 AC 102 ms
76,256 KB
testcase_15 AC 73 ms
71,356 KB
testcase_16 AC 72 ms
71,364 KB
testcase_17 AC 78 ms
75,896 KB
testcase_18 AC 164 ms
76,584 KB
testcase_19 AC 76 ms
71,412 KB
testcase_20 AC 74 ms
71,468 KB
testcase_21 AC 72 ms
71,596 KB
testcase_22 AC 70 ms
71,548 KB
testcase_23 AC 72 ms
71,484 KB
testcase_24 AC 72 ms
71,392 KB
testcase_25 AC 71 ms
71,420 KB
testcase_26 AC 72 ms
71,248 KB
testcase_27 AC 78 ms
76,100 KB
testcase_28 AC 70 ms
71,644 KB
testcase_29 AC 87 ms
76,156 KB
testcase_30 AC 83 ms
76,140 KB
testcase_31 AC 71 ms
71,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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