結果

問題 No.996 Phnom Penh
ユーザー titiatitia
提出日時 2020-02-21 23:25:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,617 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-04-17 09:24:42
合計ジャッジ時間 2,895 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 26 ms
10,752 KB
testcase_07 AC 28 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 27 ms
10,752 KB
testcase_10 AC 26 ms
10,624 KB
testcase_11 AC 28 ms
10,880 KB
testcase_12 AC 28 ms
10,752 KB
testcase_13 WA -
testcase_14 AC 133 ms
11,264 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 27 ms
10,752 KB
testcase_19 WA -
testcase_20 AC 26 ms
10,752 KB
testcase_21 AC 26 ms
10,752 KB
testcase_22 AC 25 ms
10,624 KB
testcase_23 AC 27 ms
10,752 KB
testcase_24 AC 211 ms
11,264 KB
testcase_25 AC 184 ms
11,288 KB
testcase_26 AC 190 ms
11,264 KB
testcase_27 AC 184 ms
11,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
LEN=len(S)
S+="z"*100

D1=[]
D2=[]

for i in range(LEN):
    if S[i:i+3]=="phn":
        ind=i+3
        count=0
        while True:
            if S[ind]=="h" and count>=1:
                ind+=1
            if S[ind]=="e" and count>=2:
                ind+=1
            elif count%2==0 and S[ind]=="o":
                ind+=1
                count+=1
            elif count%2==1 and S[ind]=="m":
                ind+=1
                count+=1
            else:
                break

        #print(i,ind)

        D1.append(count//2)

for i in range(LEN):
    if S[i]=="o":
        ind=i-1
        while ind>=0 and S[ind]=="h":
            ind-=1

        #print(i,ind)

        if S[ind-2:ind+1]=="pen":

            ind2=i

            count=0
            while True:
                if S[ind2]=="h" and count>=0:
                    ind2+=1
                if S[ind2]=="e" and count>=1:
                    ind2+=1
                elif count%2==0 and S[ind2]=="o":
                    ind2+=1
                    count+=1
                elif count%2==1 and S[ind2]=="m":
                    ind2+=1
                    count+=1
                else:
                    break

            D2.append(count//2)


if D1==[] and D2==[]:
    if "e" in S:
        print(2)
    elif "h" in S:
        print(1)
    else:
        print(0)
else:
    if D2==[]:
        print(sum(D1)+max(D1)+1)
    elif D1==[]:
        print(sum(D2)+max(D2)+2)
    else:
        if max(D1)>max(D2):
            print(sum(D1)+sum(D2)+max(D1)+1)
        else:
            print(sum(D1)+sum(D2)+max(D2)+2)
            
        
0