結果

問題 No.345 最小チワワ問題
ユーザー Ryuto
提出日時 2018-03-31 17:38:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-06-26 03:36:01
合計ジャッジ時間 2,620 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python

def main():
    sl = list(input().strip())
    sw = 0
    ans = 0
    res = 200
    for s in sl:
        if s == 'c':
            sw = 1
            ans = 1
        elif sw == 1 and s == 'w':
            sw = 2
            ans += 1
        elif sw == 2 and s == 'w':
            sw = 0
            ans += 1
            res = min(ans, res)
        else:
            ans += 1
    if res == 200:
        print('-1')
    else:
        print(res)

if __name__ == '__main__':
    main()
0