結果
| 問題 |
No.252 "良問"(良問とは言っていない (2)
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-07 01:14:30 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,360 ms / 2,000 ms |
| コード長 | 866 bytes |
| コンパイル時間 | 111 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 75,900 KB |
| 最終ジャッジ日時 | 2024-10-14 11:00:52 |
| 合計ジャッジ時間 | 6,807 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
ソースコード
#!/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())
S = np.array(list(read().rstrip()), dtype=np.int8)
# %%
G = np.zeros(len(S), dtype=np.int64)
P = np.zeros(len(S), dtype=np.int64)
for i, ch in enumerate(b'problem'):
P[:-6] += (S[i: len(S) - 6 + i] != ch)
for i, ch in enumerate(b'good'):
G[:-4] += (S[i: len(S) - 4 + i] != ch)
ind = np.where(S == ord('\n'))[0]
Ss = np.split(S, ind)
Gs = np.split(G, ind)
Ps = np.split(P, ind)
# %%
def solve(S, G, P):
if S[0] == ord('\n'):
S = S[1:]
G = G[1:]
P = P[1:]
G[7:] += np.cumsum(P[:-7] == 0)
G = np.minimum.accumulate(G[:-10])
cost = G + P[4:-6]
return cost.min()
for S, G, P in zip(Ss, Gs, Ps):
print(solve(S, G, P))
maspy