結果

問題 No.345 最小チワワ問題
ユーザー くまちゃんくまちゃん
提出日時 2022-02-24 12:43:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 486 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 9,128 KB
最終ジャッジ日時 2023-09-15 06:50:56
合計ジャッジ時間 2,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 25 ms
9,092 KB
testcase_03 AC 26 ms
8,936 KB
testcase_04 AC 25 ms
9,064 KB
testcase_05 WA -
testcase_06 AC 25 ms
9,004 KB
testcase_07 AC 25 ms
8,956 KB
testcase_08 AC 25 ms
8,948 KB
testcase_09 AC 25 ms
9,084 KB
testcase_10 RE -
testcase_11 AC 25 ms
9,124 KB
testcase_12 AC 26 ms
9,092 KB
testcase_13 AC 25 ms
8,948 KB
testcase_14 AC 25 ms
8,936 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 25 ms
8,876 KB
testcase_18 WA -
testcase_19 AC 26 ms
8,960 KB
testcase_20 RE -
testcase_21 AC 25 ms
9,120 KB
testcase_22 RE -
testcase_23 AC 26 ms
9,060 KB
testcase_24 AC 26 ms
9,068 KB
testcase_25 AC 26 ms
9,064 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 26 ms
9,008 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 26 ms
8,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import re


def main():
    text = input()
    l = text.find('c')
    m = text.find('w', l + 1)
    n = text.find('w', m + 1)

    if text.count('c') < 1 or text.count('w') < 2:
        print(-1)
    elif text.count('c') == 1 and text.count('w') == 1:
        print(-1)
    elif l < m < n:
        patcww = re.compile(r'ca*?w.*?w')
        rescww = patcww.search(text)
        print(len(rescww.group()))
    else:
        print(-1)

    

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