結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-08 11:46:18
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 814 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-04-15 13:47:05
合計ジャッジ時間 6,562 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(raw_input())

def dif(s,t):
    cnt=0
    for a,b in zip(s,t):
        if a!=b:
            cnt+=1
    return cnt

for case in range(T):
    s=raw_input()
    gtable=[4 for i in s]
    ptable=[7 for i in s]
    ptable2=[0 for i in s]
    for i in range(len(s)-3):
        if i>0:
            gtable[i]=gtable[i-1]
        gtable[i]= min(gtable[i],dif( s[i:i+4], "good"))
    for i in range(len(s)-7,-1,-1):
        ptable[i]=ptable[i+1]
        ptable[i]=min(ptable[i],dif(s[i:i+7],"problem"))
    for i in range(len(s)-6):
        if i>0:
            ptable2[i]=ptable2[i-1]
        if dif(s[i:i+7],"problem")==0:
            ptable2[i]+=1

    ans=11
    for i in range(len(s)-10):
        #print gtable[i],"+",ptable[i+4],"+",ptable2[i]
        ans=min(ans,ptable2[i]+gtable[i]+ptable[i+4])
    print ans
0