結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー rpy3cpprpy3cpp
提出日時 2015-07-24 23:03:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 709 bytes
コンパイル時間 150 ms
コンパイル使用メモリ 10,996 KB
実行使用メモリ 18,924 KB
最終ジャッジ日時 2023-09-22 22:49:07
合計ジャッジ時間 6,559 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
権限があれば一括ダウンロードができます

ソースコード

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