結果

問題 No.996 Phnom Penh
ユーザー vwxyz
提出日時 2024-07-16 23:37:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 15,376 KB
最終ジャッジ日時 2024-07-16 23:38:04
合計ジャッジ時間 6,304 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

S=list(input())
def operate(S,T0,T1):
    queue=[]
    cnt=0
    for s in S:
        queue.append(s)
        while len(queue)>=len(T0) and queue[len(queue)-len(T0):]==T0:
            for _ in range(len(T0)):
                queue.pop()
            for t in T1:
                queue.append(t)
            cnt+=1
    return queue,cnt
ans=0
S,cnt=operate(S,list("phnom"),list("penh"))
ans+=cnt
if "h" in S or "e" in S:
    S,_=operate(S,["h"],[])
    S,_=operate(S,["e"],["h"])
    ans+=1
queue=[]
cnt=[]
for s in S:
    queue.append(s)
    if len(queue)>=5 and queue[-5:]==list("phnom"):
        cnt.append(1)
    elif len(queue)>=7 and queue[-7:]==list("phnomom"):
        for _ in range(2):
            queue.pop()
        cnt[-1]+=1
if cnt:
    ans+=sum(cnt)+max(cnt)+1
elif "h" in S:
    ans+=1
print(ans)
0