結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー maspymaspy
提出日時 2020-03-07 00:54:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 838 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 60,028 KB
最終ジャッジ日時 2024-04-22 11:38:10
合計ジャッジ時間 7,711 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 693 ms
51,568 KB
testcase_01 TLE -
testcase_02 AC 631 ms
51,328 KB
testcase_03 AC 643 ms
59,880 KB
testcase_04 AC 640 ms
60,028 KB
testcase_05 AC 641 ms
59,900 KB
testcase_06 AC 532 ms
44,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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 = np.array(list(read().rstrip()), dtype=np.int8)


# %%
def solve(S):
    if S[0] == ord('\n'):
        S = S[1:]
    L = len(S)
    P = np.zeros(L - 6, np.int32)
    for i, ch in enumerate(b'problem'):
        P += (S[i: L - 6 + i] != ch)

    G = np.zeros(L - 10, np.int32)
    for i, ch in enumerate(b'good'):
        G += (S[i: L - 10 + i] != ch)

    add = np.zeros_like(G)
    add[7:] += (P == 0)[:-11]
    np.cumsum(add, out=add)

    G += add
    INF = 10 ** 7
    return (np.minimum.accumulate(G[:L - 10]) + P[4:]).min()


words = np.split(words, np.where(words == ord('\n'))[0])
print('\n'.join(map(str, map(solve, words))))


# %%
0