結果

問題 No.345 最小チワワ問題
ユーザー mkawa2mkawa2
提出日時 2019-12-15 09:59:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 8,556 KB
最終ジャッジ日時 2023-09-15 15:27:41
合計ジャッジ時間 2,130 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,456 KB
testcase_01 AC 19 ms
8,404 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 19 ms
8,496 KB
testcase_05 AC 19 ms
8,412 KB
testcase_06 AC 19 ms
8,380 KB
testcase_07 AC 19 ms
8,408 KB
testcase_08 AC 19 ms
8,404 KB
testcase_09 AC 20 ms
8,448 KB
testcase_10 AC 19 ms
8,464 KB
testcase_11 AC 19 ms
8,372 KB
testcase_12 AC 19 ms
8,380 KB
testcase_13 AC 19 ms
8,556 KB
testcase_14 AC 19 ms
8,440 KB
testcase_15 AC 19 ms
8,460 KB
testcase_16 AC 19 ms
8,404 KB
testcase_17 WA -
testcase_18 AC 19 ms
8,548 KB
testcase_19 AC 19 ms
8,396 KB
testcase_20 AC 19 ms
8,408 KB
testcase_21 AC 19 ms
8,408 KB
testcase_22 AC 19 ms
8,444 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 18 ms
8,448 KB
testcase_29 AC 19 ms
8,400 KB
testcase_30 AC 19 ms
8,452 KB
testcase_31 AC 19 ms
8,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    s=input()
    pos_c=101
    pos_w=-2
    ans=[]
    for i,c in enumerate(s):
        if c=="c":
            pos_c=i
        if c=="w":
            if pos_w>pos_c:
                ans.append(i-pos_c+1)
                pos_w=-2
            else:
                pos_w=i
    if ans:print(min(ans))
    else:print(-1)


main()
0