結果

問題 No.150 "良問"(良問とは言っていない
ユーザー nbisconbisco
提出日時 2017-01-29 00:16:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-08-25 13:32:49
合計ジャッジ時間 1,527 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
7,840 KB
testcase_02 AC 16 ms
7,860 KB
testcase_03 AC 15 ms
7,936 KB
testcase_04 AC 15 ms
7,832 KB
testcase_05 AC 15 ms
7,804 KB
testcase_06 AC 31 ms
7,916 KB
testcase_07 AC 16 ms
7,908 KB
testcase_08 AC 16 ms
7,836 KB
testcase_09 AC 15 ms
7,940 KB
testcase_10 WA -
testcase_11 AC 22 ms
7,844 KB
testcase_12 AC 20 ms
7,804 KB
testcase_13 AC 23 ms
7,840 KB
testcase_14 AC 25 ms
7,888 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 18 ms
7,884 KB
testcase_18 AC 25 ms
7,856 KB
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

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
    for i in range(len(s)-7, 3, -1):
        d = dist(s[i:i+7], "problem")
        if min_dist > d:
            min_dist = d
            min_idx = i
    d = min_dist
    min_dist = len(s)
    for i in range(min_idx-4+1):
        min_dist = min(min_dist, dist(s[i:i+4], "good"))
    return d + 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