結果

問題 No.150 "良問"(良問とは言っていない
ユーザー nbisconbisco
提出日時 2017-01-29 00:25:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 592 ms / 5,000 ms
コード長 658 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-19 09:44:02
合計ジャッジ時間 3,943 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 145 ms
10,624 KB
testcase_01 AC 32 ms
10,752 KB
testcase_02 AC 34 ms
10,496 KB
testcase_03 AC 34 ms
10,624 KB
testcase_04 AC 32 ms
10,752 KB
testcase_05 AC 40 ms
10,496 KB
testcase_06 AC 592 ms
10,496 KB
testcase_07 AC 29 ms
10,624 KB
testcase_08 AC 35 ms
10,624 KB
testcase_09 AC 33 ms
10,624 KB
testcase_10 AC 155 ms
10,496 KB
testcase_11 AC 174 ms
10,624 KB
testcase_12 AC 126 ms
10,624 KB
testcase_13 AC 167 ms
10,496 KB
testcase_14 AC 205 ms
10,624 KB
testcase_15 AC 189 ms
10,624 KB
testcase_16 AC 42 ms
10,496 KB
testcase_17 AC 79 ms
10,752 KB
testcase_18 AC 172 ms
10,496 KB
testcase_19 AC 216 ms
10,624 KB
testcase_20 AC 220 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dist(l,word):
    return sum([1 for p in zip(l, word) if p[0] != p[1]])

def solver(_s):
    global GL
    if len(_s) == GL:
        return dist(_s, "goodproblem")
    s = list(_s)
    min_dist = len(s)
    min_idx = len(s)-7
    cand = []
    for i in range(len(s)-7, 3, -1):
        d = dist(s[i:i+7], "problem")
        cand.append([i,d])
    d = min_dist
    min_dist = len(s)
    for i in cand:
        for j in range(i[0]-4+1):
            min_dist = min(min_dist, i[1] + dist(s[j:j+4], "good"))
    return min_dist

GL = len("goodproblem")

T = int(input())
S = [input() for i in range(T)]

ans = [solver(i) for i in S]
for i in ans:
    print(i)
0