結果

問題 No.345 最小チワワ問題
ユーザー YutaYuta
提出日時 2023-03-10 11:48:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-09-18 03:14:28
合計ジャッジ時間 2,121 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

sentence = input()
# print(sentence)
x,y,z = [0,0,0]
minimal_length = []

for i, string_ in enumerate(sentence):
    if sentence[i] == "c":

        x = i
        y = 0
        for i, string_ in enumerate(sentence):
            if sentence[i] == "w" and i>x:
                if y == 0:
                    y = i
                    
                else:
                    z = i

                    q = z-x+1
                    minimal_length.append(q)
                    break

if len(minimal_length) == 0:
    print(-1)

else:
    print(min(minimal_length))

                    
                
            

    #     if sentence[i] == "w":
    #         if y == 0:
    #             y = i
    #         elif z == 0:
    #             z = i
    
#if x != 0 and y != 0 and z!=0:
#a = z-x+1


# print(x,y,z)


0