結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー takakin
提出日時 2020-03-29 21:53:05
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
RE  
実行時間 -
コード長 378 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 53 ms
コンパイル使用メモリ 14,976 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2026-10-10 07:17:28
合計ジャッジ時間 2,292 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input=lambda: sys.stdin.readline().rstrip()
S=input()
n=len(S)
C=[]
W=[]
import bisect
for i in range(n):
  if S[i]=="c":
    C.append(i)
  if S[i]=="w":
    W.append(i)
ans=float("inf")
for i in range(len(W)-1):
  w1,w2=W[i],W[i+1]
  if w1<C[0]:
    continue
  else:
    c=C[bisect.bisect_left(C,w1)-1]
    ans=min(ans,w2-c+1)
print(-1 if ans==float("inf") else ans)
0