結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー Ryuto
提出日時 2018-03-31 17:38:07
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 504 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 951 ms
コンパイル使用メモリ 95,856 KB
実行使用メモリ 78,976 KB
最終ジャッジ日時 2026-07-30 06:56:40
合計ジャッジ時間 4,145 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/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