結果

問題 No.345 最小チワワ問題
ユーザー daku9640daku9640
提出日時 2016-10-09 09:08:45
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 482 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-21 20:42:31
合計ジャッジ時間 1,913 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

s = []
N = list(input())[::-1]
if N.count("cwcw") > 0:
    s += 4
if N.count("cww") > 0:
    s += 3
M1_flg = 1
m1 = m2 = 0
for i, n in enumerate(N):
    if n == "w" and M1_flg == 1:
        m1 = i
        M1_flg = 2
    elif n == "w" and M1_flg == 2:
        m2 = i
        M1_flg = 3
    elif n == "w" and M1_flg == 3:
        m1 = m2
        m2 = i
    elif n == "c" and M1_flg == 3:
        s += [i - m1 + 1]
        m1 = i
        M1_flg = 1
print(min(s) if len(s) != 0 else -1)
0