結果

問題 No.150 "良問"(良問とは言っていない
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-09 23:10:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 292 ms / 5,000 ms
コード長 709 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-19 09:25:48
合計ジャッジ時間 4,993 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 218 ms
11,520 KB
testcase_01 AC 107 ms
11,520 KB
testcase_02 AC 115 ms
11,520 KB
testcase_03 AC 111 ms
11,520 KB
testcase_04 AC 116 ms
11,520 KB
testcase_05 AC 112 ms
11,520 KB
testcase_06 AC 126 ms
11,520 KB
testcase_07 AC 113 ms
11,392 KB
testcase_08 AC 113 ms
11,520 KB
testcase_09 AC 109 ms
11,520 KB
testcase_10 AC 242 ms
11,648 KB
testcase_11 AC 265 ms
11,520 KB
testcase_12 AC 210 ms
11,392 KB
testcase_13 AC 266 ms
11,520 KB
testcase_14 AC 285 ms
11,520 KB
testcase_15 AC 269 ms
11,520 KB
testcase_16 AC 111 ms
11,520 KB
testcase_17 AC 160 ms
11,392 KB
testcase_18 AC 291 ms
11,520 KB
testcase_19 AC 292 ms
11,648 KB
testcase_20 AC 287 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

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