結果

問題 No.345 最小チワワ問題
ユーザー gma712
提出日時 2021-06-27 13:42:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-25 11:11:11
合計ジャッジ時間 2,123 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    S = list(input())
    wwc_lengthes = []
    wwc_store = []
    for i in range(len(S) - 1, -1, -1):
        if S[i] == 'w':
            if len(wwc_store) == 1:
                wwc_store.append(i)
            if len(wwc_store) == 0:
                wwc_store.append(i)
        if S[i] == 'c':
            if len(wwc_store) == 2:
                wwc_lengthes.append(wwc_store[0] - i + 1)
                wwc_store = []
    print(min(wwc_lengthes) if wwc_lengthes else -1)


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