結果
| 問題 | 
                            No.996 Phnom Penh
                             | 
                    
| コンテスト | |
| ユーザー | 
                             titia
                         | 
                    
| 提出日時 | 2020-02-21 23:11:33 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,086 bytes | 
| コンパイル時間 | 436 ms | 
| コンパイル使用メモリ | 12,800 KB | 
| 実行使用メモリ | 11,392 KB | 
| 最終ジャッジ日時 | 2024-10-09 02:11:28 | 
| 合計ジャッジ時間 | 3,524 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 16 WA * 9 | 
ソースコード
S=input()
LEN=len(S)
S+="z"*100
D1=[]
D2=[]
for i in range(LEN):
    if S[i:i+3]=="phn":
        ind=i+3
        while S[ind:ind+2]=="om":
            ind+=2
            while S[ind]=="e" or S[ind]=="h":
                ind+=1
        #print(i,ind)
        D1.append((ind-(i+3))//2)
for i in range(LEN):
    if S[i:i+2]=="om":
        ind=i-1
        while ind>=0 and S[ind]=="h":
            ind-=1
        #print(i,ind)
        if S[ind-2:ind+1]=="pen":
            ind2=i
            while S[ind2:ind2+2]=="om":
                ind2+=2
                while S[ind2]=="e" or S[ind2]=="h":
                    ind2+=1
            if (ind2-i)//2>0:
                D2.append((ind2-i)//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)
            
        
            
            
            
        
            
titia