結果

問題 No.150 "良問"(良問とは言っていない
ユーザー shinichishinichi
提出日時 2021-11-22 13:50:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 5,000 ms
コード長 422 bytes
コンパイル時間 1,363 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 78,384 KB
最終ジャッジ日時 2023-09-06 05:15:01
合計ジャッジ時間 4,367 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
77,612 KB
testcase_01 AC 70 ms
71,376 KB
testcase_02 AC 70 ms
71,380 KB
testcase_03 AC 70 ms
71,556 KB
testcase_04 AC 70 ms
71,412 KB
testcase_05 AC 86 ms
76,652 KB
testcase_06 AC 253 ms
77,560 KB
testcase_07 AC 70 ms
71,284 KB
testcase_08 AC 84 ms
76,620 KB
testcase_09 AC 78 ms
75,400 KB
testcase_10 AC 129 ms
77,420 KB
testcase_11 AC 149 ms
77,968 KB
testcase_12 AC 128 ms
77,760 KB
testcase_13 AC 145 ms
78,384 KB
testcase_14 AC 156 ms
77,776 KB
testcase_15 AC 144 ms
77,524 KB
testcase_16 AC 99 ms
77,240 KB
testcase_17 AC 122 ms
77,488 KB
testcase_18 AC 145 ms
77,472 KB
testcase_19 AC 169 ms
77,964 KB
testcase_20 AC 162 ms
77,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

def dist(a, b):
    cnt = 0
    assert len(a) == len(b)
    for i in range(len(a)):
        if a[i] != b[i]:
            cnt += 1
    return cnt

good, problem = "good", "problem"
INF = 1001001001
for _ in range(T):
    S = input()
    ans = INF
    for k in range(len(S)-9):
        for j in range(k+4, len(S)-6):
            ans = min(ans, dist(S[k:k+4], good) + dist(S[j:j+7], problem))
    print(ans)
0