結果
| 問題 |
No.252 "良問"(良問とは言っていない (2)
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2025-01-11 00:34:43 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,337 bytes |
| コンパイル時間 | 1,096 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 45,236 KB |
| 最終ジャッジ日時 | 2025-01-11 00:35:07 |
| 合計ジャッジ時間 | 23,112 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 6 |
ソースコード
import sys
input = sys.stdin.readline
t=int(input())
for tests in range(t):
S=input().strip()
ANS=[1<<60]*len(S)
ANS2=[1<<60]*len(S)
PLUS=[0]*len(S)
for i in range(len(S)):
s=S[i:i+4]
if len(s)==4:
score=0
if s[0]!="g":
score+=1
if s[1]!="o":
score+=1
if s[2]!="o":
score+=1
if s[3]!="d":
score+=1
ANS[i]=score
s=S[i:i+7]
if len(s)==7:
score=0
if s[0]!="p":
score+=1
if s[1]!="r":
score+=1
if s[2]!="o":
score+=1
if s[3]!="b":
score+=1
if s[4]!="l":
score+=1
if s[5]!="e":
score+=1
if s[6]!="m":
score+=1
ANS2[i]=score
if score==0:
PLUS[i+1]=1
#print(ANS)
#print(ANS2)
#print(PLUS)
for i in range(1,len(S)):
PLUS[i]+=PLUS[i-1]
for i in range(len(S)-2,-1,-1):
ANS2[i]=min(ANS2[i+1],ANS2[i])
LANS=1<<64
for i in range(len(S)-4):
LANS=min(LANS,ANS[i]+ANS2[i+4]+PLUS[i])
if ANS[i]==0:
break
print(LANS)
titia