結果

問題 No.345 最小チワワ問題
ユーザー STInverSpinel
提出日時 2021-02-10 22:49:05
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 471 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-07-08 10:10:42
合計ジャッジ時間 1,682 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()

turn=0
cnt=0
isOK=False
ans=10**9
for i in range(len(S)):
    if turn==0:
        if S[i]=='c':
            cnt=1
            turn+=1
        else:
            cnt+=1
    elif turn==1:
        if S[i]=='w':
            cnt+=1
            turn+=1
        else:
            cnt+=1
    else:
        if S[i]=='w':
            cnt+=1
            isOK=True
            ans=min(ans,cnt)
            turn=0
        else:
            cnt+=1

print(ans if isOK else -1)
0