結果
| 問題 | No.252 "良問"(良問とは言っていない (2) | 
| コンテスト | |
| ユーザー |  maspy | 
| 提出日時 | 2020-03-07 00:36:25 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 764 bytes | 
| コンパイル時間 | 81 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 49,396 KB | 
| 最終ジャッジ日時 | 2024-10-14 10:54:27 | 
| 合計ジャッジ時間 | 6,809 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 1 TLE * 1 -- * 5 | 
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
# %%
T = int(readline())
words = read().decode().split()
# %%
def solve(S):
    S = np.array(list(S))
    L = len(S)
    P = np.zeros(L - 6, np.int32)
    for i, ch in enumerate('problem'):
        P += 1 * (S[i: L - 6 + i] != ch)
    G = np.zeros(L - 4, np.int32)
    for i, ch in enumerate('good'):
        G += 1 * (S[i: L - 4 + i] != ch)
    add = np.zeros_like(G)
    add[7:] += (P == 0)[:-5]
    np.cumsum(add, out=add)
    G += add
    INF = 10 ** 7
    G = np.concatenate([[INF]*4, G])
    return (np.minimum.accumulate(G[:L - 6]) + P).min()
for w in words:
    print(solve(w))
# %%
            
            
            
        