結果

問題 No.345 最小チワワ問題
ユーザー knt3110knt3110
提出日時 2018-05-17 17:24:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-09-25 12:14:24
合計ジャッジ時間 2,201 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

s=input()

count=[0 for i in range(len(s)-1)]
for j in range(len(s)-2):
    a=''
    for i in range (j,len(s)):
        if a=='' and s[i]=='c':
            a+='c'
            count[j]+=1
        elif a=='c' and s[i]=='w':
            a+='w'
            count[j]+=1
        elif a=='cw' and s[i]=='w':
            a+='w'
            count[j]+=1
            break
        elif a=='c' or a=='cw':
            count[j]+=1
    if a!='cww':
        count[j]=-1

answer=1000
for i in range(len(count)):
    if count[i]<answer and count[i]>0:
        answer=count[i]

if answer==1000:
    print(-1)
else:
    print(answer)
    
0