結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー ic__e
提出日時 2022-12-10 20:13:52
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 21 ms / 2,000 ms
+ 532µs
コード長 314 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 341 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-11 00:21:49
合計ジャッジ時間 3,115 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# 最小チワワ問題
str = input()
wCount = 0
ans = 100

for n,sc in enumerate(str):
  wCount=0
  length=1
  if(sc=='c'):
    for sw in str[n+1:]:
      length+=1
      if(sw=='w'):
        wCount+=1
      if(wCount==2):
        if(ans>length):
          ans=length
if(ans==100):
  print(-1)
else:
  print(ans)
0