結果

問題 No.345 最小チワワ問題
ユーザー NagisaNagisa
提出日時 2016-02-27 02:55:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 507 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,860 KB
実行使用メモリ 14,400 KB
最終ジャッジ日時 2023-10-26 03:34:03
合計ジャッジ時間 4,926 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
14,400 KB
testcase_01 AC 28 ms
9,976 KB
testcase_02 AC 49 ms
9,976 KB
testcase_03 AC 49 ms
9,976 KB
testcase_04 AC 28 ms
9,976 KB
testcase_05 AC 28 ms
9,976 KB
testcase_06 AC 28 ms
9,976 KB
testcase_07 AC 28 ms
9,976 KB
testcase_08 AC 28 ms
9,976 KB
testcase_09 AC 28 ms
9,976 KB
testcase_10 AC 28 ms
9,976 KB
testcase_11 AC 29 ms
9,976 KB
testcase_12 AC 29 ms
9,976 KB
testcase_13 AC 28 ms
9,976 KB
testcase_14 AC 481 ms
9,976 KB
testcase_15 AC 29 ms
9,976 KB
testcase_16 AC 28 ms
9,976 KB
testcase_17 AC 29 ms
9,976 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

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