結果
問題 |
No.252 "良問"(良問とは言っていない (2)
|
ユーザー |
![]() |
提出日時 | 2015-08-20 22:12:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 787 bytes |
コンパイル時間 | 174 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 27,580 KB |
最終ジャッジ日時 | 2024-07-18 11:00:02 |
合計ジャッジ時間 | 19,280 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 TLE * 5 |
ソースコード
LenA = 4 LenB = 7 A = "good" B = "problem" def solve(S): N = len(S) sumB = [0] * N for i in range(LenB, N): sumB[i] = sumB[i - 1] if S[i - LenB: i] == B: sumB[i] += 1 minAmoves = [N] * N for i in range(0, N - LenA + 1): count = 0 for d in range(LenA): if S[i + d] != A[d]: count += 1 minAmoves[i] = count + sumB[i] minAmoves[i] = min(minAmoves[i], minAmoves[i - 1]) ans = N for i in range(LenA, N - LenB + 1): count = 0 for d in range(LenB): if S[i + d] != B[d]: count += 1 ans = min(ans, count + minAmoves[i - LenA]) return ans T = int(input()) S = [input() for i in range(T)] for s in S: print(solve(s))