結果

問題 No.345 最小チワワ問題
ユーザー foumi
提出日時 2019-04-04 11:03:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 401 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-12-25 15:28:01
合計ジャッジ時間 2,078 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
if s.count('c') == 0 or s.count('w') < 2:
    print(-1)

w1 = s.find('w')
wn = s.rfind('w')
w = 0
ww = 0
cww = 101

for c in range(len(s)):
    if s[c] == 'c' and s[c:].count('w') >= 2:
        w = s[c:].index('w') + c
        ww = s[w+1:].index('w') + w + 1
        if cww > ww - c + 1:
            cww = ww - c + 1

if cww == 101:
    print(-1)
else:
    print(cww)
0