結果

問題 No.150 "良問"(良問とは言っていない
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-09 23:09:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 707 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 9,196 KB
最終ジャッジ日時 2023-09-20 20:26:18
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import re
import itertools

def prepare():
    rememo = []
    words_original = [c for c in 'goodproblem']
    for i in range(12):
        for pos in itertools.combinations(range(11), i):
            words = words_original[:]
            for p in pos:
                words[p] = '.'
            pattern = ''.join(words[:4] + ['.*'] + words[4:])
            compiled = re.compile(pattern)
            rememo.append(i, compiled)
    return rememo

def solve(S, rememo):
    for i, compiled in rememo:
        result = compiled.search(S)
        if result:
            return i

if __name__ == '__main__':
    rememo = prepare()
    T = int(input())
    for t in range(T):
        print(solve(input(), rememo))
0