結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー yuki2006
提出日時 2016-02-18 03:06:28
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 392 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 122 ms
コンパイル使用メモリ 77,764 KB
最終ジャッジ日時 2025-12-03 19:25:25
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- coding: utf-8 -*-

S = raw_input()

hit = [-1] * 2
mn = float("inf")
latestCWStart = -1
for i, s in enumerate(S):
    if s == "c":
        hit[0] = i
    if s == "w":
        if latestCWStart != -1:
            mn = min(mn, i - latestCWStart + 1)

        hit[1] = i
        if hit[0] < hit[1]:
            latestCWStart = hit[0]

if mn == float("inf"):
    print -1
else:
    print mn
0