結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 26 ms
9,060 KB
testcase_05 AC 25 ms
8,952 KB
testcase_06 AC 25 ms
8,956 KB
testcase_07 AC 25 ms
9,000 KB
testcase_08 AC 25 ms
8,904 KB
testcase_09 AC 26 ms
8,872 KB
testcase_10 RE -
testcase_11 AC 25 ms
8,932 KB
testcase_12 AC 25 ms
8,928 KB
testcase_13 AC 25 ms
8,936 KB
testcase_14 AC 25 ms
8,936 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 25 ms
9,000 KB
testcase_19 AC 26 ms
8,876 KB
testcase_20 RE -
testcase_21 AC 25 ms
8,992 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 25 ms
8,940 KB
testcase_29 AC 26 ms
9,012 KB
testcase_30 AC 25 ms
9,000 KB
testcase_31 AC 25 ms
9,108 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'cx*?wx*?w')
        rescww = patcww.search(text)
        print(len(rescww.group()))
    else:
        print(-1)

    

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