結果

問題 No.150 "良問"(良問とは言っていない
ユーザー togatogatogatoga
提出日時 2015-09-12 15:26:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 739 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-19 09:26:54
合計ジャッジ時間 1,790 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
10,752 KB
testcase_01 AC 28 ms
10,880 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 29 ms
10,880 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 AC 29 ms
10,752 KB
testcase_06 AC 73 ms
10,752 KB
testcase_07 AC 29 ms
10,880 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 49 ms
10,880 KB
testcase_11 AC 46 ms
10,752 KB
testcase_12 AC 41 ms
10,752 KB
testcase_13 AC 48 ms
10,880 KB
testcase_14 AC 49 ms
10,752 KB
testcase_15 AC 48 ms
10,752 KB
testcase_16 AC 31 ms
10,752 KB
testcase_17 AC 36 ms
10,752 KB
testcase_18 AC 52 ms
10,752 KB
testcase_19 AC 54 ms
10,752 KB
testcase_20 AC 55 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())



for i in range(T):
    S = input()
    
    pre = [1 << 30] * 110
    post = [1 << 30] * 110

    for y in range(3, len(S)):
        cost = 0
        if (S[y - 3] != 'g'):
            cost += 1
        if (S[y - 2] != 'o'):
            cost += 1
        if (S[y - 1] != 'o'):
            cost += 1
        if (S[y] != 'd'):        
            cost += 1
        pre[y] = min(pre[y - 1], cost)
        
    for y in range(len(S) - 7, 0, -1):
        cost = 0
        for index,s in enumerate("problem"):
            if (S[y + index] != s):
                cost += 1
        post[y] = min(post[y + 1], cost)
        
    ans = 1 << 30
    for i in range(101):
        ans = min(ans, pre[i] + post[i + 1])
    print (ans)
0