結果

問題 No.345 最小チワワ問題
ユーザー fV9TwBhUoa9S3eV
提出日時 2019-09-18 14:03:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-08 02:41:19
合計ジャッジ時間 2,280 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

# No.345 最小チワワ問題
import sys

s = input()

index_c = 0
index_w = 0
count_w = 0
length = sys.maxsize

for i in range(len(s)):
    if s[i] == 'c':
        index_c = i
        count_w = 0

        for j in range(i, len(s)):
            if s[j] == 'w':
                index_w = j
                count_w += 1
                if count_w == 2:
                    length = min(length, index_w - index_c + 1)
                    index_c = 0

print(length if length != sys.maxsize else -1)
0