結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー yuki2006
提出日時 2016-02-18 03:06:28
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
AC  
実行時間 63 ms / 2,000 ms
+ 699µs
コード長 392 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 870 ms
コンパイル使用メモリ 80,584 KB
実行使用メモリ 81,132 KB
最終ジャッジ日時 2026-10-10 21:32:33
合計ジャッジ時間 4,317 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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