結果

問題 No.345 最小チワワ問題
ユーザー otsunekootsuneko
提出日時 2021-05-06 11:36:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 75,948 KB
最終ジャッジ日時 2023-10-12 04:42:47
合計ジャッジ時間 3,730 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,556 KB
testcase_01 AC 67 ms
71,340 KB
testcase_02 AC 71 ms
71,624 KB
testcase_03 AC 69 ms
71,396 KB
testcase_04 AC 69 ms
71,460 KB
testcase_05 AC 67 ms
71,688 KB
testcase_06 AC 69 ms
71,388 KB
testcase_07 AC 68 ms
71,236 KB
testcase_08 AC 68 ms
71,324 KB
testcase_09 AC 69 ms
71,540 KB
testcase_10 AC 67 ms
71,372 KB
testcase_11 AC 69 ms
71,380 KB
testcase_12 AC 72 ms
75,948 KB
testcase_13 AC 68 ms
71,332 KB
testcase_14 AC 70 ms
75,692 KB
testcase_15 AC 68 ms
71,336 KB
testcase_16 AC 68 ms
71,564 KB
testcase_17 AC 68 ms
71,664 KB
testcase_18 AC 67 ms
71,392 KB
testcase_19 AC 68 ms
71,308 KB
testcase_20 AC 69 ms
71,460 KB
testcase_21 AC 68 ms
71,540 KB
testcase_22 AC 69 ms
71,304 KB
testcase_23 AC 68 ms
71,636 KB
testcase_24 AC 68 ms
71,328 KB
testcase_25 AC 69 ms
71,636 KB
testcase_26 AC 68 ms
71,304 KB
testcase_27 AC 68 ms
71,432 KB
testcase_28 AC 68 ms
71,432 KB
testcase_29 AC 68 ms
71,184 KB
testcase_30 AC 69 ms
71,460 KB
testcase_31 AC 69 ms
71,540 KB
権限があれば一括ダウンロードができます

ソースコード

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