結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー yaoshimaxyaoshimax
提出日時 2016-05-08 11:46:43
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 76,928 KB
実行使用メモリ 104,704 KB
最終ジャッジ日時 2024-04-15 13:47:25
合計ジャッジ時間 13,415 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,707 ms
90,116 KB
testcase_01 AC 1,503 ms
81,816 KB
testcase_02 AC 1,893 ms
104,704 KB
testcase_03 AC 1,657 ms
103,944 KB
testcase_04 AC 1,673 ms
104,248 KB
testcase_05 AC 1,601 ms
103,732 KB
testcase_06 WA -
権限があれば一括ダウンロードができます

ソースコード

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